⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 my_chmod.c

📁 此源码是著名的教材BeginningLinux Programming中文名字叫Linux程序设计书中的源代码
💻 C
字号:
#include <stdio.h>
#include <time.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>

int main(int argc, char *argv[])
{
	struct stat buf;
	// 检查参数
	if (argc != 2) {
		printf("Usage: my_stat <filename>\n");
		exit(0);
	}
	// 获取文件属性
	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 last access is: %s", ctime(&buf.st_atime));
	printf("time of last modification is: %s", ctime(&buf.st_mtime));
	printf("time of last change is: %s", ctime(&buf.st_ctime));
	
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -