These functions return the following information:
inode number,
protection,
number of hard links,
user ID,
group ID,
device type,
size,
access time,
modify time,
status change time,
optimal blocksize,
blocks allocated
Both stat and lstat query by file name. fstat queries by logical unit.
The function is called by:
INTEGER*4 stat ierr = stat ( name, statb ) |
|||
name |
character*n |
Input |
Name of the file |
statb |
INTEGER*4 |
Output |
Status structure for the file, 13-element array |
Return value |
INTEGER*4 |
Output |
ierr=0: OK ierr>0: Error code |
Example 1: stat():
character name*18 /’MyFile’/ INTEGER*4 ierr, stat, lunit/1/, statb(13) open( unit=lunit, file=name ) ierr = stat ( name, statb ) if ( ierr .ne. 0 ) stop ’stat: error’ write(*,*)’UID of owner = ’,statb(5),’, 1 blocks = ’,statb(13) end |
The function
INTEGER*4 fstat ierr = fstat ( lunit, statb ) |
|||
lunit |
INTEGER*4 |
Input |
Logical unit number |
statb |
INTEGER*4 |
Output |
Status for the file: 13-element array |
Return value |
INTEGER*4 |
Output |
ierr=0: OK ierr>0: Error code |
is called by:
Example 2: fstat():
character name*18 /’MyFile’/ INTEGER*4 fstat, lunit/1/, statb(13) open( unit=lunit, file=name ) ierr = fstat ( lunit, statb ) if ( ierr .ne. 0 ) stop ’fstat: error’ write(*,*)’UID of owner = ’,statb(5),’, 1 blocks = ’,statb(13) end |
The function is called by:
ierr = lstat ( name, statb ) |
|||
name |
character*n |
Input |
File name |
statb |
INTEGER*4 |
Output |
Status array of file, 13 elements |
Return value |
INTEGER*4 |
Output |
ierr=0: OK ierr>0: Error code |
Example 3: lstat():
character name*18 /’MyFile’/ INTEGER*4 lstat, lunit/1/, statb(13) open( unit=lunit, file=name ) ierr = lstat ( name, statb ) if ( ierr .ne. 0 ) stop ’lstat: error’ write(*,*)’UID of owner = ’,statb(5),’, 1 blocks = ’,statb(13) end |
The meaning of the information returned in the INTEGER*4 array statb is as described for the structure stat under stat(2).
Spare values are not included. The order is shown in the following table:
statb(1) statb(2) statb(3) statb(4) statb(5) statb(6) statb(7) statb(8) statb(9) statb(10) statb(11) statb(12) statb(13) |
Device inode resides on This inode’s number Protection Number of hard links to the file User ID of owner Group ID of owner Device type, for inode that is device Total size of file File last access time File last modify time File last status change time Optimal blocksize for file system I/O ops Actual number of blocks allocated |
See also stat(2), access(3F), perror(3F), and time(3F).
Note: the path names can be no longer than MAXPATHLEN as defined in <sys/param.h>.