gnome-mount r167 - in trunk: . src



Author: davidz
Date: Thu Apr 17 00:47:38 2008
New Revision: 167
URL: http://svn.gnome.org/viewvc/gnome-mount?rev=167&view=rev

Log:
2008-04-16  David Zeuthen  <davidz redhat com>

        * src/gnome-mount.c: Ensure that eject works even when giving
        a drive (e.g. /dev/sdb) instead of a volume (e.g. /dev/sdb1).
        Fixes #526308.



Modified:
   trunk/ChangeLog
   trunk/src/gnome-mount.c

Modified: trunk/src/gnome-mount.c
==============================================================================
--- trunk/src/gnome-mount.c	(original)
+++ trunk/src/gnome-mount.c	Thu Apr 17 00:47:38 2008
@@ -205,7 +205,7 @@
 		 *   org.freedesktop.Hal.Device.Volume.InvalidEjectOption
 		 *   org.freedesktop.Hal.Device.Volume.Busy
 		 *   org.freedesktop.Hal.Device.Volume.UnknownFailure
-		 *
+		 *   org.freedesktop.Hal.Device.UnknownError
 		 *
 		 * in a sane way.
 		 */
@@ -240,13 +240,16 @@
 			/* TODO: could add 'Lazy Unmount' button */
 		} else if (strcmp (error_name, "org.freedesktop.Hal.Device.Volume.InvalidUnmountOption") == 0 ||
 			   strcmp (error_name, "org.freedesktop.Hal.Device.Volume.UnsupportedEjectOption") == 0 ||
-			   strcmp (error_name, "org.freedesktop.Hal.Device.Volume.UnknownFailure") == 0) {
-			gtk_message_dialog_format_secondary_text (
+			   strcmp (error_name, "org.freedesktop.Hal.Device.Volume.UnknownFailure") == 0 ||
+			   strcmp (error_name, "org.freedesktop.Hal.Device.UnknownError") == 0) {
+			gtk_message_dialog_format_secondary_markup (
 				GTK_MESSAGE_DIALOG (w),
-				volume_name != NULL ? 
-				_("Cannot eject the volume '%s'.") :
-				_("Cannot eject the volume."),
-				volume_name);
+				_("There was an error ejecting the volume or drive."
+                                  "\n"
+                                  "\n"
+                                  "<b>%s:</b> %s"),
+                                error_name,
+                                error_detail);
 		}
 
 		gtk_dialog_add_buttons (GTK_DIALOG (w),
@@ -2948,6 +2951,43 @@
 			if (found) {
 				goto try_drive;
 			} else {
+                                if (opt_eject) {
+                                        char **volumes_udis;
+                                        int num_volumes;
+                                        int n;
+
+                                        /* HACK TODO XXX ALERT: ugh.. try to find a mountable volume with an eject
+                                         * method..
+                                         */
+                                        volumes_udis = libhal_drive_find_all_volumes (hal_ctx, drive, &num_volumes);
+                                        if (volumes_udis != NULL) {
+                                                for (n = 0; n < num_volumes; n++) {
+                                                        char **vol_ifs;
+                                                        int m;
+
+                                                        vol_ifs = libhal_device_get_property_strlist (
+                                                                hal_ctx,
+                                                                volumes_udis[n],
+                                                                "info.interfaces",
+                                                                NULL);
+                                                        if (vol_ifs != NULL) {
+                                                                for (m = 0; vol_ifs[m] != NULL; m++) {
+                                                                        if (strcmp (ifs[m], "org.freedesktop.Hal.Device.Volume") == 0) {
+                                                                                volume = libhal_volume_from_udi (hal_ctx, volumes_udis[n]);
+                                                                                libhal_drive_free (drive);
+                                                                                drive = NULL;
+                                                                                goto try_drive;
+                                                                        }
+                                                                }
+                                                        }
+                                                        libhal_free_string_array (vol_ifs);
+                                                }
+                                                libhal_free_string_array (volumes_udis);
+                                        }
+
+                                }
+
+
                                 if (opt_verbose)
                                         g_message (_("Drive %s does not contain media."), 
                                                    resolved_device_file != NULL ? resolved_device_file : opt_hal_udi);
@@ -3038,8 +3078,8 @@
 		}
 
 	} else if (opt_eject) {
-		if (volume_eject (udi, volume, drive))
-			rc = 0;
+                if (volume_eject (udi, volume, drive))
+                        rc = 0;
 	} else {
 		LibHalVolumeUsage fsusage;
 



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