Zebediah Figura : ntdll: Implement NtQueryVolumeInformationFile(FileFsVolumeInformation).

Alexandre Julliard julliard at winehq.org
Mon Apr 6 15:53:21 CDT 2020


Module: wine
Branch: master
Commit: 021d9f07602da5d61a27f86c86f6a06a38ee2e58
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=021d9f07602da5d61a27f86c86f6a06a38ee2e58

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Fri Mar 27 10:32:33 2020 -0500

ntdll: Implement NtQueryVolumeInformationFile(FileFsVolumeInformation).

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 71343c25be..1adc1e094e 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 546795456a..33b8ead552 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));




More information about the wine-cvs mailing list