mountmgr: Add a Wine-specific ioctl to define a drive for a Unix path.

This commit is contained in:
Alexandre Julliard 2008-10-23 15:48:08 +02:00
parent b2ebab9f6f
commit 8faceff2f9
3 changed files with 66 additions and 0 deletions

View File

@ -223,6 +223,48 @@ static NTSTATUS query_mount_points( const void *in_buff, SIZE_T insize,
return STATUS_SUCCESS;
}
/* implementation of IOCTL_MOUNTMGR_DEFINE_UNIX_DRIVE */
static NTSTATUS define_unix_drive( const void *in_buff, SIZE_T insize )
{
const struct mountmgr_unix_drive *input = in_buff;
const char *mount_point = NULL, *device = NULL;
unsigned int i;
WCHAR letter = tolowerW( input->letter );
if (letter < 'a' || letter > 'z') return STATUS_INVALID_PARAMETER;
if (input->type > DRIVE_RAMDISK) return STATUS_INVALID_PARAMETER;
if (input->mount_point_offset > insize || input->device_offset > insize)
return STATUS_INVALID_PARAMETER;
/* make sure string are null-terminated */
if (input->mount_point_offset)
{
mount_point = (const char *)in_buff + input->mount_point_offset;
for (i = input->mount_point_offset; i < insize; i++)
if (!*((const char *)in_buff + i)) break;
if (i >= insize) return STATUS_INVALID_PARAMETER;
}
if (input->device_offset)
{
device = (const char *)in_buff + input->device_offset;
for (i = input->device_offset; i < insize; i++)
if (!*((const char *)in_buff + i)) break;
if (i >= insize) return STATUS_INVALID_PARAMETER;
}
if (input->type != DRIVE_NO_ROOT_DIR)
{
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 );
}
else
{
TRACE( "removing %c:\n", letter );
return remove_dos_device( letter - 'a', NULL );
}
}
/* handler for ioctls on the mount manager device */
static NTSTATUS WINAPI mountmgr_ioctl( DEVICE_OBJECT *device, IRP *irp )
{
@ -244,6 +286,13 @@ static NTSTATUS WINAPI mountmgr_ioctl( DEVICE_OBJECT *device, IRP *irp )
irpsp->Parameters.DeviceIoControl.OutputBufferLength,
&irp->IoStatus );
break;
case IOCTL_MOUNTMGR_DEFINE_UNIX_DRIVE:
if (irpsp->Parameters.DeviceIoControl.InputBufferLength < sizeof(struct mountmgr_unix_drive))
return STATUS_INVALID_PARAMETER;
irp->IoStatus.Information = 0;
irp->IoStatus.u.Status = define_unix_drive( irpsp->Parameters.DeviceIoControl.Type3InputBuffer,
irpsp->Parameters.DeviceIoControl.InputBufferLength );
break;
default:
FIXME( "ioctl %x not supported\n", irpsp->Parameters.DeviceIoControl.IoControlCode );
irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;

View File

@ -32,6 +32,7 @@
#include "ntddstor.h"
#include "ntddcdrm.h"
#include "ddk/wdm.h"
#define WINE_MOUNTMGR_EXTENSIONS
#include "ddk/mountmgr.h"
extern void initialize_hal(void);

View File

@ -49,6 +49,22 @@ static const WCHAR MOUNTMGR_DOS_DEVICE_NAME[] = {'\\','\\','.','\\','M','o','u',
#define IOCTL_MOUNTMGR_CHECK_UNPROCESSED_VOLUMES CTL_CODE(MOUNTMGRCONTROLTYPE, 10, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION CTL_CODE(MOUNTMGRCONTROLTYPE, 11, METHOD_BUFFERED, FILE_READ_ACCESS)
/* Wine extensions */
#ifdef WINE_MOUNTMGR_EXTENSIONS
#define IOCTL_MOUNTMGR_DEFINE_UNIX_DRIVE CTL_CODE(MOUNTMGRCONTROLTYPE, 32, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
struct mountmgr_unix_drive
{
ULONG size;
ULONG type;
WCHAR letter;
USHORT mount_point_offset;
USHORT device_offset;
};
#endif
typedef struct _MOUNTMGR_CREATE_POINT_INPUT
{
USHORT SymbolicLinkNameOffset;