Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/mountmgr.sys/device.c | 60 ++++++++++++++++++++++++++++-------- dlls/mountmgr.sys/mountmgr.c | 14 +++++++-- dlls/mountmgr.sys/mountmgr.h | 2 ++ include/ddk/mountmgr.h | 1 + 4 files changed, 63 insertions(+), 14 deletions(-)
diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c index 89171363367..5aac45c6508 100644 --- a/dlls/mountmgr.sys/device.c +++ b/dlls/mountmgr.sys/device.c @@ -30,6 +30,11 @@ #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif +#ifdef MAJOR_IN_MKDEV +# include <sys/mkdev.h> +#elif defined(MAJOR_IN_SYSMACROS) +# include <sys/sysmacros.h> +#endif
#define NONAMELESSUNION
@@ -1617,6 +1622,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 +1648,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( unsigned int major, unsigned int minor, 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 != makedev( major, minor )) + 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 be72b0540d0..1ba66de7cbc 100644 --- a/dlls/mountmgr.sys/mountmgr.c +++ b/dlls/mountmgr.sys/mountmgr.c @@ -291,9 +291,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->major, input->minor, &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 26901499ac3..15893592976 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( unsigned int major, unsigned int minor, 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 8ddf1582a67..4271333204e 100644 --- a/include/ddk/mountmgr.h +++ b/include/ddk/mountmgr.h @@ -66,6 +66,7 @@ struct mountmgr_unix_drive ULONG size; ULONG type; ULONG fs_type; + ULONG major, minor; WCHAR letter; USHORT mount_point_offset; USHORT device_offset;