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

This commit is contained in:
Alexandre Julliard 2009-07-20 16:05:04 +02:00
parent bc8dce2004
commit 84396c2e62
5 changed files with 23 additions and 14 deletions

View File

@ -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 );

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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
{

View File

@ -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 );