Alexandre Julliard : mountmgr: Add support for setting the drive UUID instead of having it always hardcoded .

Alexandre Julliard julliard at winehq.org
Tue Jul 21 09:33:43 CDT 2009


Module: wine
Branch: master
Commit: 84396c2e625d918be73d6948c7aed650e4e139c7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=84396c2e625d918be73d6948c7aed650e4e139c7

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jul 20 16:05:04 2009 +0200

mountmgr: Add support for setting the drive UUID instead of having it always hardcoded.

---

 dlls/mountmgr.sys/device.c   |   16 ++++++++++++++--
 dlls/mountmgr.sys/diskarb.c  |    2 +-
 dlls/mountmgr.sys/hal.c      |    2 +-
 dlls/mountmgr.sys/mountmgr.c |   13 +++++--------
 dlls/mountmgr.sys/mountmgr.h |    4 ++--
 5 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 8057a69..1b23d97 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -71,6 +71,7 @@ struct volume
     struct list           entry;       /* entry in volumes list */
     struct disk_device   *device;      /* disk device */
     char                 *udi;         /* unique identifier for dynamic volumes */
+    GUID                  guid;        /* volume uuid */
     struct mount_point   *mount;       /* Volume{xxx} mount point */
 };
 
@@ -109,6 +110,14 @@ static char *strdupA( const char *str )
     return ret;
 }
 
+static const GUID *get_default_uuid( int letter )
+{
+    static GUID guid;
+
+    guid.Data4[7] = 'A' + letter;
+    return &guid;
+}
+
 /* read a Unix symlink; returned buffer must be freed by caller */
 static char *read_symlink( const char *path )
 {
@@ -358,7 +367,7 @@ static void set_drive_letter( struct dos_drive *drive, int letter )
         id_len = strlen( device->unix_mount ) + 1;
     }
     drive->dosdev = add_dosdev_mount_point( device->dev_obj, &device->name, letter, id, id_len );
-    volume->mount = add_volume_mount_point( device->dev_obj, &device->name, letter, id, id_len );
+    volume->mount = add_volume_mount_point( device->dev_obj, &device->name, &volume->guid, id, id_len );
 }
 
 static inline int is_valid_device( struct stat *st )
@@ -528,6 +537,7 @@ static void create_drive_devices(void)
         {
             drive->volume->device->unix_mount = link;
             drive->volume->device->unix_device = device;
+            drive->volume->guid = *get_default_uuid( i );
             set_drive_letter( drive, i );
         }
         else
@@ -542,7 +552,7 @@ static void create_drive_devices(void)
 
 /* create a new dos drive */
 NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
-                         const char *mount_point, enum device_type type )
+                         const char *mount_point, enum device_type type, const GUID *guid )
 {
     struct dos_drive *drive, *next;
 
@@ -575,6 +585,8 @@ NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
     if (create_dos_device( udi, type, &drive )) return STATUS_NO_MEMORY;
 
 found:
+    if (!guid) guid = get_default_uuid( letter );
+    drive->volume->guid = *guid;
     RtlFreeHeap( GetProcessHeap(), 0, drive->volume->device->unix_device );
     drive->volume->device->unix_device = strdupA( device );
     set_drive_letter( drive, letter );
diff --git a/dlls/mountmgr.sys/diskarb.c b/dlls/mountmgr.sys/diskarb.c
index 3296d04..1597e34 100644
--- a/dlls/mountmgr.sys/diskarb.c
+++ b/dlls/mountmgr.sys/diskarb.c
@@ -69,7 +69,7 @@ static void appeared_callback( DADiskRef disk, void *context )
 
     TRACE( "got mount notification for '%s' on '%s'\n", device, mount_point );
 
-    add_dos_device( -1, device, device, mount_point, type );
+    add_dos_device( -1, device, device, mount_point, type, NULL );
 done:
     CFRelease( dict );
 }
diff --git a/dlls/mountmgr.sys/hal.c b/dlls/mountmgr.sys/hal.c
index 310b144..6e09c2c 100644
--- a/dlls/mountmgr.sys/hal.c
+++ b/dlls/mountmgr.sys/hal.c
@@ -136,7 +136,7 @@ static void new_device( LibHalContext *ctx, const char *udi )
     else if (type && !strcmp( type, "floppy" )) drive_type = DEVICE_FLOPPY;
     else drive_type = DEVICE_UNKNOWN;
 
-    add_dos_device( -1, udi, device, mount_point, drive_type );
+    add_dos_device( -1, udi, device, mount_point, drive_type, NULL );
 
     /* add property watch for mount point */
     p_libhal_device_add_property_watch( ctx, udi, &error );
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
index d2b1515..4554de6 100644
--- a/dlls/mountmgr.sys/mountmgr.c
+++ b/dlls/mountmgr.sys/mountmgr.c
@@ -103,20 +103,17 @@ struct mount_point *add_dosdev_mount_point( DEVICE_OBJECT *device, UNICODE_STRIN
 
 /* create the Volume mount point symlink for a new device */
 struct mount_point *add_volume_mount_point( DEVICE_OBJECT *device, UNICODE_STRING *device_name,
-                                            int drive, const void *id, unsigned int id_len )
+                                            const GUID *guid, const void *id, unsigned int id_len )
 {
     static const WCHAR volumeW[] = {'\\','?','?','\\','V','o','l','u','m','e','{',
                                     '%','0','8','x','-','%','0','4','x','-','%','0','4','x','-',
                                     '%','0','2','x','%','0','2','x','-','%','0','2','x','%','0','2','x',
                                     '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x','}',0};
     WCHAR link[sizeof(volumeW)];
-    GUID guid;
 
-    memset( &guid, 0, sizeof(guid) );  /* FIXME */
-    guid.Data4[7] = 'A' + drive;
-    sprintfW( link, volumeW, guid.Data1, guid.Data2, guid.Data3,
-              guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
-              guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
+    sprintfW( link, volumeW, guid->Data1, guid->Data2, guid->Data3,
+              guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
+              guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
     return add_mount_point( device, device_name, link, id, id_len );
 }
 
@@ -266,7 +263,7 @@ static NTSTATUS define_unix_drive( const void *in_buff, SIZE_T insize )
         case DRIVE_RAMDISK:   type = DEVICE_RAMDISK; break;
         case DRIVE_FIXED:     type = DEVICE_HARDDISK_VOL; break;
         }
-        return add_dos_device( letter - 'a', NULL, device, mount_point, type );
+        return add_dos_device( letter - 'a', NULL, device, mount_point, type, NULL );
     }
     else
     {
diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h
index e8f7d5d..5ce5886 100644
--- a/dlls/mountmgr.sys/mountmgr.h
+++ b/dlls/mountmgr.sys/mountmgr.h
@@ -52,7 +52,7 @@ enum device_type
 };
 
 extern NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
-                                const char *mount_point, enum device_type type );
+                                const char *mount_point, enum device_type type, const GUID *guid );
 extern NTSTATUS remove_dos_device( int letter, const char *udi );
 extern NTSTATUS query_dos_device( int letter, enum device_type *type,
                                   const char **device, const char **mount_point );
@@ -65,6 +65,6 @@ struct mount_point;
 extern struct mount_point *add_dosdev_mount_point( DEVICE_OBJECT *device, UNICODE_STRING *device_name,
                                                    int drive, const void *id, unsigned int id_len );
 extern struct mount_point *add_volume_mount_point( DEVICE_OBJECT *device, UNICODE_STRING *device_name,
-                                                   int drive, const void *id, unsigned int id_len );
+                                                   const GUID *guid, const void *id, unsigned int id_len );
 extern void delete_mount_point( struct mount_point *mount );
 extern void set_mount_point_id( struct mount_point *mount, const void *id, unsigned int id_len );




More information about the wine-cvs mailing list