fstat

来源:互联网 发布:淘宝贷款欠1万4年了 编辑:程序博客网 时间:2024/05/21 07:14

/************GNU/Linux 编程p170 **********/

//fstat获得文件信息

#include<stdio.h>

#include<unistd.h>

#include<sys/stat.h>

 

 

int main(){

struct stat buf;

int fd;

if(argc!=2)

{

puts("USAGE:mstat{file}");

exit(EXIT_FAILURE);

}

if((fd=open(arv[1],O_RDONLY))<0)

{

perror();

exit(-1);

}

if((fd=fstat(fd,&buf))<0)

{

perror();

exit(-1);

}

mode=buf.st_mode;

printf("FILE:%s\n",argv[1]);

printf( )

exit(EXIT_SUCCESS);

原创粉丝点击