mountmgr: Return the serial and label from IOCTL_MOUNTMGR_QUERY_UNIX_DRIVE.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-03-27 10:32:32 -05:00 committed by Alexandre Julliard
parent 18a960bb84
commit 19b8aadf4b
4 changed files with 40 additions and 9 deletions

View File

@ -152,6 +152,15 @@ static char *strdupA( const char *str )
return ret;
}
static WCHAR *strdupW( const WCHAR *str )
{
WCHAR *ret;
if (!str) return NULL;
if ((ret = RtlAllocateHeap( GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(WCHAR) ))) strcpyW( ret, str );
return ret;
}
static const GUID *get_default_uuid( int letter )
{
static GUID guid;
@ -1631,7 +1640,7 @@ enum mountmgr_fs_type get_mountmgr_fs_type(enum fs_type fs_type)
/* query information about an existing dos drive, by letter or udi */
NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_type *fs_type,
char **device, char **mount_point )
DWORD *serial, char **device, char **mount_point, WCHAR **label )
{
NTSTATUS status = STATUS_NO_SUCH_DEVICE;
struct dos_drive *drive;
@ -1644,8 +1653,10 @@ NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_
disk_device = drive->volume->device;
if (type) *type = disk_device->type;
if (fs_type) *fs_type = get_mountmgr_fs_type( drive->volume->fs_type );
if (serial) *serial = drive->volume->serial;
if (device) *device = strdupA( disk_device->unix_device );
if (mount_point) *mount_point = strdupA( disk_device->unix_mount );
if (label) *label = strdupW( drive->volume->label );
status = STATUS_SUCCESS;
break;
}
@ -1655,7 +1666,8 @@ NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_
/* query information about an existing unix device, by dev_t */
NTSTATUS query_unix_device( ULONGLONG unix_dev, enum device_type *type,
enum mountmgr_fs_type *fs_type, char **device, char **mount_point )
enum mountmgr_fs_type *fs_type, DWORD *serial, char **device,
char **mount_point, WCHAR **label )
{
NTSTATUS status = STATUS_NO_SUCH_DEVICE;
struct volume *volume;
@ -1674,8 +1686,10 @@ NTSTATUS query_unix_device( ULONGLONG unix_dev, enum device_type *type,
if (type) *type = disk_device->type;
if (fs_type) *fs_type = get_mountmgr_fs_type( volume->fs_type );
if (serial) *serial = volume->serial;
if (device) *device = strdupA( disk_device->unix_device );
if (mount_point) *mount_point = strdupA( disk_device->unix_mount );
if (label) *label = strdupW( volume->label );
status = STATUS_SUCCESS;
break;
}

View File

@ -294,22 +294,25 @@ static NTSTATUS query_unix_drive( void *buff, SIZE_T insize,
char *device, *mount_point;
int letter = tolowerW( input->letter );
NTSTATUS status;
DWORD size, type = DEVICE_UNKNOWN;
DWORD size, type = DEVICE_UNKNOWN, serial;
enum mountmgr_fs_type fs_type;
enum device_type device_type;
char *ptr;
WCHAR *label;
if (!letter)
{
if ((status = query_unix_device( input->unix_dev, &device_type,
&fs_type, &device, &mount_point )))
if ((status = query_unix_device( input->unix_dev, &device_type, &fs_type,
&serial, &device, &mount_point, &label )))
return status;
}
else
{
if (letter < 'a' || letter > 'z') return STATUS_INVALID_PARAMETER;
if ((status = query_dos_device( letter - 'a', &device_type, &fs_type, &device, &mount_point ))) return status;
if ((status = query_dos_device( letter - 'a', &device_type, &fs_type, &serial, &device,
&mount_point, &label )))
return status;
}
switch (device_type)
@ -334,8 +337,10 @@ static NTSTATUS query_unix_drive( void *buff, SIZE_T insize,
output->letter = letter;
output->type = type;
output->fs_type = fs_type;
output->serial = serial;
output->mount_point_offset = 0;
output->device_offset = 0;
output->label_offset = 0;
if (size > outsize)
{
@ -372,6 +377,14 @@ static NTSTATUS query_unix_drive( void *buff, SIZE_T insize,
}
else output->device_offset = 0;
if (label)
{
output->label_offset = ptr - (char *)output;
strcpyW( (WCHAR *)ptr, label );
ptr += (strlenW(label) + 1) * sizeof(WCHAR);
}
else output->label_offset = 0;
TRACE( "returning %c: dev %s mount %s type %u\n",
letter, debugstr_a(device), debugstr_a(mount_point), type );
@ -379,6 +392,7 @@ static NTSTATUS query_unix_drive( void *buff, SIZE_T insize,
done:
RtlFreeHeap( GetProcessHeap(), 0, device );
RtlFreeHeap( GetProcessHeap(), 0, mount_point );
RtlFreeHeap( GetProcessHeap(), 0, label );
return status;
}

View File

@ -57,10 +57,11 @@ extern NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
const char *mount_point, enum device_type type, const GUID *guid,
UNICODE_STRING *devname ) DECLSPEC_HIDDEN;
extern NTSTATUS remove_dos_device( int letter, const char *udi ) DECLSPEC_HIDDEN;
extern NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_type *fs_type,
char **device, char **mount_point ) DECLSPEC_HIDDEN;
extern NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_type *fs_type, DWORD *serial,
char **device, char **mount_point, WCHAR **label ) DECLSPEC_HIDDEN;
extern NTSTATUS query_unix_device( ULONGLONG unix_dev, enum device_type *type,
enum mountmgr_fs_type *fs_type, char **device, char **mount_point ) DECLSPEC_HIDDEN;
DWORD *serial, enum mountmgr_fs_type *fs_type, char **device,
char **mount_point, WCHAR **label ) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI harddisk_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI serial_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI parallel_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;

View File

@ -66,10 +66,12 @@ struct mountmgr_unix_drive
ULONG size;
ULONG type;
ULONG fs_type;
DWORD serial;
ULONGLONG unix_dev;
WCHAR letter;
USHORT mount_point_offset;
USHORT device_offset;
USHORT label_offset;
};
#define IOCTL_MOUNTMGR_QUERY_DHCP_REQUEST_PARAMS CTL_CODE(MOUNTMGRCONTROLTYPE, 64, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)