Package: libgnomevfs2-0
Version: 1:2.22.0-5
Tags: patch
Followup-For: Bug #396215

I can confirm this problem in the current version of gnome-vfs from
unstable (2.22.0-5).  A filesystem will be displayed twice (once
mounted, once unmounted) in Nautilus, the GNOME file dialog, etc. if:
 1. the FS is currently mounted;
 2. it is listed in /etc/fstab;
 3. it has the 'user' option in fstab; AND
 4. the fstab record's fs_spec uses LABEL=, refers to a symlink
    (such as /dev/disk/by-id/foo), or otherwise differs from the
    device listed in /proc/mounts.

(it might also be necessary for the user option to be listed in
/proc/mtab; I haven't tested the case where it is in fstab but
not mtab)

Two pairs of entries on my system which cause duplicates:

/etc/fstab:
 LABEL=backup_ext /media/backup_ext ext3 
user,noauto,noexec,nosuid,acl,user_xattr 0 0
 /dev/disk/by-label/IPOD /media/ipod vfat 
user,noauto,noexec,fmask=177,dmask=077 0 0

/proc/mounts:
 /dev/sdb1 /media/backup_ext ext3 
rw,nosuid,nodev,noexec,errors=continue,user_xattr,acl,data=ordered 0 0
 /dev/sdg2 /media/ipod vfat 
rw,nosuid,nodev,noexec,fmask=0177,dmask=0077,codepage=cp437,iocharset=utf8 0 0


The Debian gnome-vfs package already contains a patch
(15_uuid_mount.patch) that fixes the problem for UUID= mounts by
making the following changes:

 1. Chase symlinks that appear in fsnames in /proc/mounts (/etc/mtab).
 2. If the fsname in fstab is "UUID=foo", replace that with
    /dev/disk/by-uuid/foo and chase symlinks.
 3. If this is not a symlink, or if realpath fails, skip this
    mountpoint entirely


The attached patch, to be applied AFTER 15_uuid_mount.patch, extends
the logic for fstab further:

 4. If the fsname in fstab is "LABEL=foo", replace that with
    /dev/disk/by-label/foo (and skip the mountpoint if that
    is not a link).
 5. Always chase symlinks that appear in fstab.  This allows
    /dev/disk/by-id/foo and other symlinks to work.

thus fixing the duplicate mountpoint problem for LABEL= and symlink
mountpoints.


This patch applies cleanly to the gnome-vfs from experimental
(2.24.0-1), but I have not tested with that version.


--- gnome-vfs-2.22.0/libgnomevfs/gnome-vfs-unix-mounts.c	2009-01-15 00:08:55.366081000 -0500
+++ gnome-vfs-2.22.0-new/libgnomevfs/gnome-vfs-unix-mounts.c	2009-01-15 01:43:20.734078841 -0500
@@ -597,24 +597,34 @@
 			gchar *device_path;
 
 			device_path = g_strdup_printf ("/dev/disk/by-uuid/%s", mount_entry->device_path+5);
-			   
 			if (g_file_test (device_path, G_FILE_TEST_IS_SYMLINK)) {
-				char rpath[PATH_MAX];
-				if (realpath (device_path, rpath)) {
-					g_free (mount_entry->device_path);
-					mount_entry->device_path = g_strdup (rpath);
-				}
-				else {
-					g_free (device_path);
-					continue;
-				}
+				g_free (mount_entry->device_path);
+				mount_entry->device_path = device_path;
+			} else {
+				g_free (device_path);
+				continue;
 			}
-			else {
+		}
+		if(strlen(mount_entry->device_path) >= 6 && !strncmp (mount_entry->device_path, "LABEL=", 6)) {
+			gchar *device_path;
+
+			device_path = g_strdup_printf ("/dev/disk/by-label/%s", mount_entry->device_path+6);
+			if (g_file_test (device_path, G_FILE_TEST_IS_SYMLINK)) {
+				g_free (mount_entry->device_path);
+				mount_entry->device_path = device_path;
+			} else {
 				g_free (device_path);
 				continue;
 			}
-			g_free (device_path);
-		}	
+		}
+
+		if (g_file_test (mount_entry->device_path, G_FILE_TEST_IS_SYMLINK)) {
+			char rpath[PATH_MAX];
+			if (realpath (mount_entry->device_path, rpath)) {
+				g_free (mount_entry->device_path);
+				mount_entry->device_path = g_strdup(rpath);
+			}
+		}
 
 		mount_entry->filesystem_type = g_strdup (mntent->mnt_type);
 

-- 
Neil Moore, n...@s-z.org, http://s-z.org/neil/

Reply via email to