OSDN Git Service

Used /proc/mounts for checking existing mounts
authorJean-Pierre André <jpandre@users.sourceforge.net>
Mon, 22 Apr 2013 16:37:51 +0000 (18:37 +0200)
committerJean-Pierre André <jpandre@users.sourceforge.net>
Mon, 22 Apr 2013 16:37:51 +0000 (18:37 +0200)
The file /etc/mtab is traditionally checked to avoid multiple mountings
of the same device, but this is not accurate enough in some conditions.
So use /proc/mounts when available and fall back to /etc/mtab on
systems which do not have /proc/mounts.

libntfs-3g/volume.c

index 5bb266f..edd7697 100644 (file)
@@ -1433,7 +1433,8 @@ static int ntfs_mntent_check(const char *file, unsigned long *mnt_flags)
                err = errno;
                goto exit;
        }
-       if (!(f = setmntent(MOUNTED, "r"))) {
+       f = setmntent("/proc/mounts", "r");
+       if (!f && !(f = setmntent(MOUNTED, "r"))) {
                err = errno;
                goto exit;
        }