头文件:
#包含
#包含
#包含
定义:
intstat(constcharqjdzhpathname,struct stat qjdzhbuf );
描述:
thefunctionsreturninformationaboutafile,in the buffer pointed to by buf。
nopermissionsarerequiredonthefileitself,but—in the case of stat (,fstatat ),and
lstat ()-execute(search ) permissionisrequiredonallofthedirectoriesinpathname
that lead to the file。
stat(andfstatat ) retrieveinformationaboutthefilepointedtobypathname;
stat(andfstatat ) retrieveinformationaboutthefilepointedtobypathname; the differences for fstatat () are described below。
ltat (身份证明)、exceptthatifpathnameisasymboliclink、thenitreturnsinformationaboutthelinkitself、notthefiller
身份证明(ftat )、exceptthatthefileaboutwhichinformationistoberetrievedisspecifiedbythefiledescriptorfd。
RETURN VALUE:
On success,zero is returned. On error,-1 is returned,and errno is set appropriately。
ERRORS:
EBADF fd is bad。
error can occur when,for example,anapplication compiledona 32-bitplatformwithout-d _ file _ offset _ bits=65284; 64 calls stat ()
#包含#包含#包含#包含
intmain () {structstat buf;
stat(home/c/test )、buf );
printf(thefilesize=%dn ),buf.st_size );
}
启动结构:
结构启动{
dev_t st_dev;/qjdzhidofdevicecontainingfileqjdzh/ino _ tst _ ino;/qjdzhinodenumberqjdzh/mode _ tst _ mode;/qjdzhprotectionqjdzh/nlink _ tst _ nlink;/qjdzhnumberofhardlinksqjdzh/uid _ tst _ uid;/qjdzhuseridofownerqjdzh/GID _ tst _ GID;/qjdzhgroupidofownerqjdzh/dev _ tst _ rdev; /qjdzhdeviceid(ifspecialfile ) qjdzh/off_t st_size; /qjdzhtotal size,inbytesqjdzh/blk size _ tst _ blk size;/qjdzhblocksizeforfilesystemi/oqjdzh/blk CNT _ tst _ blocks;/qjdzhnumberof 512 bblocksallocatedqjdzh /
/qjdzhSince Linux 2.6,the kernel supports nanosecond
precisionforthefollowingtimestampfields。
For the details before Linux 2.6,see NOTES.qjdzh/
结构时间ST _ atim; /qjdzh time of last access qjdzh/
结构时间ST _ mtim;/qjdzhtimeoflastmodificationqjdzh /
结构时间ST _ ctim;/qjdzhtimeoflaststatuschangeqjdzh /
# definest _ atimest _ atim.TV _ sec/qjdzhbackwardcompatibilityqjdzh /
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec};
(;
stat(Intfd、structstatqjdzh )接收到的open的文件描述符
请注意,stat(charqjdzhfilename,structstatqjdzh ) )接收的路径名可以处理符号链接,但处理符号链接指向的文件。
请注意,lstat(charqjdzhfilename,structstatqjdzh ) )接收的路径名既可以处理符号链接,也可以处理符号链接本身)文件。