10 main(int argc, char* argv[])
13 printf("missing operand\n");
17 int fd = open(argv[1], FO_RDONLY | FO_NOFOLLOW);
19 printf("fail to open %d\n", errno);
23 struct file_stat stat;
24 if (fstat(fd, &stat) < 0) {
25 printf("fail to get stat %d\n", errno);
29 printf("File: %s ", argv[1]);
31 char* ftype = "directory";
32 int mode = stat.st_mode >> 16;
34 ftype = "mappable (sequential) device";
36 if (!((mode & F_SVDEV) ^ F_SVDEV)) {
37 ftype = "volumetric device";
40 } else if ((mode & F_SYMLINK)) {
41 if (readlinkat(fd, NULL, buf, 256) < 0) {
42 printf("fail to readlink %d\n", errno);
46 ftype = "symbolic link";
47 } else if (mode == F_FILE) {
48 ftype = "regular file";
51 printf("\nType: %s\n", ftype);
52 printf("Size: %d; Blocks: %d; FS Block: %d; IO Blocks: %d\n",
59 if (!(mode & F_DEV)) {
64 printf("Device: %xh:%xh@%d; Inode: %d; Links: %d\n",
65 dev->meta, dev->unique, dev->index,
66 stat.st_ino, stat.st_nlink);
68 printf("Access: 0%o; Uid: %d; Gid: %d\n",
69 stat.st_mode & 0xffff,
73 printf("Access: %lu\n", stat.st_atim);
74 printf("Modify: %lu\n", stat.st_mtim);
75 printf("Create: %lu\n", stat.st_ctim);