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
 
2 changed files:
Changes:
| ... | ... | @@ -69,6 +69,7 @@ | 
| 69 | 69 |      #+(and bsd netbsd) int64-t
 | 
| 70 | 70 |      #+alpha unsigned-int)
 | 
| 71 | 71 | |
| 72 | +#+nil
 | 
|
| 72 | 73 |  (def-alien-type dev-t
 | 
| 73 | 74 |      #-(or alpha svr4 bsd linux) short
 | 
| 74 | 75 |      #+linux u-int64-t
 | 
| ... | ... | @@ -1351,37 +1352,37 @@ | 
| 1351 | 1352 |         ;; to the stat function.  fstat is different from stat and
 | 
| 1352 | 1353 |         ;; lstat since it takes an fd for the first arg instead of
 | 
| 1353 | 1354 |         ;; string.
 | 
| 1354 | -       `(with-alien ((dev dev-t)
 | 
|
| 1355 | -		     (ino ino-t)
 | 
|
| 1356 | -		     (mode mode-t)
 | 
|
| 1357 | -		     (nlink nlink-t)
 | 
|
| 1358 | -		     (uid uid-t)
 | 
|
| 1359 | -		     (gid gid-t)
 | 
|
| 1360 | -		     (rdev dev-t)
 | 
|
| 1361 | -		     (size off-t)
 | 
|
| 1362 | -		     (atime time-t)
 | 
|
| 1363 | -		     (mtime time-t)
 | 
|
| 1364 | -		     (ctime time-t)
 | 
|
| 1355 | +       `(with-alien ((dev u-int64-t)
 | 
|
| 1356 | +		     (ino u-int64-t)
 | 
|
| 1357 | +		     (mode c-call:unsigned-int)
 | 
|
| 1358 | +		     (nlink u-int64-t)
 | 
|
| 1359 | +		     (uid c-call:unsigned-int)
 | 
|
| 1360 | +		     (gid c-call:unsigned-int)
 | 
|
| 1361 | +		     (rdev u-int64-t)
 | 
|
| 1362 | +		     (size int64-t)
 | 
|
| 1363 | +		     (atime int64-t)
 | 
|
| 1364 | +		     (mtime int64-t)
 | 
|
| 1365 | +		     (ctime int64-t)
 | 
|
| 1365 | 1366 |  		     (blksize c-call:long)
 | 
| 1366 | -		     (blocks off-t))
 | 
|
| 1367 | +		     (blocks int64-t))
 | 
|
| 1367 | 1368 |  	  (let ((result
 | 
| 1368 | 1369 |  		  (alien-funcall
 | 
| 1369 | 1370 |  		   (extern-alien ,c-func-name
 | 
| 1370 | 1371 |  				 (function int
 | 
| 1371 | 1372 |  					   ,first-arg-type
 | 
| 1372 | -					   (* dev-t)
 | 
|
| 1373 | -					   (* ino-t)
 | 
|
| 1374 | -					   (* mode-t)
 | 
|
| 1375 | -					   (* nlink-t)
 | 
|
| 1376 | -					   (* uid-t)
 | 
|
| 1377 | -					   (* gid-t)
 | 
|
| 1378 | -					   (* dev-t)
 | 
|
| 1379 | -					   (* off-t)
 | 
|
| 1380 | -					   (* time-t)
 | 
|
| 1381 | -					   (* time-t)
 | 
|
| 1382 | -					   (* time-t)
 | 
|
| 1373 | +					   (* u-int64-t)
 | 
|
| 1374 | +					   (* u-int64-t)
 | 
|
| 1375 | +					   (* c-call:unsigned-int)
 | 
|
| 1376 | +					   (* u-int64-t)
 | 
|
| 1377 | +					   (* c-call:unsigned-int)
 | 
|
| 1378 | +					   (* c-call:unsigned-int)
 | 
|
| 1379 | +					   (* u-int64-t)
 | 
|
| 1380 | +					   (* int64-t)
 | 
|
| 1381 | +					   (* int64-t)
 | 
|
| 1382 | +					   (* int64-t)
 | 
|
| 1383 | +					   (* int64-t)
 | 
|
| 1383 | 1384 |  					   (* c-call:long)
 | 
| 1384 | -					   (* off-t)))
 | 
|
| 1385 | +					   (* int64-t)))
 | 
|
| 1385 | 1386 |  		   ,first-arg
 | 
| 1386 | 1387 |  		   (addr dev)
 | 
| 1387 | 1388 |  		   (addr ino)
 | 
| ... | ... | @@ -597,11 +597,19 @@ os_sleep(double seconds) | 
| 597 | 597 |      }
 | 
| 598 | 598 |  }
 | 
| 599 | 599 |  
 | 
| 600 | +/*
 | 
|
| 601 | + * Interface to stat/fstat/lstat.
 | 
|
| 602 | + *
 | 
|
| 603 | + * The arg types are chosen such that they can hold the largest
 | 
|
| 604 | + * possible value that any OS would use for the particular slot in the
 | 
|
| 605 | + * stat structure.  That way we can just use one OS-independent
 | 
|
| 606 | + * function that works across all OSes.
 | 
|
| 607 | + */
 | 
|
| 600 | 608 |  int
 | 
| 601 | -unix_stat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
 | 
|
| 602 | -          uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
 | 
|
| 603 | -          time_t *atime, time_t *mtime, time_t *ctime,
 | 
|
| 604 | -          long *blksize, off_t *blocks)
 | 
|
| 609 | +unix_stat(const char* path, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
 | 
|
| 610 | +          unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
 | 
|
| 611 | +          int64_t *atime, int64_t *mtime, int64_t *ctime,
 | 
|
| 612 | +          long *blksize, int64_t *blocks)
 | 
|
| 605 | 613 |  {
 | 
| 606 | 614 |      int rc;
 | 
| 607 | 615 |      struct stat buf;
 | 
| ... | ... | @@ -647,10 +655,10 @@ unix_stat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink | 
| 647 | 655 |  }
 | 
| 648 | 656 | |
| 649 | 657 |  int
 | 
| 650 | -unix_fstat(int fd, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
 | 
|
| 651 | -           uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
 | 
|
| 652 | -           time_t *atime, time_t *mtime, time_t *ctime,
 | 
|
| 653 | -           long *blksize, off_t *blocks)
 | 
|
| 658 | +unix_fstat(int fd, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
 | 
|
| 659 | +           unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
 | 
|
| 660 | +           int64_t *atime, int64_t *mtime, int64_t *ctime,
 | 
|
| 661 | +           long *blksize, int64_t *blocks)
 | 
|
| 654 | 662 |  {
 | 
| 655 | 663 |      int rc;
 | 
| 656 | 664 |      struct stat buf;
 | 
| ... | ... | @@ -675,10 +683,10 @@ unix_fstat(int fd, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink, | 
| 675 | 683 |  }
 | 
| 676 | 684 | |
| 677 | 685 |  int
 | 
| 678 | -unix_lstat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
 | 
|
| 679 | -           uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
 | 
|
| 680 | -           time_t *atime, time_t *mtime, time_t *ctime,
 | 
|
| 681 | -           long *blksize, off_t *blocks)
 | 
|
| 686 | +unix_lstat(const char* path, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
 | 
|
| 687 | +           unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
 | 
|
| 688 | +           int64_t *atime, int64_t *mtime, int64_t *ctime,
 | 
|
| 689 | +           long *blksize, int64_t *blocks)
 | 
|
| 682 | 690 |  {
 | 
| 683 | 691 |      int rc;
 | 
| 684 | 692 |      struct stat buf;
 |