Путь: Toys/Other, команды версии: Ver.4 Ver.9 mountpoint Комментарии в файле mountpoint.c :
Исходный текст в файле mountpoint.c #define FOR_mountpoint #include "toys.h" static void die(char *gripe) { if (!FLAG(q)) printf("%s: not a %s\n", *toys.optargs, gripe); toys.exitval++; xexit(); } void mountpoint_main(void) { struct stat st1, st2; char *arg = *toys.optargs; if (lstat(arg, &st1)) (FLAG(q) ? die : perror_exit_raw)(arg); if (FLAG(x)) { if (!S_ISBLK(st1.st_mode)) die("block device"); if (!FLAG(q)) printf("%u:%u\n", dev_major(st1.st_rdev), dev_minor(st1.st_rdev)); return; } // TODO: a file can be a mountpoint for --bind mounts. if (!S_ISDIR(st1.st_mode)) die("directory"); arg = xmprintf("%s/..", arg); xstat(arg, &st2); free(arg); // If the device is different, it's a mount point. If the device _and_ // inode are the same, it's probably "/". This misses --bind mounts from // elsewhere in the same filesystem, but so does the other one and in the // absence of a spec I guess that's the expected behavior? toys.exitval = !(st1.st_dev != st2.st_dev || st1.st_ino == st2.st_ino); if (FLAG(d)) printf("%u:%u\n", dev_major(st1.st_dev), dev_minor(st1.st_dev)); else if (!FLAG(q)) printf("%s is %sa mountpoint\n", *toys.optargs, toys.exitval ? "not " : ""); } |