From f9110f4480eade2d849c4cc08efa49bf0f7f5148 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 22 Apr 2009 22:20:22 -0400 Subject: [PATCH] libext2fs: Skip relative pathnames in /etc/mtab in ismounted.c The functions which test to see if a device is mounted can get confused by entries in /etc/mtab for virtual filesystems: rootfs / rootfs rw 0 0 none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 If the device name doesn't start with a slash, ignore the /etc/mtab entry, so that relative pathnames passed into functions such as ext2fs_check_mount_point() or ext2fs_check_if_mounted() don't return false positives. Signed-off-by: "Theodore Ts'o" --- lib/ext2fs/ismounted.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index 4a7c8c6..4c5500f 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -65,6 +65,8 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, } } while ((mnt = getmntent (f)) != NULL) { + if (mnt->mnt_fsname[0] != '/') + continue; if (strcmp(file, mnt->mnt_fsname) == 0) break; if (stat(mnt->mnt_fsname, &st_buf) == 0) { -- 1.8.3.1