Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl
Commits:
750c109a by Raymond Toy at 2022-08-04T07:36:39-07:00
Remove solaris versions of stat and friends
This has been replaced by unix_stat and friends.
- - - - -
1 changed file:
- src/code/unix.lisp
Changes:
=====================================
src/code/unix.lisp
=====================================
@@ -1467,42 +1467,6 @@
(declare (type unix-fd fd))
(call-stat "unix_fstat" int fd)))
-;;; 64-bit versions of stat and friends
-#+solaris
-(progn
-(defun unix-stat (name)
- _N"Unix-stat retrieves information about the specified
- file returning them in the form of multiple values.
- See the UNIX Programmer's Manual for a description
- of the values returned. If the call fails, then NIL
- and an error number is returned instead."
- (declare (type unix-pathname name))
- (when (string= name "")
- (setf name "."))
- (with-alien ((buf (struct stat64)))
- (syscall ("stat64" c-string (* (struct stat64)))
- (extract-stat-results buf)
- (%name->file name) (addr buf))))
-
-(defun unix-lstat (name)
- _N"Unix-lstat is similar to unix-stat except the specified
- file must be a symbolic link."
- (declare (type unix-pathname name))
- (with-alien ((buf (struct stat64)))
- (syscall ("lstat64" c-string (* (struct stat64)))
- (extract-stat-results buf)
- (%name->file name) (addr buf))))
-
-(defun unix-fstat (fd)
- _N"Unix-fstat is similar to unix-stat except the file is specified
- by the file descriptor fd."
- (declare (type unix-fd fd))
- (with-alien ((buf (struct stat64)))
- (syscall ("fstat64" int (* (struct stat64)))
- (extract-stat-results buf)
- fd (addr buf))))
-)
-
(def-alien-type nil
(struct rusage
(ru-utime (struct timeval)) ; user time used
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/750c109add317988cdb319e…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/750c109add317988cdb319e…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl
Commits:
a831003a by Raymond Toy at 2022-08-04T07:18:22-07:00
Update POT file for new docstrings for stat
- - - - -
1 changed file:
- src/i18n/locale/cmucl-unix.pot
Changes:
=====================================
src/i18n/locale/cmucl-unix.pot
=====================================
@@ -486,6 +486,76 @@ msgstr ""
msgid "Size of control character vector."
msgstr ""
+#: src/code/unix.lisp
+msgid ""
+"Unix-stat retrieves information about the specified\n"
+" file returning them in the form of multiple values. If the call\n"
+" fails, then NIL and an error number is returned. If the call\n"
+" succeeds, then T is returned in addition to the following values\n"
+" from the stat struct st:\n"
+"\n"
+" st_dev Device ID\n"
+" st_ino File serial number\n"
+" st_mode Mode of file\n"
+" st_nlink Number of hard links to the file\n"
+" st_uid User ID\n"
+" st_gid Group ID\n"
+" st_rdev Device ID (if file is character or block special)\n"
+" st_atime Last data access time, in sec\n"
+" st_mtime Last data modification time, in sec\n"
+" st_ctime Last file status change time, in sec\n"
+" st_blksize Preferred I/O block size\n"
+" st_blocks Number of blocks allocated. (Block size is implementation"
+" dependent.)\n"
+""
+msgstr ""
+
+#: src/code/unix.lisp
+msgid ""
+"Unix-fstat is similar to unix-stat except the file is specified\n"
+" by the file descriptor fd. If the call fails, then NIL and an\n"
+" error number is returned. If the call succeeds, then T is returned\n"
+" in addition to the following values from the stat struct st:\n"
+"\n"
+" st_dev Device ID\n"
+" st_ino File serial number\n"
+" st_mode Mode of file\n"
+" st_nlink Number of hard links to the file\n"
+" st_uid User ID\n"
+" st_gid Group ID\n"
+" st_rdev Device ID (if file is character or block special)\n"
+" st_atime Last data access time, in sec\n"
+" st_mtime Last data modification time, in sec\n"
+" st_ctime Last file status change time, in sec\n"
+" st_blksize Preferred I/O block size\n"
+" st_blocks Number of blocks allocated. (Block size is implementation"
+" dependent.)\n"
+""
+msgstr ""
+
+#: src/code/unix.lisp
+msgid ""
+"Unix-lstat is similar to unix-stat except the specified\n"
+" file must be a symbolic link. If the call fails, then NIL and an\n"
+" error number is returned. If the call succeeds, then T is returned\n"
+" in addition to the following values from the stat struct st:\n"
+"\n"
+" st_dev Device ID\n"
+" st_ino File serial number\n"
+" st_mode Mode of file\n"
+" st_nlink Number of hard links to the file\n"
+" st_uid User ID\n"
+" st_gid Group ID\n"
+" st_rdev Device ID (if file is character or block special)\n"
+" st_atime Last data access time, in sec\n"
+" st_mtime Last data modification time, in sec\n"
+" st_ctime Last file status change time, in sec\n"
+" st_blksize Preferred I/O block size\n"
+" st_blocks Number of blocks allocated. (Block size is implementation"
+" dependent.)\n"
+""
+msgstr ""
+
#: src/code/unix.lisp
msgid ""
"Unix-stat retrieves information about the specified\n"
@@ -497,14 +567,14 @@ msgstr ""
#: src/code/unix.lisp
msgid ""
-"Unix-fstat is similar to unix-stat except the file is specified\n"
-" by the file descriptor fd."
+"Unix-lstat is similar to unix-stat except the specified\n"
+" file must be a symbolic link."
msgstr ""
#: src/code/unix.lisp
msgid ""
-"Unix-lstat is similar to unix-stat except the specified\n"
-" file must be a symbolic link."
+"Unix-fstat is similar to unix-stat except the file is specified\n"
+" by the file descriptor fd."
msgstr ""
#: src/code/unix.lisp
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/a831003a17f8c31c2e96d41…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/a831003a17f8c31c2e96d41…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl
Commits:
c36ad0c7 by Raymond Toy at 2022-08-03T19:53:21-07:00
Remove unused alien types and update docstrings
The alien types dev-t and nlink-t aren't used anywhere anymore so
remove them.
Update the docstrings for unix-stat and friends to describe what the
multiple return values are.
- - - - -
1 changed file:
- src/code/unix.lisp
Changes:
=====================================
src/code/unix.lisp
=====================================
@@ -69,14 +69,6 @@
#+(and bsd netbsd) int64-t
#+alpha unsigned-int)
-#+nil
-(def-alien-type dev-t
- #-(or alpha svr4 bsd linux) short
- #+linux u-int64-t
- #+netbsd u-int64-t
- #+alpha int
- #+(and (not linux) (not netbsd) (or bsd svr4)) unsigned-long)
-
#-BSD
(progn
(deftype file-offset () '(signed-byte 32))
@@ -128,13 +120,6 @@
`(multiple-value-bind (,word ,bit) (floor ,offset 32)
(logbitp ,bit (deref (slot ,fd-set 'fds-bits) ,word)))))
-(def-alien-type nlink-t
- #-(or svr4 netbsd linux) unsigned-short
- #+netbsd unsigned-long
- #+svr4 unsigned-long
- #+(and linux (not amd64)) unsigned-int
- #+(and linux amd64) u-int64-t)
-
(defconstant fd-setsize
#-(or hpux alpha linux FreeBSD) 256
#+hpux 2048 #+alpha 4096 #+(or linux FreeBSD) 1024)
@@ -1415,10 +1400,24 @@
blocks))))))
(defun unix-stat (name)
_N"Unix-stat retrieves information about the specified
- file returning them in the form of multiple values.
- See the UNIX Programmer's Manual for a description
- of the values returned. If the call fails, then NIL
- and an error number is returned instead."
+ file returning them in the form of multiple values. If the call
+ fails, then NIL and an error number is returned. If the call
+ succeeds, then T is returned in addition to the following values
+ from the stat struct st:
+
+ st_dev Device ID
+ st_ino File serial number
+ st_mode Mode of file
+ st_nlink Number of hard links to the file
+ st_uid User ID
+ st_gid Group ID
+ st_rdev Device ID (if file is character or block special)
+ st_atime Last data access time, in sec
+ st_mtime Last data modification time, in sec
+ st_ctime Last file status change time, in sec
+ st_blksize Preferred I/O block size
+ st_blocks Number of blocks allocated. (Block size is implementation dependent.)
+"
(declare (type unix-pathname name))
(when (string= name "")
(setf name "."))
@@ -1426,13 +1425,45 @@
(defun unix-lstat (name)
"Unix-lstat is similar to unix-stat except the specified
- file must be a symbolic link."
+ file must be a symbolic link. If the call fails, then NIL and an
+ error number is returned. If the call succeeds, then T is returned
+ in addition to the following values from the stat struct st:
+
+ st_dev Device ID
+ st_ino File serial number
+ st_mode Mode of file
+ st_nlink Number of hard links to the file
+ st_uid User ID
+ st_gid Group ID
+ st_rdev Device ID (if file is character or block special)
+ st_atime Last data access time, in sec
+ st_mtime Last data modification time, in sec
+ st_ctime Last file status change time, in sec
+ st_blksize Preferred I/O block size
+ st_blocks Number of blocks allocated. (Block size is implementation dependent.)
+"
(declare (type unix-pathname name))
(call-stat "unix_lstat" c-call:c-string (%name->file name)))
(defun unix-fstat (fd)
_N"Unix-fstat is similar to unix-stat except the file is specified
- by the file descriptor fd."
+ by the file descriptor fd. If the call fails, then NIL and an
+ error number is returned. If the call succeeds, then T is returned
+ in addition to the following values from the stat struct st:
+
+ st_dev Device ID
+ st_ino File serial number
+ st_mode Mode of file
+ st_nlink Number of hard links to the file
+ st_uid User ID
+ st_gid Group ID
+ st_rdev Device ID (if file is character or block special)
+ st_atime Last data access time, in sec
+ st_mtime Last data modification time, in sec
+ st_ctime Last file status change time, in sec
+ st_blksize Preferred I/O block size
+ st_blocks Number of blocks allocated. (Block size is implementation dependent.)
+"
(declare (type unix-fd fd))
(call-stat "unix_fstat" int fd)))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c36ad0c736ca2f037eddb83…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c36ad0c736ca2f037eddb83…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl
Commits:
b726c5a4 by Raymond Toy at 2022-08-03T19:01:31-07:00
Don't use dev_t and friends in stat interface definition.
To simplify things, don't use dev_t and friends in the C interface.
Instead, use the largest integer type that any OS would want to use.
So dev_t becomes u_int64_t because Linux can return 64-bit integers
here. This would work just fine for macos which uses 32-bit integers.
We are depending on the compiler to produce a warning or error if we
try to store a larger integer type into a smaller type.
- - - - -
2 changed files:
- src/code/unix.lisp
- src/lisp/os-common.c
Changes:
=====================================
src/code/unix.lisp
=====================================
@@ -69,6 +69,7 @@
#+(and bsd netbsd) int64-t
#+alpha unsigned-int)
+#+nil
(def-alien-type dev-t
#-(or alpha svr4 bsd linux) short
#+linux u-int64-t
@@ -1351,37 +1352,37 @@
;; to the stat function. fstat is different from stat and
;; lstat since it takes an fd for the first arg instead of
;; string.
- `(with-alien ((dev dev-t)
- (ino ino-t)
- (mode mode-t)
- (nlink nlink-t)
- (uid uid-t)
- (gid gid-t)
- (rdev dev-t)
- (size off-t)
- (atime time-t)
- (mtime time-t)
- (ctime time-t)
+ `(with-alien ((dev u-int64-t)
+ (ino u-int64-t)
+ (mode c-call:unsigned-int)
+ (nlink u-int64-t)
+ (uid c-call:unsigned-int)
+ (gid c-call:unsigned-int)
+ (rdev u-int64-t)
+ (size int64-t)
+ (atime int64-t)
+ (mtime int64-t)
+ (ctime int64-t)
(blksize c-call:long)
- (blocks off-t))
+ (blocks int64-t))
(let ((result
(alien-funcall
(extern-alien ,c-func-name
(function int
,first-arg-type
- (* dev-t)
- (* ino-t)
- (* mode-t)
- (* nlink-t)
- (* uid-t)
- (* gid-t)
- (* dev-t)
- (* off-t)
- (* time-t)
- (* time-t)
- (* time-t)
+ (* u-int64-t)
+ (* u-int64-t)
+ (* c-call:unsigned-int)
+ (* u-int64-t)
+ (* c-call:unsigned-int)
+ (* c-call:unsigned-int)
+ (* u-int64-t)
+ (* int64-t)
+ (* int64-t)
+ (* int64-t)
+ (* int64-t)
(* c-call:long)
- (* off-t)))
+ (* int64-t)))
,first-arg
(addr dev)
(addr ino)
=====================================
src/lisp/os-common.c
=====================================
@@ -597,11 +597,19 @@ os_sleep(double seconds)
}
}
+/*
+ * Interface to stat/fstat/lstat.
+ *
+ * The arg types are chosen such that they can hold the largest
+ * possible value that any OS would use for the particular slot in the
+ * stat structure. That way we can just use one OS-independent
+ * function that works across all OSes.
+ */
int
-unix_stat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
- uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
- time_t *atime, time_t *mtime, time_t *ctime,
- long *blksize, off_t *blocks)
+unix_stat(const char* path, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
+ unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
+ int64_t *atime, int64_t *mtime, int64_t *ctime,
+ long *blksize, int64_t *blocks)
{
int rc;
struct stat buf;
@@ -647,10 +655,10 @@ unix_stat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink
}
int
-unix_fstat(int fd, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
- uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
- time_t *atime, time_t *mtime, time_t *ctime,
- long *blksize, off_t *blocks)
+unix_fstat(int fd, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
+ unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
+ int64_t *atime, int64_t *mtime, int64_t *ctime,
+ long *blksize, int64_t *blocks)
{
int rc;
struct stat buf;
@@ -675,10 +683,10 @@ unix_fstat(int fd, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
}
int
-unix_lstat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
- uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
- time_t *atime, time_t *mtime, time_t *ctime,
- long *blksize, off_t *blocks)
+unix_lstat(const char* path, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
+ unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
+ int64_t *atime, int64_t *mtime, int64_t *ctime,
+ long *blksize, int64_t *blocks)
{
int rc;
struct stat buf;
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/b726c5a416dd05fc6fbd848…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/b726c5a416dd05fc6fbd848…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl
Commits:
34a975ee by Raymond Toy at 2022-08-03T13:02:19-07:00
Replace ino64-t with ino-t on linux.
Basically makes ino-t be a 64-bit int and removes the ino64-t type for
linux. Requires updating stat calls to use ino-t instead of ino64-t,
of course.
- - - - -
1 changed file:
- src/code/unix.lisp
Changes:
=====================================
src/code/unix.lisp
=====================================
@@ -53,12 +53,9 @@
(def-alien-type u-int32-t unsigned-int)
(def-alien-type ino-t
- #+netbsd u-int64-t
+ #+(or netbsd linux darwin) u-int64-t
#+alpha unsigned-int
- #-(or alpha netbsd) unsigned-long)
-
-#+linux
-(def-alien-type ino64-t u-int64-t)
+ #-(or alpha netbsd linux darwin) unsigned-long)
(def-alien-type size-t
#-(or linux alpha) long
@@ -1300,7 +1297,7 @@
#+glibc2.1
(d-ino ino-t) ; inode number of entry
#-glibc2.1
- (d-ino ino64-t) ; inode number of entry
+ (d-ino ino-t) ; inode number of entry
(d-off off-t) ; offset of next disk directory entry
(d-reclen unsigned-short) ; length of this record
(d_type unsigned-char)
@@ -1346,15 +1343,16 @@
(d-name (array char 256)))) ; name must be no longer than this
+;; unix-stat and friends
(macrolet
((call-stat (c-func-name first-arg-type first-arg)
;; Call the stat function named C-FUNC-NAME. The type of the
- ;; first arg is FIRST-ARG_TYPE and FIRST-ARG is the first arg
+ ;; first arg is FIRST-ARG-TYPE and FIRST-ARG is the first arg
;; to the stat function. fstat is different from stat and
;; lstat since it takes an fd for the first arg instead of
;; string.
`(with-alien ((dev dev-t)
- (ino ino64-t)
+ (ino ino-t)
(mode mode-t)
(nlink nlink-t)
(uid uid-t)
@@ -1372,7 +1370,7 @@
(function int
,first-arg-type
(* dev-t)
- (* ino64-t)
+ (* ino-t)
(* mode-t)
(* nlink-t)
(* uid-t)
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/34a975ee5749c15840971bc…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/34a975ee5749c15840971bc…
You're receiving this email because of your account on gitlab.common-lisp.net.