[PATCH] ntdll: Implement NtQueryVolumeInformationFile FileFsFullSizeInformation.

Michal Suchanek msuchanek at suse.de
Sat Jun 18 03:54:37 CDT 2022


Some programs refuse to write to disk when they cannot determine there
is enough disk space. Implement the ntdll subfunction for it.

Signed-off-by: Michal Suchanek <msuchanek at suse.de>
---
 dlls/ntdll/tests/file.c |  8 +-------
 dlls/ntdll/unix/file.c  | 24 ++++++++++++++++++++++--
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 106413a83fc..ede578081fc 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -1289,7 +1289,7 @@ static void test_file_full_size_information(void)
 
     /* Assume No Quota Settings configured on Wine Testbot */
     res = pNtQueryVolumeInformationFile(h, &io, &ffsi, sizeof ffsi, FileFsFullSizeInformation);
-    todo_wine ok(res == STATUS_SUCCESS, "cannot get attributes, res %lx\n", res);
+    ok(res == STATUS_SUCCESS, "cannot get attributes, res %lx\n", res);
     res = pNtQueryVolumeInformationFile(h, &io, &fsi, sizeof fsi, FileFsSizeInformation);
     ok(res == STATUS_SUCCESS, "cannot get attributes, res %lx\n", res);
 
@@ -1305,8 +1305,6 @@ static void test_file_full_size_information(void)
     ok(fsi.BytesPerSector == 512, "[fsi] BytesPerSector expected 512, got %ld\n",fsi.BytesPerSector);
     ok(fsi.SectorsPerAllocationUnit == 8, "[fsi] SectorsPerAllocationUnit expected 8, got %ld\n",fsi.SectorsPerAllocationUnit);
 
-    todo_wine
-    {
     ok(ffsi.TotalAllocationUnits.QuadPart > 0,
         "[ffsi] TotalAllocationUnits expected positive, got negative value 0x%s\n",
         wine_dbgstr_longlong(ffsi.TotalAllocationUnits.QuadPart));
@@ -1324,14 +1322,10 @@ static void test_file_full_size_information(void)
         "[ffsi] CallerAvailableAllocationUnits error fsi:0x%s, ffsi: 0x%s\n",
         wine_dbgstr_longlong(fsi.AvailableAllocationUnits.QuadPart),
         wine_dbgstr_longlong(ffsi.CallerAvailableAllocationUnits.QuadPart));
-    }
 
     /* Assume file system is NTFS */
-    todo_wine
-    {
     ok(ffsi.BytesPerSector == 512, "[ffsi] BytesPerSector expected 512, got %ld\n",ffsi.BytesPerSector);
     ok(ffsi.SectorsPerAllocationUnit == 8, "[ffsi] SectorsPerAllocationUnit expected 8, got %ld\n",ffsi.SectorsPerAllocationUnit);
-    }
 
     CloseHandle( h );
 }
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index cc8bf0c6e82..c2586ca39d8 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -6630,9 +6630,29 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, IO_STATUS_BLOCK *io
         break;
 
     case FileFsFullSizeInformation:
-        FIXME( "%p: full size info not supported\n", handle );
-        status = STATUS_NOT_IMPLEMENTED;
+    {
+        FILE_FS_FULL_SIZE_INFORMATION *info = buffer;
+        struct statfs stfs;
+        unsigned long sector_size = 512;
+
+        if (length < sizeof(FILE_FS_FULL_SIZE_INFORMATION))
+        {
+            status = STATUS_INFO_LENGTH_MISMATCH;
+            break;
+        }
+
+        status = STATUS_UNSUCCESSFUL;
+        if (!fstatfs( fd, &stfs ))
+        {
+            info->TotalAllocationUnits.QuadPart = stfs.f_blocks;
+            info->CallerAvailableAllocationUnits.QuadPart = stfs.f_bavail;
+            info->ActualAvailableAllocationUnits.QuadPart = stfs.f_bfree;
+            info->SectorsPerAllocationUnit = stfs.f_bsize / sector_size;
+            info->BytesPerSector = sector_size;
+            status = STATUS_SUCCESS;
+        }
         break;
+    }
 
     case FileFsObjectIdInformation:
         FIXME( "%p: object id info not supported\n", handle );
-- 
2.36.1




More information about the wine-devel mailing list