fix unmount issue where directory isn't removed
authorDavid Zeuthen <davidz@redhat.com>
Sat, 31 May 2008 02:08:57 +0000 (22:08 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Sat, 31 May 2008 02:08:57 +0000 (22:08 -0400)
src/devkit-disks-daemon.c
src/devkit-disks-device.c
src/devkit-disks-device.h
src/devkit-disks-mount-monitor.c
src/mounts-file.c

index c553b83..8b9771f 100644 (file)
@@ -170,7 +170,7 @@ devkit_disks_daemon_local_update_mount_state (DevkitDisksDaemon *daemon, GList *
 
                 device_mount_path = devkit_disks_device_local_get_mount_path (device);
                 if (device_mount_path != NULL) {
-                        devkit_disks_device_local_set_unmounted (device, emit_changed);
+                        devkit_disks_device_local_set_unmounted (device, device_mount_path, emit_changed);
                 }
         }
 
index be8ab36..678f366 100644 (file)
@@ -2305,12 +2305,16 @@ devkit_disks_device_local_set_mounted (DevkitDisksDevice *device,
 
 void
 devkit_disks_device_local_set_unmounted (DevkitDisksDevice *device,
+                                         const char        *given_mount_path,
                                          gboolean           emit_changed_signal)
 {
         char *mount_path;
         gboolean remove_dir_on_unmount;
 
-        mount_path = g_strdup (device->priv->info.device_mount_path);
+        if (given_mount_path != NULL)
+                mount_path = g_strdup (given_mount_path);
+        else
+                mount_path = g_strdup (device->priv->info.device_mount_path);
 
         /* make sure we clean up directories created by ourselves in /media */
         if (!mounts_file_has_device (device, NULL, &remove_dir_on_unmount)) {
@@ -2318,6 +2322,8 @@ devkit_disks_device_local_set_unmounted (DevkitDisksDevice *device,
                 remove_dir_on_unmount = FALSE;
         }
 
+        g_warning ("mount_path=%s remove_dir_on_unmount=%d", mount_path, remove_dir_on_unmount);
+
         g_free (device->priv->info.device_mount_path);
         device->priv->info.device_mount_path = NULL;
         device->priv->info.device_is_mounted = FALSE;
@@ -2333,7 +2339,6 @@ devkit_disks_device_local_set_unmounted (DevkitDisksDevice *device,
 
         if (emit_changed_signal)
                 emit_changed (device);
-
         g_free (mount_path);
 }
 
@@ -3401,7 +3406,7 @@ filesystem_unmount_completed_cb (DBusGMethodInvocation *context,
         char *mount_path = user_data;
 
         if (WEXITSTATUS (status) == 0 && !job_was_cancelled) {
-                devkit_disks_device_local_set_unmounted (device, TRUE);
+                devkit_disks_device_local_set_unmounted (device, mount_path, TRUE);
                 if (mount_path != NULL) /* can be NULL when unmounting /etc/fstab mounts */
                         mounts_file_remove (device, mount_path);
                 dbus_g_method_return (context);
@@ -6674,7 +6679,7 @@ force_unmount_completed_cb (DBusGMethodInvocation *context,
         if (WEXITSTATUS (status) == 0 && !job_was_cancelled) {
 
                 g_warning ("Successfully force unmounted device %s", device->priv->info.device_file);
-                devkit_disks_device_local_set_unmounted (device, TRUE);
+                devkit_disks_device_local_set_unmounted (device, NULL, TRUE);
                 mounts_file_remove (device, data->mount_path);
 
                 /* TODO: when we add polling, this can probably be removed. I have no idea why hal's
index 35a77ef..d5fdcad 100644 (file)
@@ -109,6 +109,7 @@ void               devkit_disks_device_local_set_mounted         (DevkitDisksDev
                                                                   const char        *mount_path,
                                                                   gboolean           emit_changed_signal);
 void               devkit_disks_device_local_set_unmounted       (DevkitDisksDevice *device,
+                                                                  const char        *given_mount_path,
                                                                   gboolean           emit_changed_signal);
 
 gboolean           devkit_disks_device_local_is_busy             (DevkitDisksDevice *device);
index 90f82ad..8b2cd04 100644 (file)
@@ -221,8 +221,8 @@ _check_lvm (const char *device_path)
 {
         struct stat statbuf;
         if (stat (device_path, &statbuf) == 0) {
-                g_warning ("major=%d minor=%d", major (statbuf.st_rdev), minor (statbuf.st_rdev));
                 if (major (statbuf.st_rdev) == 253) {
+                        /* TODO: should check that /dev/dm-%d exists and has same major/minor */
                         return g_strdup_printf ("/dev/dm-%d", minor (statbuf.st_rdev));
                 }
         }
index 4d3814d..8fb3152 100644 (file)
@@ -98,7 +98,7 @@ mounts_file_has_device (DevkitDisksDevice *device,
                                 if (mounted_by_uid != NULL)
                                         *mounted_by_uid = atoi (tokens[MOUNTS_FILE_MOUNTED_BY_UID]);
                                 if (remove_dir_on_unmount != NULL)
-                                        if (strcmp (tokens[MOUNTS_FILE_MOUNTED_BY_UID], "1") == 0)
+                                        if (strcmp (tokens[MOUNTS_FILE_REMOVE_DIR_ON_UNMOUNT], "1") == 0)
                                                 *remove_dir_on_unmount = TRUE;
 
                                 g_strfreev (lines);