[PATCH] mountmgr: Add and remove drives when they are (un)mounted.

Lei Zhang thestig at google.com
Thu Oct 30 18:33:57 CDT 2008


---
 dlls/mountmgr.sys/hal.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/mountmgr.sys/hal.c b/dlls/mountmgr.sys/hal.c
index e1d3da1..53aa10c 100644
--- a/dlls/mountmgr.sys/hal.c
+++ b/dlls/mountmgr.sys/hal.c
@@ -129,6 +129,15 @@ static void new_device( LibHalContext *ctx, const char *udi )
     if (!p_libhal_device_get_property_bool( ctx, parent, "storage.removable", &error ))
         goto done;
 
+    /* add property watch for mount point */
+    p_libhal_device_add_property_watch( ctx, udi, &error );
+
+    if (!p_libhal_device_get_property_bool( ctx, udi, "volume.is_mounted", &error ))
+    {
+        TRACE( "%s not mounted\n", udi );
+        goto done;
+    }
+
     if (!(type = p_libhal_device_get_property_string( ctx, parent, "storage.drive_type", &error )))
         p_dbus_error_free( &error );  /* ignore error */
 
@@ -137,9 +146,6 @@ static void new_device( LibHalContext *ctx, const char *udi )
 
     add_dos_device( -1, udi, device, mount_point, drive_type );
 
-    /* add property watch for mount point */
-    p_libhal_device_add_property_watch( ctx, udi, &error );
-
 done:
     if (type) p_libhal_free_string( type );
     if (parent) p_libhal_free_string( parent );
@@ -170,7 +176,13 @@ static void property_modified (LibHalContext *ctx, const char *udi,
     TRACE( "udi %s key %s %s\n", wine_dbgstr_a(udi), wine_dbgstr_a(key),
                 is_added ? "added" : is_removed ? "removed" : "modified" );
 
-    if (!strcmp( key, "volume.mount_point" )) new_device( ctx, udi );
+    if (!strcmp( key, "volume.is_mounted" ))
+    {
+        if (p_libhal_device_get_property_bool( ctx, udi, "volume.is_mounted", NULL ))
+            new_device( ctx, udi );
+        else
+            removed_device( ctx, udi );
+    }
 }
 
 
-- 
1.5.4.5


--000e0cd20f8a28f825045a8111fc--



More information about the wine-patches mailing list