Whamcloud - gitweb
libext2fs: don't scan /etc/mtab if file system not found in /proc/mounts
authorTheodore Ts'o <tytso@mit.edu>
Mon, 6 Jan 2020 19:42:01 +0000 (14:42 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 6 Jan 2020 20:15:10 +0000 (15:15 -0500)
Previously we would scan /etc/mtab if the device is not found in
/proc/mounts.  This is because previously, /etc/mtab would have the
filename for a loopback mount, while /proc/mounts would only have
something like /dev/loop0.  Since on many systems /etc/mtab is now a
symlink to /proc/mounts, ismounted.c has a special function,
check_loop_mounted.

For this reason, it's not necessary to fall back to trying to scan
/etc/mtab if a device / filename is not found from scanning
/proc/mounts.  This also prevents failures if the file /etc/mtab does
not exist but /proc/mounts does exist when checking to see if a device
is mounted when it isn't.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ismounted.c

index dc37cce..c021569 100644 (file)
@@ -227,7 +227,7 @@ static errcode_t check_mntent(const char *file, int *mount_flags,
 #ifdef __linux__
        retval = check_mntent_file("/proc/mounts", file, mount_flags,
                                   mtpt, mtlen);
-       if (retval == 0 && (*mount_flags != 0))
+       if (retval == 0)
                return 0;
 #endif /* __linux__ */
 #if defined(MOUNTED) || defined(_PATH_MOUNTED)