Oracle Solaris Studio 12.4 Man Pages

Exit Print View

Updated: January 2015
 
 

fstat(3F)

Name

stat , lstat , fstat - 获取文件状态

Synopsis

integer*4 function stat(name,statb)
character*(*) name
integer*4 statb(13)
integer*4 function lstat(name,statb)
character*(*) name
integer*4 statb(13)
integer function fstat(lunit,statb)
integer*4 statb(13)

Description

这些例程返回有关文件的详细信息。

函数 statlstatfilename 执行查询。

函数 fstat 按 FORTRAN 逻辑单元 lunit 执行查询。

成功时,每个函数的值为零,否则返回错误代码。

变量 statb 接收文件的状态结构。

调用序列:

stat:
integer*4 stat, statb(13)
character name*(*)
ierr = stat ( name, statb )

fstat:
integer*4 fstat, logunit, statb(13)
ierr = fstat ( logunit, statb )

lstat:
integer*4 lstat, statb(13)
character name*(*)
ierr = lstat ( name, statb )

数组 statb 中返回的信息的含义在 stat(2) 下针对结构 stat 的描述中有介绍。

不包括备用值。顺序为:

 
statb(1)        device inode resides on
statb(2)        this inode's number
statb(3)        protection
statb(4)        number of hard links to the file
statb(5)        user id of owner
statb(6)        group id of owner
statb(7)        the device type, for inode that is device
statb(8)        total size of file
statb(9)        file last access time
statb(10)       file last modify time
statb(11)       file last status change time
statb(12)       optimal blocksize for file system i/o ops
statb(13)       actual number of blocks allocated

Notes

这些例程在用于大于 2 GB 的文件(“大型”文件,其文件字节数超过了 INTEGER*4 数据的范围)时不会返回错误或警告。但是,以文件总大小 (statb) 形式返回的值将被截断为较低的 32 位。从 Solaris 2.6 操作环境发布开始,引入了对大文件的支持。可将 stat64(3F)、lstat64(3F) 和 fstat64(3F)(这些例程的 64 位版本)用于大文件。

stat 调用 libc 库中的 stat(2),而 lstat 则调用 lstat(2)。有关这两个 libc 函数之间的差异,请参见 stat(2) 手册页。简言之,当指定的文件是符号链接时,它们不同;lstat 将返回有关该链接的信息,而 stat 将返回有关该链接引用的文件的信息。

Files

libfui.a

See also

stat(2)、access(3F)、perror(3F)、time(3F)、stat64(3F)、lstat64(3F)、fstat64(3F)

Bugs

路径名的长度不能超过 <sys/param.h> 中定义的 MAXPATHLEN