chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Full fstat?


From: John Cowan
Subject: Re: [Chicken-users] Full fstat?
Date: Sun, 14 Jan 2007 16:57:42 -0500
User-agent: Mutt/1.3.28i

Kon Lovett scripsit:

> >I've now tested this and yeah, no dev number for me.  :-(
> 
> But inode is returned.

Inode by itself is fairly useless, though, whereas dev and inode jointly
return a unique binary ID for each file.  (You get funny answers on
Cygwin, though.)

I think the posix unit should be changed, Felix.  This is a patch to make
file-stat return a 13-element vector, where the last four elements are
st_dev, st_rdev, st_blksize, and st_blocks.  Other systems may have other
elements, but these four are present in Posix; st_dev and st_rdev date
right back to 7th Edition times, and st_blksize and st_blocks to 4.1BSD.
Unless someone actually checks the returned length, this will be entirely
backward-compatible.


--- posixunix.scm.orig  2007-01-14 15:28:37.447504000 -0500
+++ posixunix.scm       2007-01-14 16:22:34.866176000 -0500
@@ -631,6 +631,10 @@
 (define-foreign-variable _stat_st_ctime double "C_statbuf.st_ctime")
 (define-foreign-variable _stat_st_uid unsigned-int "C_statbuf.st_uid")
 (define-foreign-variable _stat_st_mode unsigned-int "C_statbuf.st_mode")
+(define-foreign-variable _stat_st_dev unsigned-int "C_statbuf.st_dev")
+(define-foreign-variable _stat_st_rdev unsigned-int "C_statbuf.st_rdev")
+(define-foreign-variable _stat_st_blksize unsigned-int "C_statbuf.st_blksize")
+(define-foreign-variable _stat_st_blocks unsigned-int "C_statbuf.st_rdev")
 
 (define (##sys#stat file link loc)
   (let ([r (cond [(fixnum? file) (##core#inline "C_fstat" file)]
@@ -651,7 +655,9 @@
   (##sys#stat f (:optional link #f) 'file-stat)
   (vector _stat_st_ino _stat_st_mode _stat_st_nlink
           _stat_st_uid _stat_st_gid _stat_st_size
-          _stat_st_atime _stat_st_ctime _stat_st_mtime) )
+          _stat_st_atime _stat_st_ctime _stat_st_mtime
+          _stat_st_dev _stat_st_rdev
+          _stat_st_blksize _stat_st_blocks) )
 
 (define (file-size f) (##sys#stat f #f 'file-size) _stat_st_size)
 (define (file-modification-time f) (##sys#stat f #f 'file-modification-time) 
_stat_st_mtime)


-- 
John Cowan    address@hidden    http://ccil.org/~cowan
Objective consideration of contemporary phenomena compel the conclusion
that optimum or inadequate performance in the trend of competitive
activities exhibits no tendency to be commensurate with innate capacity,
but that a considerable element of the unpredictable must invariably be
taken into account. --Ecclesiastes 9:11, Orwell/Brown version




reply via email to

[Prev in Thread] Current Thread [Next in Thread]