diff options
-rw-r--r-- | libbb/find_mount_point.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libbb/find_mount_point.c b/libbb/find_mount_point.c index 94bbf1d4a..0e1be3820 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) | |||
56 | continue; | 56 | continue; |
57 | 57 | ||
58 | /* Is device's dev_t == name's dev_t? */ | 58 | /* Is device's dev_t == name's dev_t? */ |
59 | if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == devno_of_name) | 59 | if (mountEntry->mnt_fsname[0] == '/' |
60 | /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
61 | * avoid stat'ing "sysfs", "proc", "none" and such, | ||
62 | * useless at best, can stat unrelated files at worst. | ||
63 | */ | ||
64 | && stat(mountEntry->mnt_fsname, &s) == 0 | ||
65 | && s.st_rdev == devno_of_name | ||
66 | ) { | ||
60 | break; | 67 | break; |
68 | } | ||
61 | /* Match the directory's mount point. */ | 69 | /* Match the directory's mount point. */ |
62 | if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == devno_of_name) | 70 | if (stat(mountEntry->mnt_dir, &s) == 0 |
71 | && s.st_dev == devno_of_name | ||
72 | ) { | ||
63 | break; | 73 | break; |
74 | } | ||
64 | } | 75 | } |
65 | endmntent(mtab_fp); | 76 | endmntent(mtab_fp); |
66 | 77 | ||