From 20801dc6a025507926d879e7bd8a7205e8a479b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 22 Apr 2013 18:37:51 +0200 Subject: [PATCH] Used /proc/mounts for checking existing mounts 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libntfs-3g/volume.c b/libntfs-3g/volume.c index 5bb266ff..edd76979 100644 --- a/libntfs-3g/volume.c +++ b/libntfs-3g/volume.c @@ -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; }