From 43bdb47d02b17d46e8495dae733c7b07cb9f9ce4 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 6 Jan 2020 14:42:01 -0500 Subject: [PATCH] libext2fs: don't scan /etc/mtab if file system not found in /proc/mounts 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 --- lib/ext2fs/ismounted.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index dc37cce..c021569 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -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) -- 1.8.3.1