Commit 3aa4feb5 authored by Alexandre Julliard's avatar Alexandre Julliard

mountmgr: Use wine_get_dos_file_name() instead of wine_unix_to_nt_file_name().

parent f8699c0a
...@@ -1017,32 +1017,26 @@ static struct volume *find_matching_volume( const char *udi, const char *device, ...@@ -1017,32 +1017,26 @@ static struct volume *find_matching_volume( const char *udi, const char *device,
static BOOL get_volume_device_info( struct volume *volume ) static BOOL get_volume_device_info( struct volume *volume )
{ {
const char *unix_device = volume->device->unix_device; const char *unix_device = volume->device->unix_device;
ANSI_STRING unix_name; WCHAR *name;
UNICODE_STRING nt_name;
OBJECT_ATTRIBUTES attr;
HANDLE handle; HANDLE handle;
NTSTATUS ret;
CDROM_TOC toc; CDROM_TOC toc;
DWORD size; DWORD size;
BYTE superblock[SUPERBLOCK_SIZE]; BYTE superblock[SUPERBLOCK_SIZE];
IO_STATUS_BLOCK io;
if (!unix_device) if (!unix_device)
return FALSE; return FALSE;
RtlInitAnsiString( &unix_name, unix_device ); if (!(name = wine_get_dos_file_name( unix_device )))
if ((ret = wine_unix_to_nt_file_name( &unix_name, &nt_name )))
{ {
ERR("Failed to convert %s to NT, status %#x\n", debugstr_a(unix_device), ret); ERR("Failed to convert %s to NT, err %u\n", debugstr_a(unix_device), GetLastError());
return FALSE; return FALSE;
} }
handle = CreateFileW( name, GENERIC_READ | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE,
InitializeObjectAttributes( &attr, &nt_name, OBJ_CASE_INSENSITIVE, 0, NULL ); NULL, OPEN_EXISTING, 0, 0 );
if ((ret = NtOpenFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE, RtlFreeHeap( GetProcessHeap(), 0, name );
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT ))) if (handle == INVALID_HANDLE_VALUE)
{ {
WARN("Failed to open %s, status %#x\n", debugstr_a(unix_device), ret); WARN("Failed to open %s, err %u\n", debugstr_a(unix_device), GetLastError());
RtlFreeUnicodeString( &nt_name );
return FALSE; return FALSE;
} }
......
...@@ -432,7 +432,7 @@ static void WINAPI query_symbol_file( TP_CALLBACK_INSTANCE *instance, void *cont ...@@ -432,7 +432,7 @@ static void WINAPI query_symbol_file( TP_CALLBACK_INSTANCE *instance, void *cont
IRP *irp = context; IRP *irp = context;
MOUNTMGR_TARGET_NAME *result; MOUNTMGR_TARGET_NAME *result;
CFStringRef query_cfstring; CFStringRef query_cfstring;
WCHAR *unix_buf = NULL; WCHAR *filename, *unix_buf = NULL;
ANSI_STRING unix_path; ANSI_STRING unix_path;
UNICODE_STRING path; UNICODE_STRING path;
MDQueryRef mdquery; MDQueryRef mdquery;
...@@ -489,16 +489,19 @@ static void WINAPI query_symbol_file( TP_CALLBACK_INSTANCE *instance, void *cont ...@@ -489,16 +489,19 @@ static void WINAPI query_symbol_file( TP_CALLBACK_INSTANCE *instance, void *cont
HeapFree( GetProcessHeap(), 0, unix_buf ); HeapFree( GetProcessHeap(), 0, unix_buf );
if (status) goto done; if (status) goto done;
status = wine_unix_to_nt_file_name( &unix_path, &path ); filename = wine_get_dos_file_name( unix_path.Buffer );
RtlFreeAnsiString( &unix_path ); RtlFreeAnsiString( &unix_path );
if (status) goto done; if (!filename)
{
status = STATUS_NO_SUCH_FILE;
goto done;
}
result = irp->AssociatedIrp.SystemBuffer; result = irp->AssociatedIrp.SystemBuffer;
result->DeviceNameLength = path.Length; result->DeviceNameLength = lstrlenW(filename) * sizeof(WCHAR);
size = FIELD_OFFSET(MOUNTMGR_TARGET_NAME, DeviceName[path.Length / sizeof(WCHAR)]); size = FIELD_OFFSET(MOUNTMGR_TARGET_NAME, DeviceName[lstrlenW(filename)]);
if (size <= IoGetCurrentIrpStackLocation(irp)->Parameters.DeviceIoControl.OutputBufferLength) if (size <= IoGetCurrentIrpStackLocation(irp)->Parameters.DeviceIoControl.OutputBufferLength)
{ {
memcpy( result->DeviceName, path.Buffer, path.Length ); memcpy( result->DeviceName, filename, lstrlenW(filename) * sizeof(WCHAR) );
irp->IoStatus.Information = size; irp->IoStatus.Information = size;
status = STATUS_SUCCESS; status = STATUS_SUCCESS;
} }
...@@ -507,7 +510,7 @@ static void WINAPI query_symbol_file( TP_CALLBACK_INSTANCE *instance, void *cont ...@@ -507,7 +510,7 @@ static void WINAPI query_symbol_file( TP_CALLBACK_INSTANCE *instance, void *cont
irp->IoStatus.Information = sizeof(*result); irp->IoStatus.Information = sizeof(*result);
status = STATUS_BUFFER_OVERFLOW; status = STATUS_BUFFER_OVERFLOW;
} }
RtlFreeUnicodeString( &path ); RtlFreeHeap( GetProcessHeap(), 0, filename );
done: done:
irp->IoStatus.u.Status = status; irp->IoStatus.u.Status = status;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment