Whamcloud - gitweb
libext2fs: Skip relative pathnames in /etc/mtab in ismounted.c
authorTheodore Ts'o <tytso@mit.edu>
Thu, 23 Apr 2009 02:20:22 +0000 (22:20 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 23 Apr 2009 02:20:22 +0000 (22:20 -0400)
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" <tytso@mit.edu>
lib/ext2fs/ismounted.c

index 4a7c8c6..4c5500f 100644 (file)
@@ -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) {