Re: [Nautilus-list] nautilus-1.0.4-automount patch



le lun 12-11-2001 à 19:52, Darin Adler a écrit :
> on 11/12/01 7:57 AM, Frederic Crozat at fcrozat mandrakesoft com wrote:
> 
> > So, here is second version of patch (against 1.0.6)..
> 
> Looks OK to commit. I'd like those long lines broken up, and there's no need
> for that #else in volume_is_automounted. But neither of those is a major
> issue. Please commit to the stable branch at least, and preferably to both
> branches.

I was ready to commit the patch with your suggestions when I encounter
strange behaviours when mixing CD automount and "manual" mounting
(through Disks contextual menu) when a CDROM is accessed at the same
time through automount and manual mount. In this test case, CDROM is
mounted two times, with same device_path but different mount_path..

Therefore I've found a bug in nautilus_volume_monitor_set_volume_name
which was only checking for device_path, which could lead in
inconsistent CD icons on desktop and abnormal nautilus window creation
when accessing to automounted CDs. It is fixed in the patch.

I'm also wondering if we should popup a new nautilus window when an
automounted CDROM volume is mounted. This could be very annoying to get
nautilus window poping-up each time a CD is mounted if the system is
used by several people at the same time, as a server. I'm wondering if I
should add nautilus_volume_is_automounted public function and call it in
volume_mounted_callback in nautilus-application.c ? 

There is also no way for users to disable this autopop feature is
magicdev is not install on the system and since magicdev is very tied to
RedHat, it is only available on RedHat (and Debian) systems :( Maybe I
could add a preferences in Expert mode, only visible when magicdev is
not on the system ?

When all this things will be done and as soon as I get a working
supermount kernel, I'll be working on adding supermount support for
Nautilus..

So, here is new version of patch... I'm waiting for your comment :))

-- 
Frédéric Crozat
MandrakeSoft
--- nautilus-1.0.6/libnautilus-private/nautilus-volume-monitor.c.autofs	Wed Oct 10 02:16:39 2001
+++ nautilus-1.0.6/libnautilus-private/nautilus-volume-monitor.c	Tue Nov 13 18:32:12 2001
@@ -623,6 +623,57 @@
 
 #endif /* !SOLARIS_MNT */
 
+static gboolean 
+volume_is_automounted (const NautilusVolume *volume)
+{
+	FILE *file;
+	MountTableEntry *ent;
+	gboolean automounted;
+#ifdef HAVE_SYS_MNTTAB_H
+ 	MountTableEntry ent_storage;
+#endif
+	
+	automounted = FALSE; 
+ 
+#ifdef HAVE_SYS_MNTTAB_H
+	file = setmntent (MOUNT_TABLE_PATH, "r");
+ 	if (file == NULL) {
+ 		return FALSE;
+ 	}
+
+ 	 /* Search for our device in the fstab */
+ 	ent = &ent_storage;
+	while (!getmntent (file, ent)) {
+		if ((strstr (ent->mnt_fstype, "autofs") != NULL) 
+		    && (strncmp (ent->mnt_mountp, volume->mount_path, strlen (ent->mnt_mountp)) == 0)) {
+			automounted = TRUE;
+			break;
+		}
+ 	}
+	fclose (file);
+
+#elif defined (HAVE_MNTENT_H)
+	file = setmntent (_PATH_MOUNTED, "r");
+	if (file == NULL) {
+		return FALSE;
+	}
+		
+	/* Search for our device in the fstab */
+	while ((ent = getmntent (file)) != NULL) {
+		if ((strstr (ent->mnt_type, "autofs") != NULL) 
+		    && (strncmp (ent->mnt_dir, volume->mount_path, strlen (ent->mnt_dir)) == 0)) {
+			automounted = TRUE;
+			break;
+		}
+	}
+	
+	endmntent (file);
+#endif
+	
+	
+	return automounted;
+}
+
 char *
 nautilus_volume_get_name (const NautilusVolume *volume)
 {
@@ -833,7 +884,11 @@
 
 	switch (volume->device_type) {
 	case NAUTILUS_DEVICE_CDROM_DRIVE:
-		pthread_create (&eject_thread, NULL, eject_device, g_strdup (volume->device_path));
+		/* Don't eject automounted device 
+		 * since this action is done by automount daemon, not user */
+		if (!volume_is_automounted (volume)) {
+			pthread_create (&eject_thread, NULL, eject_device, g_strdup (volume->device_path));
+		}
 		break;
 	default:
 	}
@@ -1592,7 +1647,8 @@
 	/* Find volume and set new name */
 	for (node = monitor->details->mounts; node != NULL; node = node->next) {
 		found_volume = node->data;
-		if (strcmp (found_volume->device_path, volume->device_path) == 0) {
+		if ((strcmp (found_volume->device_path, volume->device_path) == 0)
+		   && (strcmp (found_volume->mount_path, volume->mount_path) == 0)) {
 			g_free (found_volume->volume_name);
 			found_volume->volume_name = g_strdup (volume_name);
 			return;


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