diff options
author | Rob Landley <rob@landley.net> | 2022-10-02 04:11:12 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2022-10-02 04:11:12 -0500 |
commit | 0df9a26c7c844e088abd519cc6c5748b514695e9 (patch) | |
tree | 01ce14b2161ef533807f6590b468adff612190ac | |
parent | eb88ab8a0d8636f1f55964f3f8ccb65dd52720b5 (diff) | |
download | toybox-0df9a26c7c844e088abd519cc6c5748b514695e9.tar.gz |
The mountpoint logic isn't the same as same_file(), and -q applies to
argument not existing.
-rw-r--r-- | toys/other/mountpoint.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/toys/other/mountpoint.c b/toys/other/mountpoint.c index fb538c42..7985cbb5 100644 --- a/toys/other/mountpoint.c +++ b/toys/other/mountpoint.c @@ -34,7 +34,7 @@ void mountpoint_main(void) struct stat st1, st2; char *arg = *toys.optargs; - if (lstat(arg, &st1)) perror_exit_raw(arg); + if (lstat(arg, &st1)) (FLAG(q) ? die : perror_exit_raw)(arg); if (FLAG(x)) { if (!S_ISBLK(st1.st_mode)) die("block device"); @@ -55,7 +55,7 @@ void mountpoint_main(void) // 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 = !same_file(&st1, &st2); + 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 " : ""); |