From: Theodore Ts'o Date: Thu, 23 Apr 2009 02:20:22 +0000 (-0400) Subject: libext2fs: Skip relative pathnames in /etc/mtab in ismounted.c X-Git-Tag: v1.41.5~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9110f4480eade2d849c4cc08efa49bf0f7f5148;p=thirdparty%2Fe2fsprogs.git 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" --- diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index 4a7c8c69f..4c5500f46 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) {