From 652ee6e2952724cce9c9832f5b52697f156fe7aa Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 29 Oct 2008 13:56:55 -0700 Subject: [PATCH] mountmgr: Differentiate between removable floppies and disks. --- dlls/mountmgr.sys/device.c | 16 ++++++++-------- dlls/mountmgr.sys/diskarb.c | 2 +- dlls/mountmgr.sys/hal.c | 2 +- dlls/mountmgr.sys/mountmgr.c | 2 +- dlls/mountmgr.sys/mountmgr.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c index 00b59ed..5ef4473 100644 --- a/dlls/mountmgr.sys/device.c +++ b/dlls/mountmgr.sys/device.c @@ -143,7 +143,7 @@ static void send_notify( int drive, int code ) } /* create the disk device for a given drive */ -static NTSTATUS create_disk_device( const char *udi, DWORD type, struct dos_drive **drive_ret ) +static NTSTATUS create_disk_device( const char *udi, DWORD type, struct dos_drive **drive_ret, BOOL floppy ) { static const WCHAR harddiskvolW[] = {'\\','D','e','v','i','c','e', '\\','H','a','r','d','d','i','s','k','V','o','l','u','m','e','%','u',0}; @@ -307,7 +307,7 @@ static inline int is_valid_device( struct stat *st ) } /* find or create a DOS drive for the corresponding device */ -static int add_drive( const char *device, DWORD type ) +static int add_drive( const char *device, DWORD type, BOOL floppy ) { char *path, *p; char in_use[26]; @@ -322,7 +322,7 @@ static int add_drive( const char *device, DWORD type ) first = 2; last = 26; - if (type == DRIVE_REMOVABLE) + if (floppy) { first = 0; last = 2; @@ -448,7 +448,7 @@ static void create_drive_devices(void) } } - if (!create_disk_device( NULL, drive_type, &drive )) + if (!create_disk_device( NULL, drive_type, &drive, (i < 2) )) { drive->unix_mount = link; drive->unix_device = device; @@ -466,13 +466,13 @@ 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, DWORD type ) + const char *mount_point, DWORD type, BOOL floppy ) { struct dos_drive *drive, *next; if (letter == -1) /* auto-assign a letter */ { - letter = add_drive( device, type ); + letter = add_drive( device, type, floppy ); if (letter == -1) return STATUS_OBJECT_NAME_COLLISION; } else /* simply reset the device symlink */ @@ -496,7 +496,7 @@ NTSTATUS add_dos_device( int letter, const char *udi, const char *device, if (drive->drive == letter) delete_disk_device( drive ); } - if (create_disk_device( udi, type, &drive )) return STATUS_NO_MEMORY; + if (create_disk_device( udi, type, &drive, floppy )) return STATUS_NO_MEMORY; found: RtlFreeHeap( GetProcessHeap(), 0, drive->unix_device ); @@ -641,7 +641,7 @@ NTSTATUS WINAPI harddisk_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *pa driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = harddisk_ioctl; /* create a harddisk0 device that isn't assigned to any drive */ - create_disk_device( "harddisk0 placeholder", DRIVE_FIXED, &drive ); + create_disk_device( "harddisk0 placeholder", DRIVE_FIXED, &drive, FALSE ); create_drive_devices(); diff --git a/dlls/mountmgr.sys/diskarb.c b/dlls/mountmgr.sys/diskarb.c index a469ee6..9cc62f3 100644 --- a/dlls/mountmgr.sys/diskarb.c +++ b/dlls/mountmgr.sys/diskarb.c @@ -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, FALSE ); done: CFRelease( dict ); } diff --git a/dlls/mountmgr.sys/hal.c b/dlls/mountmgr.sys/hal.c index e1d3da1..64f224a 100644 --- a/dlls/mountmgr.sys/hal.c +++ b/dlls/mountmgr.sys/hal.c @@ -135,7 +135,7 @@ static void new_device( LibHalContext *ctx, const char *udi ) if (type && !strcmp( type, "cdrom" )) drive_type = DRIVE_CDROM; else drive_type = DRIVE_REMOVABLE; /* FIXME: default to removable */ - add_dos_device( -1, udi, device, mount_point, drive_type ); + add_dos_device( -1, udi, device, mount_point, drive_type, !strcmp( type, "floppy" ) ); /* add property watch for mount point */ p_libhal_device_add_property_watch( ctx, udi, &error ); diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c index 3c1aa88..6755c17 100644 --- a/dlls/mountmgr.sys/mountmgr.c +++ b/dlls/mountmgr.sys/mountmgr.c @@ -256,7 +256,7 @@ static NTSTATUS define_unix_drive( const void *in_buff, SIZE_T insize ) { TRACE( "defining %c: dev %s mount %s type %u\n", letter, debugstr_a(device), debugstr_a(mount_point), input->type ); - return add_dos_device( letter - 'a', NULL, device, mount_point, input->type ); + return add_dos_device( letter - 'a', NULL, device, mount_point, input->type, FALSE ); } else { diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h index 63e9b75..85bc79c 100644 --- a/dlls/mountmgr.sys/mountmgr.h +++ b/dlls/mountmgr.sys/mountmgr.h @@ -41,7 +41,7 @@ extern void initialize_diskarbitration(void); /* device functions */ extern NTSTATUS add_dos_device( int letter, const char *udi, const char *device, - const char *mount_point, DWORD type ); + const char *mount_point, DWORD type, BOOL floppy ); extern NTSTATUS remove_dos_device( int letter, const char *udi ); extern NTSTATUS query_dos_device( int letter, DWORD *type, const char **device, const char **mount_point ); extern NTSTATUS WINAPI harddisk_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ); -- 1.5.4.5