Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
-
171ca28b
by Raymond Toy at 2022-08-23T23:01:04+00:00
-
2dfc9ff1
by Raymond Toy at 2022-08-23T23:01:09+00:00
7 changed files:
- src/code/unix.lisp
- src/contrib/unix/unix-glibc2.lisp
- src/contrib/unix/unix.lisp
- src/i18n/locale/cmucl-unix.pot
- src/lisp/Config.x86_linux
- src/lisp/Config.x86_linux_clang
- src/lisp/os-common.c
Changes:
... | ... | @@ -53,12 +53,9 @@ |
53 | 53 | (def-alien-type u-int32-t unsigned-int)
|
54 | 54 | |
55 | 55 | (def-alien-type ino-t
|
56 | - #+netbsd u-int64-t
|
|
56 | + #+(or netbsd linux darwin) u-int64-t
|
|
57 | 57 | #+alpha unsigned-int
|
58 | - #-(or alpha netbsd) unsigned-long)
|
|
59 | - |
|
60 | -#+linux
|
|
61 | -(def-alien-type ino64-t u-int64-t)
|
|
58 | + #-(or alpha netbsd linux darwin) unsigned-long)
|
|
62 | 59 | |
63 | 60 | (def-alien-type size-t
|
64 | 61 | #-(or linux alpha) long
|
... | ... | @@ -72,14 +69,6 @@ |
72 | 69 | #+(and bsd netbsd) int64-t
|
73 | 70 | #+alpha unsigned-int)
|
74 | 71 | |
75 | -(def-alien-type dev-t
|
|
76 | - #-(or alpha svr4 bsd linux) short
|
|
77 | - #+(and linux (not amd64)) uquad-t
|
|
78 | - #+(and linux amd64) u-int64-t
|
|
79 | - #+netbsd u-int64-t
|
|
80 | - #+alpha int
|
|
81 | - #+(and (not linux) (not netbsd) (or bsd svr4)) unsigned-long)
|
|
82 | - |
|
83 | 72 | #-BSD
|
84 | 73 | (progn
|
85 | 74 | (deftype file-offset () '(signed-byte 32))
|
... | ... | @@ -131,13 +120,6 @@ |
131 | 120 | `(multiple-value-bind (,word ,bit) (floor ,offset 32)
|
132 | 121 | (logbitp ,bit (deref (slot ,fd-set 'fds-bits) ,word)))))
|
133 | 122 | |
134 | -(def-alien-type nlink-t
|
|
135 | - #-(or svr4 netbsd linux) unsigned-short
|
|
136 | - #+netbsd unsigned-long
|
|
137 | - #+svr4 unsigned-long
|
|
138 | - #+(and linux (not amd64)) unsigned-int
|
|
139 | - #+(and linux amd64) u-int64-t)
|
|
140 | - |
|
141 | 123 | (defconstant fd-setsize
|
142 | 124 | #-(or hpux alpha linux FreeBSD) 256
|
143 | 125 | #+hpux 2048 #+alpha 4096 #+(or linux FreeBSD) 1024)
|
... | ... | @@ -1301,7 +1283,7 @@ |
1301 | 1283 | #+glibc2.1
|
1302 | 1284 | (d-ino ino-t) ; inode number of entry
|
1303 | 1285 | #-glibc2.1
|
1304 | - (d-ino ino64-t) ; inode number of entry
|
|
1286 | + (d-ino ino-t) ; inode number of entry
|
|
1305 | 1287 | (d-off off-t) ; offset of next disk directory entry
|
1306 | 1288 | (d-reclen unsigned-short) ; length of this record
|
1307 | 1289 | (d_type unsigned-char)
|
... | ... | @@ -1347,261 +1329,143 @@ |
1347 | 1329 | (d-name (array char 256)))) ; name must be no longer than this
|
1348 | 1330 | |
1349 | 1331 | |
1350 | -#+(and bsd (not netbsd))
|
|
1351 | -(def-alien-type nil
|
|
1352 | - (struct stat
|
|
1353 | - (st-dev dev-t)
|
|
1354 | - (st-ino ino-t)
|
|
1355 | - (st-mode mode-t)
|
|
1356 | - (st-nlink nlink-t)
|
|
1357 | - (st-uid uid-t)
|
|
1358 | - (st-gid gid-t)
|
|
1359 | - (st-rdev dev-t)
|
|
1360 | - (st-atime (struct timespec-t))
|
|
1361 | - (st-mtime (struct timespec-t))
|
|
1362 | - (st-ctime (struct timespec-t))
|
|
1363 | - (st-size off-t)
|
|
1364 | - (st-blocks off-t)
|
|
1365 | - (st-blksize unsigned-long)
|
|
1366 | - (st-flags unsigned-long)
|
|
1367 | - (st-gen unsigned-long)
|
|
1368 | - (st-lspare long)
|
|
1369 | - (st-qspare (array long 4))))
|
|
1370 | - |
|
1371 | -#+svr4
|
|
1372 | -(def-alien-type nil
|
|
1373 | - (struct stat
|
|
1374 | - (st-dev dev-t)
|
|
1375 | - (st-pad1 #-linux (array long 3) #+linux unsigned-short)
|
|
1376 | - (st-ino ino-t)
|
|
1377 | - (st-mode #-linux unsigned-long #+linux unsigned-short)
|
|
1378 | - (st-nlink #-linux short #+linux unsigned-short)
|
|
1379 | - (st-uid #-linux uid-t #+linux unsigned-short)
|
|
1380 | - (st-gid #-linux gid-t #+linux unsigned-short)
|
|
1381 | - (st-rdev dev-t)
|
|
1382 | - (st-pad2 #-linux (array long 2) #+linux unsigned-short)
|
|
1383 | - (st-size off-t)
|
|
1384 | - #-linux (st-pad3 long)
|
|
1385 | - #+linux (st-blksize unsigned-long)
|
|
1386 | - #+linux (st-blocks unsigned-long)
|
|
1387 | - #-linux (st-atime (struct timestruc-t))
|
|
1388 | - #+linux (st-atime unsigned-long)
|
|
1389 | - #+linux (unused-1 unsigned-long)
|
|
1390 | - #-linux (st-mtime (struct timestruc-t))
|
|
1391 | - #+linux (st-mtime unsigned-long)
|
|
1392 | - #+linux (unused-2 unsigned-long)
|
|
1393 | - #-linux (st-ctime (struct timestruc-t))
|
|
1394 | - #+linux (st-ctime unsigned-long)
|
|
1395 | - #+linux (unused-3 unsigned-long)
|
|
1396 | - #+linux (unused-4 unsigned-long)
|
|
1397 | - #+linux (unused-5 unsigned-long)
|
|
1398 | - #-linux(st-blksize long)
|
|
1399 | - #-linux (st-blocks long)
|
|
1400 | - #-linux (st-fstype (array char 16))
|
|
1401 | - #-linux (st-pad4 (array long 8))))
|
|
1402 | - |
|
1403 | -#+linux
|
|
1404 | -(def-alien-type nil
|
|
1405 | - (struct stat
|
|
1406 | - (st-dev dev-t)
|
|
1407 | - #-(or alpha amd64) (st-pad1 unsigned-short)
|
|
1408 | - (st-ino ino-t)
|
|
1409 | - #+alpha (st-pad1 unsigned-int)
|
|
1410 | - #-amd64 (st-mode mode-t)
|
|
1411 | - (st-nlink nlink-t)
|
|
1412 | - #+amd64 (st-mode mode-t)
|
|
1413 | - (st-uid uid-t)
|
|
1414 | - (st-gid gid-t)
|
|
1415 | - (st-rdev dev-t)
|
|
1416 | - #-alpha (st-pad2 unsigned-short)
|
|
1417 | - (st-size off-t)
|
|
1418 | - #-alpha (st-blksize unsigned-long)
|
|
1419 | - #-alpha (st-blocks blkcnt-t)
|
|
1420 | - (st-atime time-t)
|
|
1421 | - #-alpha (unused-1 unsigned-long)
|
|
1422 | - (st-mtime time-t)
|
|
1423 | - #-alpha (unused-2 unsigned-long)
|
|
1424 | - (st-ctime time-t)
|
|
1425 | - #+alpha (st-blocks int)
|
|
1426 | - #+alpha (st-pad2 unsigned-int)
|
|
1427 | - #+alpha (st-blksize unsigned-int)
|
|
1428 | - #+alpha (st-flags unsigned-int)
|
|
1429 | - #+alpha (st-gen unsigned-int)
|
|
1430 | - #+alpha (st-pad3 unsigned-int)
|
|
1431 | - #+alpha (unused-1 unsigned-long)
|
|
1432 | - #+alpha (unused-2 unsigned-long)
|
|
1433 | - (unused-3 unsigned-long)
|
|
1434 | - (unused-4 unsigned-long)
|
|
1435 | - #-alpha (unused-5 unsigned-long)))
|
|
1436 | - |
|
1437 | -;;; 64-bit stat for Solaris
|
|
1438 | -#+solaris
|
|
1439 | -(def-alien-type nil
|
|
1440 | - (struct stat64
|
|
1441 | - (st-dev dev-t)
|
|
1442 | - (st-pad1 (array long 3)) ; Pad so ino is 64-bit aligned
|
|
1443 | - (st-ino ino64-t)
|
|
1444 | - (st-mode unsigned-long)
|
|
1445 | - (st-nlink short)
|
|
1446 | - (st-uid uid-t)
|
|
1447 | - (st-gid gid-t)
|
|
1448 | - (st-rdev dev-t)
|
|
1449 | - (st-pad2 (array long 3)) ; Pad so size is 64-bit aligned
|
|
1450 | - (st-size off64-t)
|
|
1451 | - (st-atime (struct timestruc-t))
|
|
1452 | - (st-mtime (struct timestruc-t))
|
|
1453 | - (st-ctime (struct timestruc-t))
|
|
1454 | - (st-blksize long)
|
|
1455 | - (st-pad3 (array long 1)) ; Pad so blocks is 64-bit aligned
|
|
1456 | - (st-blocks blkcnt64-t)
|
|
1457 | - (st-fstype (array char 16))
|
|
1458 | - (st-pad4 (array long 8))))
|
|
1459 | - |
|
1460 | -#+netbsd
|
|
1461 | -(def-alien-type nil
|
|
1462 | - (struct stat
|
|
1463 | - (st-dev dev-t)
|
|
1464 | - (st-mode mode-t)
|
|
1465 | - (st-ino ino-t)
|
|
1466 | - (st-nlink nlink-t)
|
|
1467 | - (st-uid uid-t)
|
|
1468 | - (st-gid gid-t)
|
|
1469 | - (st-rdev dev-t)
|
|
1470 | - (st-atime (struct timespec-t))
|
|
1471 | - (st-mtime (struct timespec-t))
|
|
1472 | - (st-ctime (struct timespec-t))
|
|
1473 | - (st-birthtime (struct timespec-t))
|
|
1474 | - (st-size off-t)
|
|
1475 | - (st-blocks off-t)
|
|
1476 | - (st-blksize long)
|
|
1477 | - (st-flags unsigned-long)
|
|
1478 | - (st-gen unsigned-long)
|
|
1479 | - (st-spare (array unsigned-long 2))))
|
|
1480 | - |
|
1481 | -#-linux
|
|
1482 | -(defmacro extract-stat-results (buf)
|
|
1483 | - `(values T
|
|
1484 | - (slot ,buf 'st-dev)
|
|
1485 | - (slot ,buf 'st-ino)
|
|
1486 | - (slot ,buf 'st-mode)
|
|
1487 | - (slot ,buf 'st-nlink)
|
|
1488 | - (slot ,buf 'st-uid)
|
|
1489 | - (slot ,buf 'st-gid)
|
|
1490 | - (slot ,buf 'st-rdev)
|
|
1491 | - (slot ,buf 'st-size)
|
|
1492 | - #-(or svr4 BSD) (slot ,buf 'st-atime)
|
|
1493 | - #+svr4 (slot (slot ,buf 'st-atime) 'tv-sec)
|
|
1494 | - #+BSD (slot (slot ,buf 'st-atime) 'ts-sec)
|
|
1495 | - #-(or svr4 BSD)(slot ,buf 'st-mtime)
|
|
1496 | - #+svr4 (slot (slot ,buf 'st-mtime) 'tv-sec)
|
|
1497 | - #+BSD(slot (slot ,buf 'st-mtime) 'ts-sec)
|
|
1498 | - #-(or svr4 BSD) (slot ,buf 'st-ctime)
|
|
1499 | - #+svr4 (slot (slot ,buf 'st-ctime) 'tv-sec)
|
|
1500 | - #+BSD(slot (slot ,buf 'st-ctime) 'ts-sec)
|
|
1501 | - #+netbsd (slot (slot ,buf 'st-birthtime) 'ts-sec)
|
|
1502 | - (slot ,buf 'st-blksize)
|
|
1503 | - (slot ,buf 'st-blocks)))
|
|
1504 | - |
|
1505 | -#+linux
|
|
1506 | -(defmacro extract-stat-results (buf)
|
|
1507 | - `(values T
|
|
1508 | - #+(or alpha amd64)
|
|
1509 | - (slot ,buf 'st-dev)
|
|
1510 | - #-(or alpha amd64)
|
|
1511 | - (+ (deref (slot ,buf 'st-dev) 0)
|
|
1512 | - (* (+ +max-u-long+ 1)
|
|
1513 | - (deref (slot ,buf 'st-dev) 1))) ;;; let's hope this works..
|
|
1514 | - (slot ,buf 'st-ino)
|
|
1515 | - (slot ,buf 'st-mode)
|
|
1516 | - (slot ,buf 'st-nlink)
|
|
1517 | - (slot ,buf 'st-uid)
|
|
1518 | - (slot ,buf 'st-gid)
|
|
1519 | - #+(or alpha amd64)
|
|
1520 | - (slot ,buf 'st-rdev)
|
|
1521 | - #-(or alpha amd64)
|
|
1522 | - (+ (deref (slot ,buf 'st-rdev) 0)
|
|
1523 | - (* (+ +max-u-long+ 1)
|
|
1524 | - (deref (slot ,buf 'st-rdev) 1))) ;;; let's hope this works..
|
|
1525 | - (slot ,buf 'st-size)
|
|
1526 | - (slot ,buf 'st-atime)
|
|
1527 | - (slot ,buf 'st-mtime)
|
|
1528 | - (slot ,buf 'st-ctime)
|
|
1529 | - (slot ,buf 'st-blksize)
|
|
1530 | - (slot ,buf 'st-blocks)))
|
|
1531 | - |
|
1532 | -#-solaris
|
|
1533 | -(progn
|
|
1534 | -(defun unix-stat (name)
|
|
1535 | - _N"Unix-stat retrieves information about the specified
|
|
1536 | - file returning them in the form of multiple values.
|
|
1537 | - See the UNIX Programmer's Manual for a description
|
|
1538 | - of the values returned. If the call fails, then NIL
|
|
1539 | - and an error number is returned instead."
|
|
1540 | - (declare (type unix-pathname name))
|
|
1541 | - (when (string= name "")
|
|
1542 | - (setf name "."))
|
|
1543 | - (with-alien ((buf (struct stat)))
|
|
1544 | - (syscall (#+linux "stat64" #+netbsd "__stat50" #-(or linux netbsd) "stat"
|
|
1545 | - c-string (* (struct stat)))
|
|
1546 | - (extract-stat-results buf)
|
|
1547 | - (%name->file name) (addr buf))))
|
|
1548 | - |
|
1549 | -(defun unix-lstat (name)
|
|
1550 | - _N"Unix-lstat is similar to unix-stat except the specified
|
|
1551 | - file must be a symbolic link."
|
|
1552 | - (declare (type unix-pathname name))
|
|
1553 | - (with-alien ((buf (struct stat)))
|
|
1554 | - (syscall (#+linux "lstat64" #+netbsd "__lstat50" #-(or linux netbsd) "lstat"
|
|
1555 | - c-string (* (struct stat)))
|
|
1556 | - (extract-stat-results buf)
|
|
1557 | - (%name->file name) (addr buf))))
|
|
1558 | - |
|
1559 | -(defun unix-fstat (fd)
|
|
1560 | - _N"Unix-fstat is similar to unix-stat except the file is specified
|
|
1561 | - by the file descriptor fd."
|
|
1562 | - (declare (type unix-fd fd))
|
|
1563 | - (with-alien ((buf (struct stat)))
|
|
1564 | - (syscall (#+linux "fstat64" #+netbsd "__fstat50" #-(or linux netbsd) "fstat"
|
|
1565 | - int (* (struct stat)))
|
|
1566 | - (extract-stat-results buf)
|
|
1567 | - fd (addr buf))))
|
|
1568 | -)
|
|
1569 | - |
|
1570 | -;;; 64-bit versions of stat and friends
|
|
1571 | -#+solaris
|
|
1572 | -(progn
|
|
1573 | -(defun unix-stat (name)
|
|
1574 | - _N"Unix-stat retrieves information about the specified
|
|
1575 | - file returning them in the form of multiple values.
|
|
1576 | - See the UNIX Programmer's Manual for a description
|
|
1577 | - of the values returned. If the call fails, then NIL
|
|
1578 | - and an error number is returned instead."
|
|
1579 | - (declare (type unix-pathname name))
|
|
1580 | - (when (string= name "")
|
|
1581 | - (setf name "."))
|
|
1582 | - (with-alien ((buf (struct stat64)))
|
|
1583 | - (syscall ("stat64" c-string (* (struct stat64)))
|
|
1584 | - (extract-stat-results buf)
|
|
1585 | - (%name->file name) (addr buf))))
|
|
1586 | - |
|
1587 | -(defun unix-lstat (name)
|
|
1588 | - _N"Unix-lstat is similar to unix-stat except the specified
|
|
1589 | - file must be a symbolic link."
|
|
1590 | - (declare (type unix-pathname name))
|
|
1591 | - (with-alien ((buf (struct stat64)))
|
|
1592 | - (syscall ("lstat64" c-string (* (struct stat64)))
|
|
1593 | - (extract-stat-results buf)
|
|
1594 | - (%name->file name) (addr buf))))
|
|
1595 | - |
|
1596 | -(defun unix-fstat (fd)
|
|
1597 | - _N"Unix-fstat is similar to unix-stat except the file is specified
|
|
1598 | - by the file descriptor fd."
|
|
1599 | - (declare (type unix-fd fd))
|
|
1600 | - (with-alien ((buf (struct stat64)))
|
|
1601 | - (syscall ("fstat64" int (* (struct stat64)))
|
|
1602 | - (extract-stat-results buf)
|
|
1603 | - fd (addr buf))))
|
|
1604 | -)
|
|
1332 | +;; unix-stat and friends
|
|
1333 | +(macrolet
|
|
1334 | + ((call-stat (c-func-name first-arg-type first-arg)
|
|
1335 | + ;; Call the stat function named C-FUNC-NAME. The type of the
|
|
1336 | + ;; first arg is FIRST-ARG-TYPE and FIRST-ARG is the first arg
|
|
1337 | + ;; to the stat function. fstat is different from stat and
|
|
1338 | + ;; lstat since it takes an fd for the first arg instead of
|
|
1339 | + ;; string.
|
|
1340 | + `(with-alien ((dev c-call:long-long)
|
|
1341 | + (ino c-call:unsigned-long-long)
|
|
1342 | + (mode c-call:unsigned-int)
|
|
1343 | + (nlink c-call:unsigned-long-long)
|
|
1344 | + (uid c-call:unsigned-int)
|
|
1345 | + (gid c-call:unsigned-int)
|
|
1346 | + (rdev c-call:unsigned-long-long)
|
|
1347 | + (size c-call:long-long)
|
|
1348 | + (atime c-call:long-long)
|
|
1349 | + (mtime c-call:long-long)
|
|
1350 | + (ctime c-call:long-long)
|
|
1351 | + (blksize c-call:long)
|
|
1352 | + (blocks c-call:long-long))
|
|
1353 | + (let ((result
|
|
1354 | + (alien-funcall
|
|
1355 | + (extern-alien ,c-func-name
|
|
1356 | + (function int
|
|
1357 | + ,first-arg-type
|
|
1358 | + (* c-call:long-long)
|
|
1359 | + (* c-call:unsigned-long-long)
|
|
1360 | + (* c-call:unsigned-int)
|
|
1361 | + (* c-call:unsigned-long-long)
|
|
1362 | + (* c-call:unsigned-int)
|
|
1363 | + (* c-call:unsigned-int)
|
|
1364 | + (* c-call:unsigned-long-long)
|
|
1365 | + (* c-call:long-long)
|
|
1366 | + (* c-call:long-long)
|
|
1367 | + (* c-call:long-long)
|
|
1368 | + (* c-call:long-long)
|
|
1369 | + (* c-call:long)
|
|
1370 | + (* c-call:long-long)))
|
|
1371 | + ,first-arg
|
|
1372 | + (addr dev)
|
|
1373 | + (addr ino)
|
|
1374 | + (addr mode)
|
|
1375 | + (addr nlink)
|
|
1376 | + (addr uid)
|
|
1377 | + (addr gid)
|
|
1378 | + (addr rdev)
|
|
1379 | + (addr size)
|
|
1380 | + (addr atime)
|
|
1381 | + (addr mtime)
|
|
1382 | + (addr ctime)
|
|
1383 | + (addr blksize)
|
|
1384 | + (addr blocks))))
|
|
1385 | + (if (eql -1 result)
|
|
1386 | + (values nil (unix-errno))
|
|
1387 | + (values t
|
|
1388 | + dev
|
|
1389 | + ino
|
|
1390 | + mode
|
|
1391 | + nlink
|
|
1392 | + uid
|
|
1393 | + gid
|
|
1394 | + rdev
|
|
1395 | + size
|
|
1396 | + atime
|
|
1397 | + mtime
|
|
1398 | + ctime
|
|
1399 | + blksize
|
|
1400 | + blocks))))))
|
|
1401 | + (defun unix-stat (name)
|
|
1402 | + _N"Unix-stat retrieves information about the specified
|
|
1403 | + file returning them in the form of multiple values. If the call
|
|
1404 | + fails, then NIL and an error number is returned. If the call
|
|
1405 | + succeeds, then T is returned in addition to the following values
|
|
1406 | + from the stat struct st:
|
|
1407 | + |
|
1408 | + st_dev Device ID
|
|
1409 | + st_ino File serial number
|
|
1410 | + st_mode Mode of file
|
|
1411 | + st_nlink Number of hard links to the file
|
|
1412 | + st_uid User ID
|
|
1413 | + st_gid Group ID
|
|
1414 | + st_rdev Device ID (if file is character or block special)
|
|
1415 | + st_atime Last data access time, in sec
|
|
1416 | + st_mtime Last data modification time, in sec
|
|
1417 | + st_ctime Last file status change time, in sec
|
|
1418 | + st_blksize Preferred I/O block size
|
|
1419 | + st_blocks Number of blocks allocated. (Block size is implementation dependent.)
|
|
1420 | +"
|
|
1421 | + (declare (type unix-pathname name))
|
|
1422 | + (when (string= name "")
|
|
1423 | + (setf name "."))
|
|
1424 | + (call-stat "os_stat" c-call:c-string (%name->file name)))
|
|
1425 | + |
|
1426 | + (defun unix-lstat (name)
|
|
1427 | + "Unix-lstat is similar to unix-stat except the specified
|
|
1428 | + file must be a symbolic link. If the call fails, then NIL and an
|
|
1429 | + error number is returned. If the call succeeds, then T is returned
|
|
1430 | + in addition to the following values from the stat struct st:
|
|
1431 | + |
|
1432 | + st_dev Device ID
|
|
1433 | + st_ino File serial number
|
|
1434 | + st_mode Mode of file
|
|
1435 | + st_nlink Number of hard links to the file
|
|
1436 | + st_uid User ID
|
|
1437 | + st_gid Group ID
|
|
1438 | + st_rdev Device ID (if file is character or block special)
|
|
1439 | + st_atime Last data access time, in sec
|
|
1440 | + st_mtime Last data modification time, in sec
|
|
1441 | + st_ctime Last file status change time, in sec
|
|
1442 | + st_blksize Preferred I/O block size
|
|
1443 | + st_blocks Number of blocks allocated. (Block size is implementation dependent.)
|
|
1444 | +"
|
|
1445 | + (declare (type unix-pathname name))
|
|
1446 | + (call-stat "os_lstat" c-call:c-string (%name->file name)))
|
|
1447 | + |
|
1448 | + (defun unix-fstat (fd)
|
|
1449 | + _N"Unix-fstat is similar to unix-stat except the file is specified
|
|
1450 | + by the file descriptor fd. If the call fails, then NIL and an
|
|
1451 | + error number is returned. If the call succeeds, then T is returned
|
|
1452 | + in addition to the following values from the stat struct st:
|
|
1453 | + |
|
1454 | + st_dev Device ID
|
|
1455 | + st_ino File serial number
|
|
1456 | + st_mode Mode of file
|
|
1457 | + st_nlink Number of hard links to the file
|
|
1458 | + st_uid User ID
|
|
1459 | + st_gid Group ID
|
|
1460 | + st_rdev Device ID (if file is character or block special)
|
|
1461 | + st_atime Last data access time, in sec
|
|
1462 | + st_mtime Last data modification time, in sec
|
|
1463 | + st_ctime Last file status change time, in sec
|
|
1464 | + st_blksize Preferred I/O block size
|
|
1465 | + st_blocks Number of blocks allocated. (Block size is implementation dependent.)
|
|
1466 | +"
|
|
1467 | + (declare (type unix-fd fd))
|
|
1468 | + (call-stat "os_fstat" int fd)))
|
|
1605 | 1469 | |
1606 | 1470 | (def-alien-type nil
|
1607 | 1471 | (struct rusage
|
... | ... | @@ -175,7 +175,7 @@ |
175 | 175 | TIOCSIGSEND
|
176 | 176 | |
177 | 177 | KBDCGET KBDCSET KBDCRESET KBDCRST KBDCSSTD KBDSGET KBDGCLICK
|
178 | - KBDSCLICK FIONREAD unix-exit unix-stat unix-lstat unix-fstat
|
|
178 | + KBDSCLICK FIONREAD unix-exit
|
|
179 | 179 | unix-getrusage unix-fast-getrusage rusage_self rusage_children
|
180 | 180 | unix-gettimeofday
|
181 | 181 | unix-utimes unix-sched-yield unix-setreuid
|
... | ... | @@ -159,7 +159,7 @@ |
159 | 159 | |
160 | 160 | KBDCGET KBDCSET KBDCRESET KBDCRST KBDCSSTD KBDSGET KBDGCLICK
|
161 | 161 | KBDSCLICK FIONREAD #+(or hpux bsd) siocspgrp
|
162 | - unix-exit unix-stat unix-lstat unix-fstat
|
|
162 | + unix-exit
|
|
163 | 163 | unix-getrusage unix-fast-getrusage rusage_self rusage_children
|
164 | 164 | unix-gettimeofday
|
165 | 165 | #-hpux unix-utimes #-(or svr4 hpux) unix-setreuid
|
... | ... | @@ -230,50 +230,6 @@ |
230 | 230 | ;;;
|
231 | 231 | |
232 | 232 | |
233 | -;;; From sys/stat.h
|
|
234 | -;; oh boy, in linux-> 2 stat(s)!!
|
|
235 | - |
|
236 | -#-(or svr4 bsd linux) ; eg hpux and alpha
|
|
237 | -(def-alien-type nil
|
|
238 | - (struct stat
|
|
239 | - (st-dev dev-t)
|
|
240 | - (st-ino ino-t)
|
|
241 | - (st-mode mode-t)
|
|
242 | - (st-nlink nlink-t)
|
|
243 | - (st-uid uid-t)
|
|
244 | - (st-gid gid-t)
|
|
245 | - (st-rdev dev-t)
|
|
246 | - (st-size off-t)
|
|
247 | - (st-atime time-t)
|
|
248 | - (st-spare1 int)
|
|
249 | - (st-mtime time-t)
|
|
250 | - (st-spare2 int)
|
|
251 | - (st-ctime time-t)
|
|
252 | - (st-spare3 int)
|
|
253 | - (st-blksize #-alpha long #+alpha unsigned-int)
|
|
254 | - (st-blocks #-alpha long #+alpha int)
|
|
255 | - (st-spare4 (array long 2))))
|
|
256 | - |
|
257 | -#+netbsd
|
|
258 | -(def-alien-type nil
|
|
259 | - (struct stat
|
|
260 | - (st-dev dev-t)
|
|
261 | - (st-mode mode-t)
|
|
262 | - (st-ino ino-t)
|
|
263 | - (st-nlink nlink-t)
|
|
264 | - (st-uid uid-t)
|
|
265 | - (st-gid gid-t)
|
|
266 | - (st-rdev dev-t)
|
|
267 | - (st-atime (struct timespec-t))
|
|
268 | - (st-mtime (struct timespec-t))
|
|
269 | - (st-ctime (struct timespec-t))
|
|
270 | - (st-birthtime (struct timespec-t))
|
|
271 | - (st-size off-t)
|
|
272 | - (st-blocks off-t)
|
|
273 | - (st-blksize long)
|
|
274 | - (st-flags unsigned-long)
|
|
275 | - (st-gen unsigned-long)
|
|
276 | - (st-spare (array unsigned-long 2))))
|
|
277 | 233 | |
278 | 234 | ;;; From sys/resource.h
|
279 | 235 |
... | ... | @@ -489,22 +489,71 @@ msgstr "" |
489 | 489 | #: src/code/unix.lisp
|
490 | 490 | msgid ""
|
491 | 491 | "Unix-stat retrieves information about the specified\n"
|
492 | -" file returning them in the form of multiple values.\n"
|
|
493 | -" See the UNIX Programmer's Manual for a description\n"
|
|
494 | -" of the values returned. If the call fails, then NIL\n"
|
|
495 | -" and an error number is returned instead."
|
|
492 | +" file returning them in the form of multiple values. If the call\n"
|
|
493 | +" fails, then NIL and an error number is returned. If the call\n"
|
|
494 | +" succeeds, then T is returned in addition to the following values\n"
|
|
495 | +" from the stat struct st:\n"
|
|
496 | +"\n"
|
|
497 | +" st_dev Device ID\n"
|
|
498 | +" st_ino File serial number\n"
|
|
499 | +" st_mode Mode of file\n"
|
|
500 | +" st_nlink Number of hard links to the file\n"
|
|
501 | +" st_uid User ID\n"
|
|
502 | +" st_gid Group ID\n"
|
|
503 | +" st_rdev Device ID (if file is character or block special)\n"
|
|
504 | +" st_atime Last data access time, in sec\n"
|
|
505 | +" st_mtime Last data modification time, in sec\n"
|
|
506 | +" st_ctime Last file status change time, in sec\n"
|
|
507 | +" st_blksize Preferred I/O block size\n"
|
|
508 | +" st_blocks Number of blocks allocated. (Block size is implementation"
|
|
509 | +" dependent.)\n"
|
|
510 | +""
|
|
496 | 511 | msgstr ""
|
497 | 512 | |
498 | 513 | #: src/code/unix.lisp
|
499 | 514 | msgid ""
|
500 | -"Unix-lstat is similar to unix-stat except the specified\n"
|
|
501 | -" file must be a symbolic link."
|
|
515 | +"Unix-fstat is similar to unix-stat except the file is specified\n"
|
|
516 | +" by the file descriptor fd. If the call fails, then NIL and an\n"
|
|
517 | +" error number is returned. If the call succeeds, then T is returned\n"
|
|
518 | +" in addition to the following values from the stat struct st:\n"
|
|
519 | +"\n"
|
|
520 | +" st_dev Device ID\n"
|
|
521 | +" st_ino File serial number\n"
|
|
522 | +" st_mode Mode of file\n"
|
|
523 | +" st_nlink Number of hard links to the file\n"
|
|
524 | +" st_uid User ID\n"
|
|
525 | +" st_gid Group ID\n"
|
|
526 | +" st_rdev Device ID (if file is character or block special)\n"
|
|
527 | +" st_atime Last data access time, in sec\n"
|
|
528 | +" st_mtime Last data modification time, in sec\n"
|
|
529 | +" st_ctime Last file status change time, in sec\n"
|
|
530 | +" st_blksize Preferred I/O block size\n"
|
|
531 | +" st_blocks Number of blocks allocated. (Block size is implementation"
|
|
532 | +" dependent.)\n"
|
|
533 | +""
|
|
502 | 534 | msgstr ""
|
503 | 535 | |
504 | 536 | #: src/code/unix.lisp
|
505 | 537 | msgid ""
|
506 | -"Unix-fstat is similar to unix-stat except the file is specified\n"
|
|
507 | -" by the file descriptor fd."
|
|
538 | +"Unix-lstat is similar to unix-stat except the specified\n"
|
|
539 | +" file must be a symbolic link. If the call fails, then NIL and an\n"
|
|
540 | +" error number is returned. If the call succeeds, then T is returned\n"
|
|
541 | +" in addition to the following values from the stat struct st:\n"
|
|
542 | +"\n"
|
|
543 | +" st_dev Device ID\n"
|
|
544 | +" st_ino File serial number\n"
|
|
545 | +" st_mode Mode of file\n"
|
|
546 | +" st_nlink Number of hard links to the file\n"
|
|
547 | +" st_uid User ID\n"
|
|
548 | +" st_gid Group ID\n"
|
|
549 | +" st_rdev Device ID (if file is character or block special)\n"
|
|
550 | +" st_atime Last data access time, in sec\n"
|
|
551 | +" st_mtime Last data modification time, in sec\n"
|
|
552 | +" st_ctime Last file status change time, in sec\n"
|
|
553 | +" st_blksize Preferred I/O block size\n"
|
|
554 | +" st_blocks Number of blocks allocated. (Block size is implementation"
|
|
555 | +" dependent.)\n"
|
|
556 | +""
|
|
508 | 557 | msgstr ""
|
509 | 558 | |
510 | 559 | #: src/code/unix.lisp
|
... | ... | @@ -4,6 +4,7 @@ include Config.x86_common |
4 | 4 | CFLAGS += $(COPT)
|
5 | 5 | CPPFLAGS += -m32 -D__NO_CTYPE
|
6 | 6 | CFLAGS += -rdynamic -march=pentium4 -mfpmath=sse -mtune=generic
|
7 | +CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
|
|
7 | 8 | |
8 | 9 | UNDEFSYMPATTERN = -Xlinker -u -Xlinker &
|
9 | 10 | ASSEM_SRC += linux-stubs.S
|
... | ... | @@ -9,6 +9,7 @@ CFLAGS += $(COPT) |
9 | 9 | # (-mtune=pentium4), the first chip to have sse2; and finally generate
|
10 | 10 | # code assuming instructions can trap (-ftrapping-math).
|
11 | 11 | CFLAGS += -msse2 -mtune=pentium4 -ftrapping-math
|
12 | +CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
|
|
12 | 13 | |
13 | 14 | UNDEFSYMPATTERN = -Xlinker -u -Xlinker &
|
14 | 15 | ASSEM_SRC += linux-stubs.S
|
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | #include <netdb.h>
|
11 | 11 | #include <stdio.h>
|
12 | 12 | #include <string.h>
|
13 | +#include <sys/stat.h>
|
|
13 | 14 | #include <time.h>
|
14 | 15 | |
15 | 16 | #include "os.h"
|
... | ... | @@ -589,3 +590,128 @@ os_sleep(double seconds) |
589 | 590 | requested = remaining;
|
590 | 591 | }
|
591 | 592 | }
|
593 | +
|
|
594 | +/*
|
|
595 | + * Interface to stat/fstat/lstat.
|
|
596 | + *
|
|
597 | + * The arg types are chosen such that they can hold the largest
|
|
598 | + * possible value that any OS would use for the particular slot in the
|
|
599 | + * stat structure. That way we can just use one OS-independent
|
|
600 | + * function that works across all OSes.
|
|
601 | + */
|
|
602 | +int
|
|
603 | +os_stat(const char* path, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
|
|
604 | + unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
|
|
605 | + int64_t *atime, int64_t *mtime, int64_t *ctime,
|
|
606 | + long *blksize, int64_t *blocks)
|
|
607 | +{
|
|
608 | + int rc;
|
|
609 | + struct stat buf;
|
|
610 | + |
|
611 | + rc = stat(path, &buf);
|
|
612 | + |
|
613 | + if (rc != 0) {
|
|
614 | + return rc;
|
|
615 | + }
|
|
616 | +
|
|
617 | +#if 0
|
|
618 | + /*
|
|
619 | + * Useful prints to see the actual size of the various
|
|
620 | + * fields. Helpful for porting this to other OSes that we haven't
|
|
621 | + * tested on.
|
|
622 | + */
|
|
623 | + fprintf(stderr, "size dev %d\n", sizeof(buf.st_dev));
|
|
624 | + fprintf(stderr, "size ino %d\n", sizeof(buf.st_ino));
|
|
625 | + fprintf(stderr, "size mode %d\n", sizeof(buf.st_mode));
|
|
626 | + fprintf(stderr, "size nlink %d\n", sizeof(buf.st_nlink));
|
|
627 | + fprintf(stderr, "size uid %d\n", sizeof(buf.st_uid));
|
|
628 | + fprintf(stderr, "size gid %d\n", sizeof(buf.st_gid));
|
|
629 | + fprintf(stderr, "size rdev %d\n", sizeof(buf.st_rdev));
|
|
630 | + fprintf(stderr, "size size %d\n", sizeof(buf.st_size));
|
|
631 | + fprintf(stderr, "size atime %d\n", sizeof(buf.st_atime));
|
|
632 | + fprintf(stderr, "size mtime %d\n", sizeof(buf.st_mtime));
|
|
633 | + fprintf(stderr, "size ctime %d\n", sizeof(buf.st_ctime));
|
|
634 | + fprintf(stderr, "size blksize %d\n", sizeof(buf.st_blksize));
|
|
635 | + fprintf(stderr, "size blocks %d\n", sizeof(buf.st_blocks));
|
|
636 | +#endif
|
|
637 | +
|
|
638 | + *dev = buf.st_dev;
|
|
639 | + *ino = buf.st_ino;
|
|
640 | + *mode = buf.st_mode;
|
|
641 | + *nlink = buf.st_nlink;
|
|
642 | + *uid = buf.st_uid;
|
|
643 | + *gid = buf.st_gid;
|
|
644 | + *rdev = buf.st_rdev;
|
|
645 | + *size = buf.st_size;
|
|
646 | + *atime = buf.st_atime;
|
|
647 | + *mtime = buf.st_mtime;
|
|
648 | + *ctime = buf.st_ctime;
|
|
649 | + *blksize = buf.st_blksize;
|
|
650 | + *blocks = buf.st_blocks;
|
|
651 | + |
|
652 | + return rc;
|
|
653 | +}
|
|
654 | + |
|
655 | +int
|
|
656 | +os_fstat(int fd, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
|
|
657 | + unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
|
|
658 | + int64_t *atime, int64_t *mtime, int64_t *ctime,
|
|
659 | + long *blksize, int64_t *blocks)
|
|
660 | +{
|
|
661 | + int rc;
|
|
662 | + struct stat buf;
|
|
663 | + |
|
664 | + rc = fstat(fd, &buf);
|
|
665 | + |
|
666 | + if (rc != 0) {
|
|
667 | + return rc;
|
|
668 | + }
|
|
669 | + |
|
670 | + *dev = buf.st_dev;
|
|
671 | + *ino = buf.st_ino;
|
|
672 | + *mode = buf.st_mode;
|
|
673 | + *nlink = buf.st_nlink;
|
|
674 | + *uid = buf.st_uid;
|
|
675 | + *gid = buf.st_gid;
|
|
676 | + *rdev = buf.st_rdev;
|
|
677 | + *size = buf.st_size;
|
|
678 | + *atime = buf.st_atime;
|
|
679 | + *mtime = buf.st_mtime;
|
|
680 | + *ctime = buf.st_ctime;
|
|
681 | + *blksize = buf.st_blksize;
|
|
682 | + *blocks = buf.st_blocks;
|
|
683 | + |
|
684 | + return rc;
|
|
685 | +}
|
|
686 | + |
|
687 | +int
|
|
688 | +os_lstat(const char* path, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
|
|
689 | + unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
|
|
690 | + int64_t *atime, int64_t *mtime, int64_t *ctime,
|
|
691 | + long *blksize, int64_t *blocks)
|
|
692 | +{
|
|
693 | + int rc;
|
|
694 | + struct stat buf;
|
|
695 | + |
|
696 | + rc = lstat(path, &buf);
|
|
697 | + |
|
698 | + if (rc != 0) {
|
|
699 | + return rc;
|
|
700 | + }
|
|
701 | + |
|
702 | + *dev = buf.st_dev;
|
|
703 | + *ino = buf.st_ino;
|
|
704 | + *mode = buf.st_mode;
|
|
705 | + *nlink = buf.st_nlink;
|
|
706 | + *uid = buf.st_uid;
|
|
707 | + *gid = buf.st_gid;
|
|
708 | + *rdev = buf.st_rdev;
|
|
709 | + *size = buf.st_size;
|
|
710 | + *atime = buf.st_atime;
|
|
711 | + *mtime = buf.st_mtime;
|
|
712 | + *ctime = buf.st_ctime;
|
|
713 | + *blksize = buf.st_blksize;
|
|
714 | + *blocks = buf.st_blocks;
|
|
715 | + |
|
716 | + return rc;
|
|
717 | +} |