[Nautilus-list] verify_current_mount_state



I'm currently trying to figure out a fix for a race condition where
if you unmount/eject a CD-ROM rapidly from the command line, the
CD-ROM icon is left behind on the desktop.

The code in nautilus-volume-monitor.c/verify_current_mount_state() is
confusing me a quite a bit:

====
	/* Get all current mounts */
	current_mounts = get_current_mount_list ();
	if (current_mounts == NULL) {
		return;
	}
  	
  	/* If the new list is the same of the current list, bail. */
	if (mount_lists_are_identical (current_mounts, monitor->details->mounts)) {
		free_mount_list (current_mounts);
		return;
	}
		
	/* Create list of new and old mounts */
	new_mounts = build_volume_list_delta (current_mounts, monitor->details->mounts);
	old_mounts = build_volume_list_delta (monitor->details->mounts, current_mounts);  		
		
	/* Stash a copy of the current mount list for updating mount names later. */
	saved_mount_list = monitor->details->mounts;
		
	/* Free previous mount list and replace with new */
	monitor->details->mounts = current_mounts;

===

We haven't called load_additional_mount_list () yet, so we are storing
the mount list here missing information such as the volume label from
a CD-ROM. 

===

	/* Process list results to check for a properties that require opening files on disk. */
	load_additional_mount_list_info (new_mounts);
	
	if (old_mounts != NULL) {
		load_additional_mount_list_info (old_mounts);
		load_additional_mount_list_info (saved_mount_list);
	}
====

Wait ... old_mounts are mounts that are no longer there, calling
load_additional_mount_list_info (old_mounts) doesn't make any sense.

(Since the drive has been unmounted, it could have been ejected.)

Same for saved_mount_list; the volumes that aren't there can't
be updated, the volumes that are there don't need to be updated.

We actually need the full name and so forth for the old_mounts list,
fm-desktop-icon-view.c needs it to know what to remove, so what
we have to do is:

 a) Call load_additional_mount_list_info() on current_mounts before
    we save it in monitor->details->mounts.

 b) Not call load_additional_mount_list_info() on old_mounts 
    or saved_mount_list since that will wipe out what we stored.

====
    	
	/* Check and see if we have new mounts to add */
	for (node = new_mounts; node != NULL; node = node->next) {
		mount_volume_activate (monitor, node->data);
	}				
	
	/* Check and see if we have old mounts to remove */
	for (node = old_mounts; node != NULL; node = node->next) {
		/* First we need to update the volume names in this list with modified names in the old list. Names in
		 * the old list may have been modifed due to icon name conflicts.  The list of old mounts is unable
		 * take this into account when it is created
		 */			
		update_modifed_volume_name (saved_mount_list, node->data);
		
		/* Deactivate the volume. */
		mount_volume_deactivate (monitor, node->data);
  
         }
===

I don't understand this either ... old_mounts and saved_mount list
come from the same place (the previous list of mounts that was stored
in mount->details->mounts), so saved_mount_list won't have any information
that is not in old_mounts. 

I think calling update_modified_volume_name doesn't actually do anything
useful, and it seems to be some attempt to solve the problem that 
a) and b) are supposed to fix above.

I'd really appreciate if someone checked through my reasoning above ...
if I do a) and b) things seem to work a lot better, but I don't
have a lot of confidence 

Regards,
                                        Owen

[ 

Test case for bug currently:

 - insert CD, let magicdev mount it

 - remove CD by typing 'eject' from the command line which unmounts'
   and ejects. If 'eject' doesn't unmount on your system, 
   'unmount /mnt/cdrom; eject /dev/cdrom' from the command line should 
   cause the same problem.

 - CD-ROM icon is left behind and can't even be moved to the trash.

]




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