9 main(int argc, char* argv[])
12 printf("missing operand\n");
16 int fd = open(argv[1], FO_RDONLY | FO_NOFOLLOW);
18 printf("fail to open %d\n", errno);
22 struct file_stat stat;
23 if (fstat(fd, &stat) < 0) {
24 printf("fail to get stat %d\n", errno);
28 printf("File: %s ", argv[1]);
30 char* ftype = "directory";
31 int mode = stat.st_mode >> 16;
33 ftype = "mappable (sequential) device";
35 if (!((mode & F_SVDEV) ^ F_SVDEV)) {
36 ftype = "volumetric device";
39 } else if ((mode & F_SYMLINK)) {
40 if (readlinkat(fd, NULL, buf, 256) < 0) {
41 printf("fail to readlink %d\n", errno);
45 ftype = "symbolic link";
46 } else if (mode == F_FILE) {
47 ftype = "regular file";
50 printf("\nType: %s\n", ftype);
51 printf("Size: %d; Blocks: %d; FS Block: %d; IO Blocks: %d\n",
58 if (!(mode & F_DEV)) {
63 printf("Device: %xh:%xh@%d; Inode: %d; Links: %d\n",
64 dev->meta, dev->unique, dev->index,
65 stat.st_ino, stat.st_nlink);
67 printf("Access: 0%o; Uid: %d; Gid: %d\n",
68 stat.st_mode & 0xffff,
72 printf("Access: %lu\n", stat.st_atim);
73 printf("Modify: %lu\n", stat.st_mtim);
74 printf("Create: %lu\n", stat.st_ctim);