Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl

Commits:

6 changed files:

Changes:

  • src/code/unix.lisp
    ... ... @@ -1346,232 +1346,6 @@
    1346 1346
         (d-name (array char 256))))		; name must be no longer than this
    
    1347 1347
     
    
    1348 1348
     
    
    1349
    -#+(and bsd (not netbsd))
    
    1350
    -(def-alien-type nil
    
    1351
    -  (struct stat
    
    1352
    -    (st-dev dev-t)
    
    1353
    -    (st-ino ino-t)
    
    1354
    -    (st-mode mode-t)
    
    1355
    -    (st-nlink nlink-t)
    
    1356
    -    (st-uid uid-t)
    
    1357
    -    (st-gid gid-t)
    
    1358
    -    (st-rdev dev-t)
    
    1359
    -    (st-atime (struct timespec-t))
    
    1360
    -    (st-mtime (struct timespec-t))
    
    1361
    -    (st-ctime (struct timespec-t))
    
    1362
    -    (st-size off-t)
    
    1363
    -    (st-blocks off-t)
    
    1364
    -    (st-blksize unsigned-long)
    
    1365
    -    (st-flags   unsigned-long)
    
    1366
    -    (st-gen     unsigned-long)
    
    1367
    -    (st-lspare  long)
    
    1368
    -    (st-qspare (array long 4))))
    
    1369
    -
    
    1370
    -#+svr4
    
    1371
    -(def-alien-type nil
    
    1372
    -  (struct stat
    
    1373
    -    (st-dev dev-t)
    
    1374
    -    (st-pad1 #-linux (array long 3) #+linux unsigned-short)
    
    1375
    -    (st-ino ino-t)
    
    1376
    -    (st-mode #-linux unsigned-long #+linux unsigned-short)
    
    1377
    -    (st-nlink #-linux short #+linux unsigned-short)
    
    1378
    -    (st-uid #-linux uid-t #+linux unsigned-short)
    
    1379
    -    (st-gid #-linux gid-t #+linux unsigned-short)
    
    1380
    -    (st-rdev dev-t)
    
    1381
    -    (st-pad2 #-linux (array long 2) #+linux unsigned-short)
    
    1382
    -    (st-size off-t)
    
    1383
    -    #-linux (st-pad3 long)
    
    1384
    -    #+linux (st-blksize unsigned-long)
    
    1385
    -    #+linux (st-blocks unsigned-long)
    
    1386
    -    #-linux (st-atime (struct timestruc-t))
    
    1387
    -    #+linux (st-atime unsigned-long)
    
    1388
    -    #+linux (unused-1 unsigned-long)
    
    1389
    -    #-linux (st-mtime (struct timestruc-t))
    
    1390
    -    #+linux (st-mtime unsigned-long)
    
    1391
    -    #+linux (unused-2 unsigned-long)
    
    1392
    -    #-linux (st-ctime (struct timestruc-t))
    
    1393
    -    #+linux (st-ctime unsigned-long)
    
    1394
    -    #+linux (unused-3 unsigned-long)
    
    1395
    -    #+linux (unused-4 unsigned-long)
    
    1396
    -    #+linux (unused-5 unsigned-long)
    
    1397
    -    #-linux(st-blksize long)
    
    1398
    -    #-linux (st-blocks long)
    
    1399
    -    #-linux (st-fstype (array char 16))
    
    1400
    -    #-linux (st-pad4 (array long 8))))
    
    1401
    -
    
    1402
    -#+(and nil linux)
    
    1403
    -(def-alien-type nil
    
    1404
    -  (struct stat
    
    1405
    -    (st-dev dev-t)
    
    1406
    -    #-(or alpha amd64) (st-pad1 unsigned-short)
    
    1407
    -    (st-ino ino64-t)
    
    1408
    -    #+alpha (st-pad1 unsigned-int)
    
    1409
    -    #-amd64 (st-mode mode-t)
    
    1410
    -    (st-nlink  nlink-t)
    
    1411
    -    #+amd64 (st-mode mode-t)
    
    1412
    -    (st-uid  uid-t)
    
    1413
    -    (st-gid  gid-t)
    
    1414
    -    (st-rdev dev-t)
    
    1415
    -    #-alpha (st-pad2  unsigned-short)
    
    1416
    -    (st-size off-t)
    
    1417
    -    #-alpha (st-blksize unsigned-long)
    
    1418
    -    #-alpha (st-blocks blkcnt-t)
    
    1419
    -    (st-atime time-t)
    
    1420
    -    #-alpha (unused-1 unsigned-long)
    
    1421
    -    (st-mtime time-t)
    
    1422
    -    #-alpha (unused-2 unsigned-long)
    
    1423
    -    (st-ctime time-t)
    
    1424
    -    #+alpha (st-blocks int)
    
    1425
    -    #+alpha (st-pad2 unsigned-int)
    
    1426
    -    #+alpha (st-blksize unsigned-int)
    
    1427
    -    #+alpha (st-flags unsigned-int)
    
    1428
    -    #+alpha (st-gen unsigned-int)
    
    1429
    -    #+alpha (st-pad3 unsigned-int)
    
    1430
    -    #+alpha (unused-1 unsigned-long)
    
    1431
    -    #+alpha (unused-2 unsigned-long)
    
    1432
    -    (unused-3 unsigned-long)
    
    1433
    -    (unused-4 unsigned-long)
    
    1434
    -    #-alpha (unused-5 unsigned-long)))
    
    1435
    -
    
    1436
    -;;; 64-bit stat for Solaris
    
    1437
    -#+solaris
    
    1438
    -(def-alien-type nil
    
    1439
    -  (struct stat64
    
    1440
    -    (st-dev dev-t)
    
    1441
    -    (st-pad1 (array long 3))		; Pad so ino is 64-bit aligned
    
    1442
    -    (st-ino ino64-t)
    
    1443
    -    (st-mode unsigned-long)
    
    1444
    -    (st-nlink short)
    
    1445
    -    (st-uid uid-t)
    
    1446
    -    (st-gid gid-t)
    
    1447
    -    (st-rdev dev-t)
    
    1448
    -    (st-pad2 (array long 3))		; Pad so size is 64-bit aligned
    
    1449
    -    (st-size off64-t)
    
    1450
    -    (st-atime (struct timestruc-t))
    
    1451
    -    (st-mtime (struct timestruc-t))
    
    1452
    -    (st-ctime (struct timestruc-t))
    
    1453
    -    (st-blksize long)
    
    1454
    -    (st-pad3 (array long 1))		; Pad so blocks is 64-bit aligned
    
    1455
    -    (st-blocks blkcnt64-t)
    
    1456
    -    (st-fstype (array char 16))
    
    1457
    -    (st-pad4 (array long 8))))
    
    1458
    -
    
    1459
    -#+netbsd
    
    1460
    -(def-alien-type nil
    
    1461
    -  (struct stat
    
    1462
    -    (st-dev dev-t)
    
    1463
    -    (st-mode mode-t)
    
    1464
    -    (st-ino ino-t)
    
    1465
    -    (st-nlink nlink-t)
    
    1466
    -    (st-uid uid-t)
    
    1467
    -    (st-gid gid-t)
    
    1468
    -    (st-rdev dev-t)
    
    1469
    -    (st-atime (struct timespec-t))
    
    1470
    -    (st-mtime (struct timespec-t))
    
    1471
    -    (st-ctime (struct timespec-t))
    
    1472
    -    (st-birthtime (struct timespec-t))
    
    1473
    -    (st-size off-t)
    
    1474
    -    (st-blocks off-t)
    
    1475
    -    (st-blksize long)
    
    1476
    -    (st-flags   unsigned-long)
    
    1477
    -    (st-gen     unsigned-long)
    
    1478
    -    (st-spare (array unsigned-long 2))))
    
    1479
    -
    
    1480
    -#-linux
    
    1481
    -(defmacro extract-stat-results (buf)
    
    1482
    -  `(values T
    
    1483
    -	   (slot ,buf 'st-dev)
    
    1484
    -	   (slot ,buf 'st-ino)
    
    1485
    -	   (slot ,buf 'st-mode)
    
    1486
    -	   (slot ,buf 'st-nlink)
    
    1487
    -	   (slot ,buf 'st-uid)
    
    1488
    -	   (slot ,buf 'st-gid)
    
    1489
    -	   (slot ,buf 'st-rdev)
    
    1490
    -	   (slot ,buf 'st-size)
    
    1491
    -	   #-(or svr4 BSD) (slot ,buf 'st-atime)
    
    1492
    -	   #+svr4    (slot (slot ,buf 'st-atime) 'tv-sec)
    
    1493
    -           #+BSD (slot (slot ,buf 'st-atime) 'ts-sec)
    
    1494
    -	   #-(or svr4 BSD)(slot ,buf 'st-mtime)
    
    1495
    -	   #+svr4   (slot (slot ,buf 'st-mtime) 'tv-sec)
    
    1496
    -           #+BSD(slot (slot ,buf 'st-mtime) 'ts-sec)
    
    1497
    -	   #-(or svr4 BSD) (slot ,buf 'st-ctime)
    
    1498
    -	   #+svr4   (slot (slot ,buf 'st-ctime) 'tv-sec)
    
    1499
    -           #+BSD(slot (slot ,buf 'st-ctime) 'ts-sec)
    
    1500
    -	   #+netbsd (slot (slot ,buf 'st-birthtime) 'ts-sec)
    
    1501
    -	   (slot ,buf 'st-blksize)
    
    1502
    -	   (slot ,buf 'st-blocks)))
    
    1503
    -
    
    1504
    -#+linux
    
    1505
    -(defmacro extract-stat-results (buf)
    
    1506
    -  `(values T
    
    1507
    -           #+(or alpha amd64)
    
    1508
    -	   (slot ,buf 'st-dev)
    
    1509
    -           #-(or alpha amd64)
    
    1510
    -           (+ (deref (slot ,buf 'st-dev) 0)
    
    1511
    -	      (* (+ +max-u-long+  1)
    
    1512
    -	         (deref (slot ,buf 'st-dev) 1)))   ;;; let's hope this works..
    
    1513
    -	   (slot ,buf 'st-ino)
    
    1514
    -	   (slot ,buf 'st-mode)
    
    1515
    -	   (slot ,buf 'st-nlink)
    
    1516
    -	   (slot ,buf 'st-uid)
    
    1517
    -	   (slot ,buf 'st-gid)
    
    1518
    -           #+(or alpha amd64)
    
    1519
    -	   (slot ,buf 'st-rdev)
    
    1520
    -           #-(or alpha amd64)
    
    1521
    -           (+ (deref (slot ,buf 'st-rdev) 0)
    
    1522
    -	      (* (+ +max-u-long+  1)
    
    1523
    -	         (deref (slot ,buf 'st-rdev) 1)))   ;;; let's hope this works..
    
    1524
    -	   (slot ,buf 'st-size)
    
    1525
    -	   (slot ,buf 'st-atime)
    
    1526
    -	   (slot ,buf 'st-mtime)
    
    1527
    -	   (slot ,buf 'st-ctime)
    
    1528
    -	   (slot ,buf 'st-blksize)
    
    1529
    -	   (slot ,buf 'st-blocks)))
    
    1530
    -
    
    1531
    -#-(or linux solaris)
    
    1532
    -(progn
    
    1533
    -(defun unix-stat (name)
    
    1534
    -  _N"Unix-stat retrieves information about the specified
    
    1535
    -   file returning them in the form of multiple values.
    
    1536
    -   See the UNIX Programmer's Manual for a description
    
    1537
    -   of the values returned.  If the call fails, then NIL
    
    1538
    -   and an error number is returned instead."
    
    1539
    -  (declare (type unix-pathname name))
    
    1540
    -  (when (string= name "")
    
    1541
    -    (setf name "."))
    
    1542
    -  (with-alien ((buf (struct stat)))
    
    1543
    -    (syscall (#+linux "stat64" #+netbsd "__stat50" #-(or linux netbsd) "stat"
    
    1544
    -	      c-string (* (struct stat)))
    
    1545
    -	     (extract-stat-results buf)
    
    1546
    -	     (%name->file name) (addr buf))))
    
    1547
    -
    
    1548
    -(defun unix-lstat (name)
    
    1549
    -  _N"Unix-lstat is similar to unix-stat except the specified
    
    1550
    -   file must be a symbolic link."
    
    1551
    -  (declare (type unix-pathname name))
    
    1552
    -  (with-alien ((buf (struct stat)))
    
    1553
    -    (syscall (#+linux "lstat64" #+netbsd "__lstat50" #-(or linux netbsd) "lstat"
    
    1554
    -              c-string (* (struct stat)))
    
    1555
    -	     (extract-stat-results buf)
    
    1556
    -	     (%name->file name) (addr buf))))
    
    1557
    -
    
    1558
    -(defun unix-fstat (fd)
    
    1559
    -  _N"Unix-fstat is similar to unix-stat except the file is specified
    
    1560
    -   by the file descriptor fd."
    
    1561
    -  (declare (type unix-fd fd))
    
    1562
    -  (with-alien ((buf (struct stat)))
    
    1563
    -    (syscall (#+linux "fstat64" #+netbsd "__fstat50" #-(or linux netbsd) "fstat" 
    
    1564
    -              int (* (struct stat)))
    
    1565
    -	     (extract-stat-results buf)
    
    1566
    -	     fd (addr buf))))
    
    1567
    -)
    
    1568
    -
    
    1569
    -;; On linux we call out to our own C routine to return the appropriate
    
    1570
    -;; parts so that we don't have to mess around with making sure the
    
    1571
    -;; struct stat is consistent with the library.
    
    1572
    -;;
    
    1573
    -;; This should be updated so that all OSes do this.
    
    1574
    -#+linux
    
    1575 1349
     (macrolet
    
    1576 1350
         ((call-stat (c-func-name first-arg-type first-arg)
    
    1577 1351
            ;; Call the stat function named C-FUNC-NAME.  The type of the
    

  • src/i18n/locale/cmucl-unix.pot
    ... ... @@ -497,14 +497,14 @@ msgstr ""
    497 497
     
    
    498 498
     #: src/code/unix.lisp
    
    499 499
     msgid ""
    
    500
    -"Unix-lstat is similar to unix-stat except the specified\n"
    
    501
    -"   file must be a symbolic link."
    
    500
    +"Unix-fstat is similar to unix-stat except the file is specified\n"
    
    501
    +"   by the file descriptor fd."
    
    502 502
     msgstr ""
    
    503 503
     
    
    504 504
     #: src/code/unix.lisp
    
    505 505
     msgid ""
    
    506
    -"Unix-fstat is similar to unix-stat except the file is specified\n"
    
    507
    -"   by the file descriptor fd."
    
    506
    +"Unix-lstat is similar to unix-stat except the specified\n"
    
    507
    +"   file must be a symbolic link."
    
    508 508
     msgstr ""
    
    509 509
     
    
    510 510
     #: src/code/unix.lisp
    

  • src/lisp/Config.x86_linux
    ... ... @@ -7,7 +7,7 @@ CFLAGS += -rdynamic -march=pentium4 -mfpmath=sse -mtune=generic
    7 7
     
    
    8 8
     UNDEFSYMPATTERN = -Xlinker -u -Xlinker &
    
    9 9
     ASSEM_SRC +=  linux-stubs.S
    
    10
    -OS_SRC += Linux-os.c elf.c unix.c
    
    10
    +OS_SRC += Linux-os.c elf.c
    
    11 11
     OS_LIBS = -ldl
    
    12 12
     OS_LINK_FLAGS = -m32 -rdynamic -Xlinker --export-dynamic -Xlinker -Map -Xlinker foo
    
    13 13
     OS_LINK_FLAGS += -Wl,-z,noexecstack
    

  • src/lisp/Config.x86_linux_clang
    ... ... @@ -12,7 +12,7 @@ CFLAGS += -msse2 -mtune=pentium4 -ftrapping-math
    12 12
     
    
    13 13
     UNDEFSYMPATTERN = -Xlinker -u -Xlinker &
    
    14 14
     ASSEM_SRC +=  linux-stubs.S
    
    15
    -OS_SRC += Linux-os.c elf.c unix.c
    
    15
    +OS_SRC += Linux-os.c elf.c
    
    16 16
     OS_LIBS = -ldl
    
    17 17
     OS_LINK_FLAGS = -m32 -rdynamic -Xlinker --export-dynamic -Xlinker -Map -Xlinker foo
    
    18 18
     OS_LINK_FLAGS += -Wl,-z,noexecstack
    

  • src/lisp/os-common.c
    ... ... @@ -5,12 +5,17 @@
    5 5
     
    
    6 6
     */
    
    7 7
     
    
    8
    +#define _LARGEFILE_SOURCE
    
    9
    +#define _FILE_OFFSET_BITS 64
    
    10
    +
    
    11
    +#include <stdio.h>
    
    8 12
     #include <errno.h>
    
    9 13
     #include <math.h>
    
    10 14
     #include <netdb.h>
    
    11 15
     #include <stdio.h>
    
    12 16
     #include <string.h>
    
    13 17
     #include <time.h>
    
    18
    +#include <sys/stat.h>
    
    14 19
     
    
    15 20
     #include "os.h"
    
    16 21
     #include "internals.h"
    
    ... ... @@ -589,3 +594,98 @@ os_sleep(double seconds)
    589 594
     	requested = remaining;
    
    590 595
         }
    
    591 596
     }
    
    597
    +
    
    598
    +int unix_stat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
    
    599
    +              uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
    
    600
    +              time_t *atime, time_t *mtime, time_t *ctime,
    
    601
    +              long *blksize, off_t *blocks)
    
    602
    +{
    
    603
    +    int rc;
    
    604
    +    struct stat buf;
    
    605
    +
    
    606
    +    rc = stat(path, &buf);
    
    607
    +
    
    608
    +    fprintf(stderr, "size dev %d\n", sizeof(buf.st_dev));
    
    609
    +    fprintf(stderr, "size ino %d\n", sizeof(buf.st_ino));
    
    610
    +    fprintf(stderr, "size mode %d\n", sizeof(buf.st_mode));
    
    611
    +    fprintf(stderr, "size nlink %d\n", sizeof(buf.st_nlink));
    
    612
    +    fprintf(stderr, "size uid %d\n", sizeof(buf.st_uid));
    
    613
    +    fprintf(stderr, "size gid %d\n", sizeof(buf.st_gid));
    
    614
    +    fprintf(stderr, "size rdev %d\n", sizeof(buf.st_rdev));
    
    615
    +    fprintf(stderr, "size size %d\n", sizeof(buf.st_size));
    
    616
    +    fprintf(stderr, "size atime %d\n", sizeof(buf.st_atime));
    
    617
    +    fprintf(stderr, "size mtime %d\n", sizeof(buf.st_mtime));
    
    618
    +    fprintf(stderr, "size ctime %d\n", sizeof(buf.st_ctime));
    
    619
    +    fprintf(stderr, "size blksize %d\n", sizeof(buf.st_blksize));
    
    620
    +    fprintf(stderr, "size blocks %d\n", sizeof(buf.st_blocks));
    
    621
    +    
    
    622
    +    *dev = buf.st_dev;
    
    623
    +    *ino = buf.st_ino;
    
    624
    +    *mode = buf.st_mode;
    
    625
    +    *nlink = buf.st_nlink;
    
    626
    +    *uid = buf.st_uid;
    
    627
    +    *gid = buf.st_gid;
    
    628
    +    *rdev = buf.st_rdev;
    
    629
    +    *size = buf.st_size;
    
    630
    +    *atime = buf.st_atime;
    
    631
    +    *mtime = buf.st_mtime;
    
    632
    +    *ctime = buf.st_ctime;
    
    633
    +    *blksize = buf.st_blksize;
    
    634
    +    *blocks = buf.st_blocks;
    
    635
    +
    
    636
    +    return rc;
    
    637
    +}
    
    638
    +
    
    639
    +int unix_fstat(int fd, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
    
    640
    +               uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
    
    641
    +               time_t *atime, time_t *mtime, time_t *ctime,
    
    642
    +               long *blksize, off_t *blocks)
    
    643
    +{
    
    644
    +    int rc;
    
    645
    +    struct stat buf;
    
    646
    +
    
    647
    +    rc = fstat(fd, &buf);
    
    648
    +
    
    649
    +    *dev = buf.st_dev;
    
    650
    +    *ino = buf.st_ino;
    
    651
    +    *mode = buf.st_mode;
    
    652
    +    *nlink = buf.st_nlink;
    
    653
    +    *uid = buf.st_uid;
    
    654
    +    *gid = buf.st_gid;
    
    655
    +    *rdev = buf.st_rdev;
    
    656
    +    *size = buf.st_size;
    
    657
    +    *atime = buf.st_atime;
    
    658
    +    *mtime = buf.st_mtime;
    
    659
    +    *ctime = buf.st_ctime;
    
    660
    +    *blksize = buf.st_blksize;
    
    661
    +    *blocks = buf.st_blocks;
    
    662
    +
    
    663
    +    return rc;
    
    664
    +}
    
    665
    +
    
    666
    +int unix_lstat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
    
    667
    +               uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
    
    668
    +               time_t *atime, time_t *mtime, time_t *ctime,
    
    669
    +               long *blksize, off_t *blocks)
    
    670
    +{
    
    671
    +    int rc;
    
    672
    +    struct stat buf;
    
    673
    +
    
    674
    +    rc = lstat(path, &buf);
    
    675
    +
    
    676
    +    *dev = buf.st_dev;
    
    677
    +    *ino = buf.st_ino;
    
    678
    +    *mode = buf.st_mode;
    
    679
    +    *nlink = buf.st_nlink;
    
    680
    +    *uid = buf.st_uid;
    
    681
    +    *gid = buf.st_gid;
    
    682
    +    *rdev = buf.st_rdev;
    
    683
    +    *size = buf.st_size;
    
    684
    +    *atime = buf.st_atime;
    
    685
    +    *mtime = buf.st_mtime;
    
    686
    +    *ctime = buf.st_ctime;
    
    687
    +    *blksize = buf.st_blksize;
    
    688
    +    *blocks = buf.st_blocks;
    
    689
    +
    
    690
    +    return rc;
    
    691
    +}

  • src/lisp/unix.c deleted
    1
    -/*
    
    2
    - * C interfaces to unix syscalls
    
    3
    - */
    
    4
    -
    
    5
    -/* We want to support large files */
    
    6
    -
    
    7
    -#define _LARGEFILE_SOURCE
    
    8
    -#define _FILE_OFFSET_BITS 64
    
    9
    -
    
    10
    -#include <stdio.h>
    
    11
    -#include <sys/stat.h>
    
    12
    -
    
    13
    -int unix_stat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
    
    14
    -              uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
    
    15
    -              time_t *atime, time_t *mtime, time_t *ctime,
    
    16
    -              long *blksize, off_t *blocks)
    
    17
    -{
    
    18
    -    int rc;
    
    19
    -    struct stat buf;
    
    20
    -
    
    21
    -    rc = stat(path, &buf);
    
    22
    -
    
    23
    -    fprintf(stderr, "size dev %d\n", sizeof(buf.st_dev));
    
    24
    -    fprintf(stderr, "size ino %d\n", sizeof(buf.st_ino));
    
    25
    -    fprintf(stderr, "size mode %d\n", sizeof(buf.st_mode));
    
    26
    -    fprintf(stderr, "size nlink %d\n", sizeof(buf.st_nlink));
    
    27
    -    fprintf(stderr, "size uid %d\n", sizeof(buf.st_uid));
    
    28
    -    fprintf(stderr, "size gid %d\n", sizeof(buf.st_gid));
    
    29
    -    fprintf(stderr, "size rdev %d\n", sizeof(buf.st_rdev));
    
    30
    -    fprintf(stderr, "size size %d\n", sizeof(buf.st_size));
    
    31
    -    fprintf(stderr, "size atime %d\n", sizeof(buf.st_atime));
    
    32
    -    fprintf(stderr, "size mtime %d\n", sizeof(buf.st_mtime));
    
    33
    -    fprintf(stderr, "size ctime %d\n", sizeof(buf.st_ctime));
    
    34
    -    fprintf(stderr, "size blksize %d\n", sizeof(buf.st_blksize));
    
    35
    -    fprintf(stderr, "size blocks %d\n", sizeof(buf.st_blocks));
    
    36
    -    
    
    37
    -    
    
    38
    -    *dev = buf.st_dev;
    
    39
    -    *ino = buf.st_ino;
    
    40
    -    *mode = buf.st_mode;
    
    41
    -    *nlink = buf.st_nlink;
    
    42
    -    *uid = buf.st_uid;
    
    43
    -    *gid = buf.st_gid;
    
    44
    -    *rdev = buf.st_rdev;
    
    45
    -    *size = buf.st_size;
    
    46
    -    *atime = buf.st_atime;
    
    47
    -    *mtime = buf.st_mtime;
    
    48
    -    *ctime = buf.st_ctime;
    
    49
    -    *blksize = buf.st_blksize;
    
    50
    -    *blocks = buf.st_blocks;
    
    51
    -
    
    52
    -    return rc;
    
    53
    -}
    
    54
    -
    
    55
    -int unix_fstat(int fd, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
    
    56
    -               uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
    
    57
    -               time_t *atime, time_t *mtime, time_t *ctime,
    
    58
    -               long *blksize, off_t *blocks)
    
    59
    -{
    
    60
    -    int rc;
    
    61
    -    struct stat buf;
    
    62
    -
    
    63
    -    rc = fstat(fd, &buf);
    
    64
    -
    
    65
    -    *dev = buf.st_dev;
    
    66
    -    *ino = buf.st_ino;
    
    67
    -    *mode = buf.st_mode;
    
    68
    -    *nlink = buf.st_nlink;
    
    69
    -    *uid = buf.st_uid;
    
    70
    -    *gid = buf.st_gid;
    
    71
    -    *rdev = buf.st_rdev;
    
    72
    -    *size = buf.st_size;
    
    73
    -    *atime = buf.st_atime;
    
    74
    -    *mtime = buf.st_mtime;
    
    75
    -    *ctime = buf.st_ctime;
    
    76
    -    *blksize = buf.st_blksize;
    
    77
    -    *blocks = buf.st_blocks;
    
    78
    -
    
    79
    -    return rc;
    
    80
    -}
    
    81
    -
    
    82
    -int unix_lstat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
    
    83
    -               uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
    
    84
    -               time_t *atime, time_t *mtime, time_t *ctime,
    
    85
    -               long *blksize, off_t *blocks)
    
    86
    -{
    
    87
    -    int rc;
    
    88
    -    struct stat buf;
    
    89
    -
    
    90
    -    rc = lstat(path, &buf);
    
    91
    -
    
    92
    -    *dev = buf.st_dev;
    
    93
    -    *ino = buf.st_ino;
    
    94
    -    *mode = buf.st_mode;
    
    95
    -    *nlink = buf.st_nlink;
    
    96
    -    *uid = buf.st_uid;
    
    97
    -    *gid = buf.st_gid;
    
    98
    -    *rdev = buf.st_rdev;
    
    99
    -    *size = buf.st_size;
    
    100
    -    *atime = buf.st_atime;
    
    101
    -    *mtime = buf.st_mtime;
    
    102
    -    *ctime = buf.st_ctime;
    
    103
    -    *blksize = buf.st_blksize;
    
    104
    -    *blocks = buf.st_blocks;
    
    105
    -
    
    106
    -    return rc;
    
    107
    -}
    
    108
    -    
    
    109
    -    
    
    110
    -