kernel32: Use the NT name to open the device in GetVolumeInformationW.

This commit is contained in:
Alexandre Julliard 2010-10-20 12:23:00 +02:00
parent ee0f0da69b
commit 732534f954
2 changed files with 20 additions and 7 deletions

View File

@ -458,7 +458,7 @@ static void test_GetVolumeInformationA(void)
/* try again with unique volume name */ /* try again with unique volume name */
ret = pGetVolumeInformationA(volume, vol_name_buf, vol_name_size, ret = pGetVolumeInformationA(volume, vol_name_buf, vol_name_size,
&vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len); &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
todo_wine ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume, GetLastError()); ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume, GetLastError());
} }
/* Test to check that unique volume name from windows dir mount point */ /* Test to check that unique volume name from windows dir mount point */

View File

@ -517,7 +517,10 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len,
WCHAR device[] = {'\\','\\','.','\\','A',':',0}; WCHAR device[] = {'\\','\\','.','\\','A',':',0};
HANDLE handle; HANDLE handle;
NTSTATUS status;
UNICODE_STRING nt_name; UNICODE_STRING nt_name;
IO_STATUS_BLOCK io;
OBJECT_ATTRIBUTES attr;
WCHAR *p; WCHAR *p;
enum fs_type type = FS_UNKNOWN; enum fs_type type = FS_UNKNOWN;
BOOL ret = FALSE; BOOL ret = FALSE;
@ -539,9 +542,19 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len,
/* try to open the device */ /* try to open the device */
handle = CreateFileW( device, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, attr.Length = sizeof(attr);
NULL, OPEN_EXISTING, 0, 0 ); attr.RootDirectory = 0;
if (handle != INVALID_HANDLE_VALUE) attr.Attributes = OBJ_CASE_INSENSITIVE;
attr.ObjectName = &nt_name;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
nt_name.Length -= sizeof(WCHAR); /* without trailing slash */
status = NtOpenFile( &handle, GENERIC_READ, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
nt_name.Length += sizeof(WCHAR);
if (status == STATUS_SUCCESS)
{ {
BYTE superblock[SUPERBLOCK_SIZE]; BYTE superblock[SUPERBLOCK_SIZE];
CDROM_TOC toc; CDROM_TOC toc;
@ -553,7 +566,7 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len,
{ {
if (!(toc.TrackData[0].Control & 0x04)) /* audio track */ if (!(toc.TrackData[0].Control & 0x04)) /* audio track */
{ {
TRACE( "%s: found audio CD\n", debugstr_w(device) ); TRACE( "%s: found audio CD\n", debugstr_w(nt_name.Buffer) );
if (label) lstrcpynW( label, audiocdW, label_len ); if (label) lstrcpynW( label, audiocdW, label_len );
if (serial) *serial = VOLUME_GetAudioCDSerial( &toc ); if (serial) *serial = VOLUME_GetAudioCDSerial( &toc );
CloseHandle( handle ); CloseHandle( handle );
@ -568,14 +581,14 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len,
if (type == FS_UNKNOWN) type = VOLUME_ReadCDSuperblock( handle, superblock ); if (type == FS_UNKNOWN) type = VOLUME_ReadCDSuperblock( handle, superblock );
} }
CloseHandle( handle ); CloseHandle( handle );
TRACE( "%s: found fs type %d\n", debugstr_w(device), type ); TRACE( "%s: found fs type %d\n", debugstr_w(nt_name.Buffer), type );
if (type == FS_ERROR) goto done; if (type == FS_ERROR) goto done;
if (label && label_len) VOLUME_GetSuperblockLabel( device, type, superblock, label, label_len ); if (label && label_len) VOLUME_GetSuperblockLabel( device, type, superblock, label, label_len );
if (serial) *serial = VOLUME_GetSuperblockSerial( device, type, superblock ); if (serial) *serial = VOLUME_GetSuperblockSerial( device, type, superblock );
goto fill_fs_info; goto fill_fs_info;
} }
else TRACE( "cannot open device %s: err %d\n", debugstr_w(device), GetLastError() ); else TRACE( "cannot open device %s: err %d\n", debugstr_w(nt_name.Buffer), GetLastError() );
/* we couldn't open the device, fallback to default strategy */ /* we couldn't open the device, fallback to default strategy */