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", fd);
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";
32 if ((mode & F_MDEV)) {
33 if (!((mode & F_SEQDEV) ^ F_SEQDEV)) {
34 ftype = "sequential device";
35 } else if (!((mode & F_VOLDEV) ^ F_VOLDEV)) {
36 ftype = "volumetric device";
38 ftype = "regular device";
40 } else if ((mode & F_MSLNK)) {
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_MFILE)) {
48 ftype = "regular file";
51 printf("\nType: %s\n", ftype);
52 printf("Size: %d; Blocks: %d; FS Block: %d; IO Blocks: %d\n",
57 printf("Inode: %d; ", stat.st_ino);
60 if (!(stat.mode & F_MDEV)) {
66 printf("Device: %xh:%d:%d;\n",
69 dev->devident & 0xffff);