From 021d9f07602da5d61a27f86c86f6a06a38ee2e58 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 27 Mar 2020 10:32:33 -0500 Subject: [PATCH] ntdll: Implement NtQueryVolumeInformationFile(FileFsVolumeInformation). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/ntdll/file.c | 36 ++++++++++++++++++++++++++++++++---- dlls/ntdll/tests/file.c | 7 ++----- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 71343c25be2..1adc1e094ec 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -3262,7 +3262,6 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io { int fd, needs_close; struct stat st; - static int once; io->u.Status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ); if (io->u.Status == STATUS_BAD_DEVICE_TYPE) @@ -3285,9 +3284,6 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io switch( info_class ) { - case FileFsVolumeInformation: - if (!once++) FIXME( "%p: volume info not supported\n", handle ); - break; case FileFsLabelInformation: FIXME( "%p: label info not supported\n", handle ); break; @@ -3448,6 +3444,38 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io io->u.Status = STATUS_SUCCESS; break; } + case FileFsVolumeInformation: + { + FILE_FS_VOLUME_INFORMATION *info = buffer; + struct mountmgr_unix_drive *drive; + const WCHAR *label; + + if (length < sizeof(FILE_FS_VOLUME_INFORMATION)) + { + io->u.Status = STATUS_INFO_LENGTH_MISMATCH; + break; + } + + if (!(drive = get_mountmgr_fs_info( handle, fd ))) + { + ERR_(winediag)("Failed to query volume information from mountmgr.\n"); + io->u.Status = STATUS_NOT_IMPLEMENTED; + break; + } + + label = (WCHAR *)((char *)drive + drive->label_offset); + info->VolumeCreationTime.QuadPart = 0; /* FIXME */ + info->VolumeSerialNumber = drive->serial; + info->VolumeLabelLength = min( wcslen( label ) * sizeof(WCHAR), + length - offsetof( FILE_FS_VOLUME_INFORMATION, VolumeLabel ) ); + info->SupportsObjects = (drive->fs_type == MOUNTMGR_FS_TYPE_NTFS); + memcpy( info->VolumeLabel, label, info->VolumeLabelLength ); + RtlFreeHeap( GetProcessHeap(), 0, drive ); + + io->Information = offsetof( FILE_FS_VOLUME_INFORMATION, VolumeLabel ) + info->VolumeLabelLength; + io->u.Status = STATUS_SUCCESS; + break; + } case FileFsControlInformation: FIXME( "%p: control info not supported\n", handle ); break; diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 546795456a8..33b8ead5528 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -3900,8 +3900,6 @@ static void test_query_volume_information_file(void) ffvi = (FILE_FS_VOLUME_INFORMATION *)buf; -todo_wine -{ ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %d\n", status); ok(U(io).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %d\n", U(io).Status); @@ -3909,10 +3907,9 @@ todo_wine "expected %d, got %lu\n", (FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel) + ffvi->VolumeLabelLength), io.Information); - ok(ffvi->VolumeCreationTime.QuadPart != 0, "Missing VolumeCreationTime\n"); - ok(ffvi->VolumeSerialNumber != 0, "Missing VolumeSerialNumber\n"); + todo_wine ok(ffvi->VolumeCreationTime.QuadPart != 0, "Missing VolumeCreationTime\n"); + todo_wine ok(ffvi->VolumeSerialNumber != 0, "Missing VolumeSerialNumber\n"); ok(ffvi->SupportsObjects == 1,"expected 1, got %d\n", ffvi->SupportsObjects); -} ok(ffvi->VolumeLabelLength == lstrlenW(ffvi->VolumeLabel) * sizeof(WCHAR), "got %d\n", ffvi->VolumeLabelLength); trace("VolumeSerialNumber: %x VolumeLabelName: %s\n", ffvi->VolumeSerialNumber, wine_dbgstr_w(ffvi->VolumeLabel));