Zebediah Figura : mountmgr: Allow querying a Unix device by device ID.
Alexandre Julliard
julliard at winehq.org
Mon Apr 6 15:53:21 CDT 2020
Module: wine
Branch: master
Commit: 54f93b9bb90c92d57abbefbb524bcd4e87465a52
URL: https://source.winehq.org/git/wine.git/?a=commit;h=54f93b9bb90c92d57abbefbb524bcd4e87465a52
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Fri Mar 27 10:32:30 2020 -0500
mountmgr: Allow querying a Unix device by device ID.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mountmgr.sys/device.c | 55 ++++++++++++++++++++++++++++++++++----------
dlls/mountmgr.sys/mountmgr.c | 14 +++++++++--
dlls/mountmgr.sys/mountmgr.h | 2 ++
include/ddk/mountmgr.h | 13 ++++++-----
4 files changed, 64 insertions(+), 20 deletions(-)
diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 8917136336..9d287bd639 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -1617,6 +1617,18 @@ NTSTATUS remove_dos_device( int letter, const char *udi )
return status;
}
+enum mountmgr_fs_type get_mountmgr_fs_type(enum fs_type fs_type)
+{
+ switch (fs_type)
+ {
+ case FS_ISO9660: return MOUNTMGR_FS_TYPE_ISO9660;
+ case FS_UDF: return MOUNTMGR_FS_TYPE_UDF;
+ case FS_FAT1216: return MOUNTMGR_FS_TYPE_FAT;
+ case FS_FAT32: return MOUNTMGR_FS_TYPE_FAT32;
+ default: return MOUNTMGR_FS_TYPE_NTFS;
+ }
+}
+
/* 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 )
@@ -1631,18 +1643,37 @@ NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_
if (drive->drive != letter) continue;
disk_device = drive->volume->device;
if (type) *type = disk_device->type;
- if (fs_type)
- {
- switch (drive->volume->fs_type)
- {
- case FS_ISO9660: *fs_type = MOUNTMGR_FS_TYPE_ISO9660; break;
- case FS_UDF: *fs_type = MOUNTMGR_FS_TYPE_UDF; break;
- case FS_FAT1216: *fs_type = MOUNTMGR_FS_TYPE_FAT; break;
- case FS_FAT32: *fs_type = MOUNTMGR_FS_TYPE_FAT32; break;
- default: *fs_type = MOUNTMGR_FS_TYPE_NTFS; break;
- }
- *fs_type = drive->volume->fs_type;
- }
+ if (fs_type) *fs_type = get_mountmgr_fs_type( drive->volume->fs_type );
+ if (device) *device = strdupA( disk_device->unix_device );
+ if (mount_point) *mount_point = strdupA( disk_device->unix_mount );
+ status = STATUS_SUCCESS;
+ break;
+ }
+ LeaveCriticalSection( &device_section );
+ return status;
+}
+
+/* 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 )
+{
+ NTSTATUS status = STATUS_NO_SUCH_DEVICE;
+ struct volume *volume;
+ struct disk_device *disk_device;
+ struct stat st;
+
+ EnterCriticalSection( &device_section );
+ LIST_FOR_EACH_ENTRY( volume, &volumes_list, struct volume, entry )
+ {
+ disk_device = volume->device;
+
+ if (!disk_device->unix_device
+ || stat( disk_device->unix_device, &st ) < 0
+ || st.st_rdev != unix_dev)
+ continue;
+
+ if (type) *type = disk_device->type;
+ if (fs_type) *fs_type = get_mountmgr_fs_type( volume->fs_type );
if (device) *device = strdupA( disk_device->unix_device );
if (mount_point) *mount_point = strdupA( disk_device->unix_mount );
status = STATUS_SUCCESS;
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
index 3a1b20af37..791b0b722d 100644
--- a/dlls/mountmgr.sys/mountmgr.c
+++ b/dlls/mountmgr.sys/mountmgr.c
@@ -299,9 +299,19 @@ static NTSTATUS query_unix_drive( void *buff, SIZE_T insize,
enum device_type device_type;
char *ptr;
- if (letter < 'a' || letter > 'z') return STATUS_INVALID_PARAMETER;
+ if (!letter)
+ {
+ if ((status = query_unix_device( input->unix_dev, &device_type,
+ &fs_type, &device, &mount_point )))
+ 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, &device, &mount_point ))) return status;
switch (device_type)
{
case DEVICE_UNKNOWN: type = DRIVE_UNKNOWN; break;
diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h
index 26901499ac..7171a50a41 100644
--- a/dlls/mountmgr.sys/mountmgr.h
+++ b/dlls/mountmgr.sys/mountmgr.h
@@ -59,6 +59,8 @@ extern NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
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_unix_device( ULONGLONG unix_dev, enum device_type *type,
+ enum mountmgr_fs_type *fs_type, char **device, char **mount_point ) 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;
diff --git a/include/ddk/mountmgr.h b/include/ddk/mountmgr.h
index b28d6b17de..5d382a1869 100644
--- a/include/ddk/mountmgr.h
+++ b/include/ddk/mountmgr.h
@@ -63,12 +63,13 @@ enum mountmgr_fs_type
struct mountmgr_unix_drive
{
- ULONG size;
- ULONG type;
- ULONG fs_type;
- WCHAR letter;
- USHORT mount_point_offset;
- USHORT device_offset;
+ ULONG size;
+ ULONG type;
+ ULONG fs_type;
+ ULONGLONG unix_dev;
+ WCHAR letter;
+ USHORT mount_point_offset;
+ USHORT device_offset;
};
#define IOCTL_MOUNTMGR_QUERY_DHCP_REQUEST_PARAMS CTL_CODE(MOUNTMGRCONTROLTYPE, 64, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
More information about the wine-cvs
mailing list