If the device name in the mtab or /proc/mounts file does not match
with the device passed into ext2fs_check_if_mounted() or
ext2fs_check_mount_point(), skip the stat(2) call on the mountpoint,
since we never use the results of the stat(2) in that case. Not only
does this provide a slight performance win, but it the stat calls on
the mountpoints could potentially trigger some SELinux denials that
could stress some sysadmins out.
Google-Bug-Id:
193137337
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
while ((mnt = getmntent (f)) != NULL) {
if (mnt->mnt_fsname[0] != '/')
continue;
- if (stat(mnt->mnt_dir, &st_buf) != 0)
- continue;
if (strcmp(file, mnt->mnt_fsname) == 0) {
+ if (stat(mnt->mnt_dir, &st_buf) != 0)
+ continue;
if (file_rdev && (file_rdev != st_buf.st_dev)) {
#ifdef DEBUG
printf("Bogus entry in %s! "
- "(%s does not exist)\n",
- mtab_file, mnt->mnt_dir);
+ "(%s is not mounted on %s)\n",
+ mtab_file, file, mnt->mnt_dir);
#endif /* DEBUG */
continue;
}