1 Star 0 Fork 0

luhcen/信息安全系统设计

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
stat 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
luhcen 提交于 4年前 . add stat.
#include<stdio.h>
#include<time.h>
#include<sys/stat.h>
#include<unistd.h>
#include<sys/types.h>
#include<errno.h>
#include<stdlib.h>
int main(int argc, char **argv)
{
struct stat buf;
/检查参数个数/
if(argc!=2)
{
perror("Usage:my_stat \n");
exit(1);
}
/获取文件属性/
if( stat(argv[1], &buf) ==-1 )
{
perror("stat:");
exit(1);
}
printf("device is: %d\n",buf.st_dev);
printf("inode is : %d\n",buf.st_ino);
printf("mode is: %o\n",buf.st_mode);
printf("number of hard links is: %d\n",buf.st_nlink);
printf("user ID of owner is: %d\n",buf.st_uid);
printf("group ID of owner is: %d\n",buf.st_gid);
printf("device type (if inode device )is: %d\n",buf.st_rdev);
printf("total size ,in bytes is: %d\n",buf.st_size);
printf("blocksize for filesystem I/O is: %d\n",buf.st_blksize);
printf("number of blocks allocated is: %d\n",buf.st_blocks);
printf("time of lasst access is: %s",ctime(&buf.st_atime));
printf("time of last modification is: %s",ctime(&buf.st_mtime));
printf("time of last chage is: %s",ctime(&buf.st_ctime));
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lu_chen9/linux-system-programming.git
git@gitee.com:lu_chen9/linux-system-programming.git
lu_chen9
linux-system-programming
信息安全系统设计
master

搜索帮助