*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
-
#include "libbb.h"
#include <mntent.h>
devno_of_name = s.st_dev;
block_dev = 0;
- if (S_ISBLK(s.st_mode)) {
+ /* Why S_ISCHR? - UBI volumes use char devices, not block */
+ if (S_ISBLK(s.st_mode) || S_ISCHR(s.st_mode)) {
devno_of_name = s.st_rdev;
block_dev = 1;
}
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);