Commit 6880b4d1 authored by Alexandre Julliard's avatar Alexandre Julliard

mountmgr: Use set_volume_info to update the volume when creating a new drive.

parent e38aff41
...@@ -427,24 +427,14 @@ static NTSTATUS set_volume_info( struct volume *volume, struct dos_drive *drive, ...@@ -427,24 +427,14 @@ static NTSTATUS set_volume_info( struct volume *volume, struct dos_drive *drive,
/* set or change the drive letter for an existing drive */ /* set or change the drive letter for an existing drive */
static void set_drive_letter( struct dos_drive *drive, int letter ) static void set_drive_letter( struct dos_drive *drive, int letter )
{ {
void *id = NULL;
unsigned int id_len = 0;
struct volume *volume = drive->volume; struct volume *volume = drive->volume;
struct disk_device *device = volume->device;
if (drive->drive == letter) return; if (drive->drive == letter) return;
if (drive->mount) delete_mount_point( drive->mount ); if (drive->mount) delete_mount_point( drive->mount );
if (volume->mount) delete_mount_point( volume->mount ); if (volume->mount) delete_mount_point( volume->mount );
drive->drive = letter; drive->drive = letter;
drive->mount = add_dosdev_mount_point( device->dev_obj, &device->name, letter ); drive->mount = NULL;
volume->mount = add_volume_mount_point( device->dev_obj, &device->name, &volume->guid ); volume->mount = NULL;
if (device->unix_mount)
{
id = device->unix_mount;
id_len = strlen( device->unix_mount ) + 1;
}
if (drive->mount) set_mount_point_id( drive->mount, id, id_len );
if (volume->mount) set_mount_point_id( volume->mount, id, id_len );
} }
static inline int is_valid_device( struct stat *st ) static inline int is_valid_device( struct stat *st )
...@@ -531,34 +521,6 @@ done: ...@@ -531,34 +521,6 @@ done:
return drive; return drive;
} }
static void set_unix_mount_point( struct dos_drive *drive, const char *mount_point )
{
char *path, *p;
struct volume *volume = drive->volume;
struct disk_device *device = volume->device;
if (!(path = get_dosdevices_path( &p ))) return;
p[0] = 'a' + drive->drive;
p[2] = 0;
update_symlink( path, mount_point, device->unix_mount );
RtlFreeHeap( GetProcessHeap(), 0, device->unix_mount );
device->unix_mount = strdupA( mount_point );
if (mount_point && mount_point[0])
{
if (drive->mount) set_mount_point_id( drive->mount, mount_point, strlen(mount_point) + 1 );
if (volume->mount) set_mount_point_id( volume->mount, mount_point, strlen(mount_point) + 1 );
}
else
{
if (drive->mount) set_mount_point_id( drive->mount, NULL, 0 );
if (volume->mount) set_mount_point_id( volume->mount, NULL, 0 );
}
HeapFree( GetProcessHeap(), 0, path );
}
/* create devices for mapped drives */ /* create devices for mapped drives */
static void create_drive_devices(void) static void create_drive_devices(void)
{ {
...@@ -653,18 +615,23 @@ NTSTATUS remove_volume( const char *udi ) ...@@ -653,18 +615,23 @@ NTSTATUS remove_volume( const char *udi )
NTSTATUS add_dos_device( int letter, const char *udi, const char *device, NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
const char *mount_point, enum device_type type, const GUID *guid ) const char *mount_point, enum device_type type, const GUID *guid )
{ {
char *path, *p;
NTSTATUS status = STATUS_SUCCESS;
struct dos_drive *drive, *next; struct dos_drive *drive, *next;
if (!(path = get_dosdevices_path( &p ))) return STATUS_NO_MEMORY;
if (letter == -1) /* auto-assign a letter */ if (letter == -1) /* auto-assign a letter */
{ {
letter = add_drive( device, type ); letter = add_drive( device, type );
if (letter == -1) return STATUS_OBJECT_NAME_COLLISION; if (letter == -1)
{
status = STATUS_OBJECT_NAME_COLLISION;
goto done;
}
} }
else /* simply reset the device symlink */ else /* simply reset the device symlink */
{ {
char *path, *p;
if (!(path = get_dosdevices_path( &p ))) return STATUS_NO_MEMORY;
*p = 'a' + letter; *p = 'a' + letter;
update_symlink( path, device, NULL ); update_symlink( path, device, NULL );
} }
...@@ -680,15 +647,15 @@ NTSTATUS add_dos_device( int letter, const char *udi, const char *device, ...@@ -680,15 +647,15 @@ NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
if (drive->drive == letter) delete_dos_device( drive ); if (drive->drive == letter) delete_dos_device( drive );
} }
if (create_dos_device( udi, type, &drive )) return STATUS_NO_MEMORY; if ((status = create_dos_device( udi, type, &drive ))) goto done;
found: found:
if (!guid) guid = get_default_uuid( letter ); if (!guid) guid = get_default_uuid( letter );
drive->volume->guid = *guid; p[0] = 'a' + drive->drive;
RtlFreeHeap( GetProcessHeap(), 0, drive->volume->device->unix_device ); p[2] = 0;
drive->volume->device->unix_device = strdupA( device ); update_symlink( path, mount_point, drive->volume->device->unix_mount );
set_drive_letter( drive, letter ); set_drive_letter( drive, letter );
set_unix_mount_point( drive, mount_point ); set_volume_info( drive->volume, drive, device, mount_point, type, guid );
if (drive->drive != -1) if (drive->drive != -1)
{ {
...@@ -716,7 +683,9 @@ found: ...@@ -716,7 +683,9 @@ found:
if (udi) send_notify( drive->drive, DBT_DEVICEARRIVAL ); if (udi) send_notify( drive->drive, DBT_DEVICEARRIVAL );
} }
return STATUS_SUCCESS; done:
RtlFreeHeap( GetProcessHeap(), 0, path );
return status;
} }
/* remove an existing dos drive, by letter or udi */ /* remove an existing dos drive, by letter or udi */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment