Re: Automounted Directories



Submount and the gnome-vfs volume management don't get along very well.
The attached patch to gnome-vfs gets it to work reasonably.

-dave

On Wed, 2004-07-14 at 19:57 +0200, Ruediger Dohmhardt wrote:
> Dear list-members,
> 
> displaying automounted directories (automounted by subfs V0.9) worked 
> fine for me with the original Gnome-SUSE9.1 installation.
> SUSE-9.1 uses Nautilus-V2.4.2.
> 
> However, I immediately replaced GNOME-2.4 from SUSE9.1 with garnome 
> 2.6.1, and last week with garnome 2.6.2 (Nautilus-2.6.3).
> Since than I must type a command like
> 
>   cd /media/usb
> 
> to make Nautilus showing the USB-Stick contents longer than 3 seconds.
> 
> Maybe someone can give a hint to this.
> 
> CU Ruediger Dohmhardt
> 
> PS: This e-mail belong to the thread "nautilus and automounted 
> dierectories",
> but I just became list-participant. Hence I had to open a new thread.
> 
> -- 
> Ruediger Dohmhardt                  ruediger dohmhardt freenet de
> Kiefernweg 7                        Tel.:  04101 61743
> 25421 Pinneberg
> 
? gnome-vfs-submount.patch
? daemon/gnome-vfs-daemon
? libgnomevfs/s-enum-types-c
? libgnomevfs/s-enum-types-h
Index: libgnomevfs/gnome-vfs-volume-monitor-daemon.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor-daemon.c,v
retrieving revision 1.7
diff -u -r1.7 gnome-vfs-volume-monitor-daemon.c
--- libgnomevfs/gnome-vfs-volume-monitor-daemon.c	18 May 2004 07:58:40 -0000	1.7
+++ libgnomevfs/gnome-vfs-volume-monitor-daemon.c	4 Jun 2004 01:33:17 -0000
@@ -700,7 +700,7 @@
 	vol->priv->is_mounted = 1;
 	
 	vol->priv->device_type = get_device_type_from_device_and_mount (mount->device_path, mount->mount_path);
-	
+
 	if ((strcmp (mount->filesystem_type, "iso9660") == 0) ||
 	    (strcmp (mount->filesystem_type, "cd9660") == 0)) {
 		if (vol->priv->device_type == GNOME_VFS_DEVICE_TYPE_UNKNOWN) {
@@ -736,7 +736,8 @@
 		vol->priv->device_type = GNOME_VFS_DEVICE_TYPE_HARDDRIVE;
 	}
 
-	if (vol->priv->device_type == GNOME_VFS_DEVICE_TYPE_CDROM) {
+	if (vol->priv->device_type == GNOME_VFS_DEVICE_TYPE_CDROM &&
+	    strcmp (mount->filesystem_type, "subfs")) {
 		fd = 0;
 		disctype = _gnome_vfs_get_cdrom_type (mount->device_path, &fd);
 
@@ -817,6 +818,45 @@
 	return vol;
 }
 
+static GList *
+remove_submounts (GList *volumes)
+{
+	GList *l;
+	GList *new_volumes;
+	GHashTable *submounts;
+	
+	submounts = g_hash_table_new (g_str_hash, g_str_equal);
+	
+	for (l = volumes; l != NULL; l = l->next) {
+		GnomeVFSUnixMount *mount = l->data;
+
+		if (!strcmp (mount->filesystem_type, "subfs")) {
+			g_hash_table_insert (submounts, 
+					     mount->device_path,
+					     mount);
+		}
+	}
+	
+	new_volumes = NULL;
+
+	for (l = volumes; l != NULL; l = l->next) {
+		GnomeVFSUnixMount *mount = l->data;
+		
+		if (strcmp (mount->filesystem_type, "subfs") != 0 &&
+		    g_hash_table_lookup (submounts, mount->device_path)) {
+			_gnome_vfs_unix_mount_free (mount);
+		} else {
+			new_volumes = g_list_prepend (new_volumes, mount);
+		}
+	}
+
+	g_list_free (volumes);
+	
+	g_hash_table_destroy (submounts);
+
+	return g_list_reverse (new_volumes);
+}
+
 static void
 update_mtab_volumes (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon)
 {
@@ -833,6 +873,8 @@
 	if (_gnome_vfs_get_current_unix_mounts (&new_mtab)) {
 		new_mtab = g_list_sort (new_mtab, (GCompareFunc) _gnome_vfs_unix_mount_compare);
 		
+		new_mtab = remove_submounts (new_mtab);
+
 		diff_sorted_lists (volume_monitor_daemon->last_mtab,
 				   new_mtab, (GCompareFunc) _gnome_vfs_unix_mount_compare,
 				   &added, &removed);
@@ -859,7 +901,7 @@
 			_gnome_vfs_volume_monitor_mounted (volume_monitor, vol);
 			gnome_vfs_volume_unref (vol);
 		}
-		
+
 		g_list_free (added);
 		g_list_free (removed);
 		g_list_foreach (volume_monitor_daemon->last_mtab,
Index: libgnomevfs/gnome-vfs-volume-ops.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-ops.c,v
retrieving revision 1.11
diff -u -r1.11 gnome-vfs-volume-ops.c
--- libgnomevfs/gnome-vfs-volume-ops.c	3 Jun 2004 13:49:26 -0000	1.11
+++ libgnomevfs/gnome-vfs-volume-ops.c	4 Jun 2004 01:33:17 -0000
@@ -221,7 +221,7 @@
 
 	info = arg;
 
-	if (info != NULL) {
+	if (info != NULL && info->argv[0] != NULL) {
 		error = NULL;
 		if (g_spawn_sync (NULL,
 				   info->argv,
@@ -317,6 +317,7 @@
 static void
 mount_unmount_operation (const char *mount_point,
 			 const char *device_path,
+			 const char *filesystem_type,
 			 GnomeVFSDeviceType device_type,
 			 gboolean should_mount,
 			 gboolean should_eject,
@@ -341,26 +342,35 @@
        name = mount_point;
 #endif
        
+       command = NULL;
        if (should_mount) {
                command = find_command (MOUNT_COMMAND);
        } else {
-               command = find_command (UMOUNT_COMMAND);
+	       /* Don't unmount subfs volumes */
+	       if (!filesystem_type || strcmp (filesystem_type, "subfs") != 0) {
+		       command = find_command (UMOUNT_COMMAND);
+	       }
        }
 
 	mount_info = g_new0 (MountThreadInfo, 1);
 	i = 0;
-	mount_info->argv[i++] = g_strdup (command);
-	if (should_mount) {
+
+	if (command) {
+		mount_info->argv[i++] = g_strdup (command);
+		if (should_mount) {
 #ifdef  MOUNT_ARGUMENT
-		mount_info->argv[i++] = g_strdup (MOUNT_ARGUMENT);
+			mount_info->argv[i++] = g_strdup (MOUNT_ARGUMENT);
 #endif
-	} else {
+		} else {
 #ifdef  UNMOUNT_ARGUMENT
-		mount_info->argv[i++] = g_strdup (UNMOUNT_ARGUMENT);
+			mount_info->argv[i++] = g_strdup (UNMOUNT_ARGUMENT);
 #endif
+		}
+		mount_info->argv[i++] = g_strdup (name);
+		mount_info->argv[i++] = NULL;
+	} else {
+		mount_info->argv[i++] = NULL;
 	}
-	mount_info->argv[i++] = g_strdup (name);
-	mount_info->argv[i++] = NULL;
 	
 	mount_info->mount_point = g_strdup (mount_point);
 	mount_info->device_path = g_strdup (device_path);
@@ -488,7 +498,7 @@
 			  GnomeVFSVolumeOpCallback  callback,
 			  gpointer                   user_data)
 {
-	char *mount_path, *device_path;
+	char *mount_path, *device_path, *filesystem_type;
 	char *uri;
 	GnomeVFSVolumeType type;
 	
@@ -500,13 +510,16 @@
 		mount_path = gnome_vfs_get_local_path_from_uri (uri);
 		g_free (uri);
 		device_path = gnome_vfs_volume_get_device_path (volume);
+		filesystem_type = gnome_vfs_volume_get_filesystem_type (volume);
 		mount_unmount_operation (mount_path,
 					 device_path,
+					 filesystem_type,
 					 gnome_vfs_volume_get_device_type (volume),
 					 FALSE, FALSE,
 					 callback, user_data);
 		g_free (mount_path);
 		g_free (device_path);
+		g_free (filesystem_type);
 	} else {
 		unmount_connected_server (volume, callback, user_data);
 	}
@@ -517,7 +530,7 @@
 			GnomeVFSVolumeOpCallback  callback,
 			gpointer                   user_data)
 {
-	char *mount_path, *device_path;
+	char *mount_path, *device_path, *filesystem_type;
 	char *uri;
 	GnomeVFSVolumeType type;
 	
@@ -529,13 +542,16 @@
 		mount_path = gnome_vfs_get_local_path_from_uri (uri);
 		g_free (uri);
 		device_path = gnome_vfs_volume_get_device_path (volume);
+		filesystem_type = gnome_vfs_volume_get_filesystem_type (volume);
 		mount_unmount_operation (mount_path,
 					 device_path,
+					 filesystem_type,
 					 gnome_vfs_volume_get_device_type (volume),
 					 FALSE, TRUE,
 					 callback, user_data);
 		g_free (mount_path);
 		g_free (device_path);
+		g_free (filesystem_type);
 	} else {
 		unmount_connected_server (volume, callback, user_data);
 	}
@@ -552,8 +568,10 @@
 	mount_path = gnome_vfs_get_local_path_from_uri (uri);
 	g_free (uri);
 	device_path = gnome_vfs_drive_get_device_path (drive);
+
 	mount_unmount_operation (mount_path,
 				 device_path,
+				 NULL,
 				 GNOME_VFS_DEVICE_TYPE_UNKNOWN,
 				 TRUE, FALSE,
 				 callback, user_data);
@@ -566,7 +584,7 @@
 			 GnomeVFSVolumeOpCallback  callback,
 			 gpointer                   user_data)
 {
-	char *mount_path, *device_path, *uri;
+	char *mount_path, *device_path, *uri, *filesystem_type;
 	GnomeVFSVolume *volume;
 
 
@@ -580,13 +598,16 @@
 	mount_path = gnome_vfs_get_local_path_from_uri (uri);
 	g_free (uri);
 	device_path = gnome_vfs_drive_get_device_path (drive);
+	filesystem_type = gnome_vfs_volume_get_filesystem_type (volume);
 	mount_unmount_operation (mount_path,
 				 device_path,
+				 filesystem_type,
 				 (volume == NULL) ? GNOME_VFS_DEVICE_TYPE_UNKNOWN:gnome_vfs_volume_get_device_type (volume),
 				 FALSE, FALSE,
 				 callback, user_data);
 	g_free (mount_path);
 	g_free (device_path);
+		g_free (filesystem_type);
 	gnome_vfs_volume_unref (volume);
 }
 
@@ -595,7 +616,7 @@
 		       GnomeVFSVolumeOpCallback  callback,
 		       gpointer                   user_data)
 {
-	char *mount_path, *device_path, *uri;
+	char *mount_path, *device_path, *uri, *filesystem_type;
 	GnomeVFSVolume *volume;
 
 
@@ -609,13 +630,16 @@
 	mount_path = gnome_vfs_get_local_path_from_uri (uri);
 	g_free (uri);
 	device_path = gnome_vfs_drive_get_device_path (drive);
+	filesystem_type = gnome_vfs_volume_get_filesystem_type (volume);
 	mount_unmount_operation (mount_path,
 				 device_path,
+				 filesystem_type,
 				 (volume == NULL) ? GNOME_VFS_DEVICE_TYPE_UNKNOWN:gnome_vfs_volume_get_device_type (volume),
 				 FALSE, TRUE,
 				 callback, user_data);
 	g_free (mount_path);
 	g_free (device_path);
+	g_free (filesystem_type);
 	gnome_vfs_volume_unref (volume);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]