diff options
Diffstat (limited to 'libbb/find_mount_point.c')
-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 341c30102..edf734614 100644 --- a/libbb/find_mount_point.c +++ b/libbb/find_mount_point.c | |||
@@ -70,11 +70,22 @@ struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too) | |||
70 | continue; | 70 | continue; |
71 | 71 | ||
72 | /* Is device's dev_t == name's dev_t? */ | 72 | /* Is device's dev_t == name's dev_t? */ |
73 | if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == devno_of_name) | 73 | if (mountEntry->mnt_fsname[0] == '/' |
74 | /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
75 | * avoid stat'ing "sysfs", "proc", "none" and such, | ||
76 | * useless at best, can stat unrelated files at worst. | ||
77 | */ | ||
78 | && stat(mountEntry->mnt_fsname, &s) == 0 | ||
79 | && s.st_rdev == devno_of_name | ||
80 | ) { | ||
74 | break; | 81 | break; |
82 | } | ||
75 | /* Match the directory's mount point. */ | 83 | /* Match the directory's mount point. */ |
76 | if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == devno_of_name) | 84 | if (stat(mountEntry->mnt_dir, &s) == 0 |
85 | && s.st_dev == devno_of_name | ||
86 | ) { | ||
77 | break; | 87 | break; |
88 | } | ||
78 | } | 89 | } |
79 | endmntent(mtab_fp); | 90 | endmntent(mtab_fp); |
80 | #else | 91 | #else |