summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/find_mount_point.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libbb/find_mount_point.c b/libbb/find_mount_point.c
index 94bbf1d..0e1be38 100644
--- a/libbb/find_mount_point.c
+++ b/libbb/find_mount_point.c
@@ -56,11 +56,22 @@ struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too)
continue;
/* Is device's dev_t == name's dev_t? */
- if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == devno_of_name)
+ if (mountEntry->mnt_fsname[0] == '/'
+ /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ * avoid stat'ing "sysfs", "proc", "none" and such,
+ * useless at best, can stat unrelated files at worst.
+ */
+ && stat(mountEntry->mnt_fsname, &s) == 0
+ && s.st_rdev == devno_of_name
+ ) {
break;
+ }
/* Match the directory's mount point. */
- if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == devno_of_name)
+ if (stat(mountEntry->mnt_dir, &s) == 0
+ && s.st_dev == devno_of_name
+ ) {
break;
+ }
}
endmntent(mtab_fp);