https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f79ec61bdc43d8017ba40…
commit f79ec61bdc43d8017ba408aa817543bc65328c6c
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Jun 19 15:40:08 2022 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Jun 19 16:12:10 2022 +0200
[DISKPART] Print proper file system information for the FILESYSTEMS command
---
base/system/diskpart/diskpart.h | 1 +
base/system/diskpart/filesystems.c | 113 +++++++++++++++++++++++++++++++++++--
base/system/diskpart/lang/de-DE.rc | 3 +-
base/system/diskpart/lang/en-US.rc | 3 +-
base/system/diskpart/lang/pl-PL.rc | 3 +-
base/system/diskpart/lang/pt-PT.rc | 3 +-
base/system/diskpart/lang/ro-RO.rc | 3 +-
base/system/diskpart/lang/ru-RU.rc | 3 +-
base/system/diskpart/lang/sq-AL.rc | 3 +-
base/system/diskpart/lang/tr-TR.rc | 3 +-
base/system/diskpart/lang/zh-CN.rc | 3 +-
base/system/diskpart/lang/zh-TW.rc | 3 +-
base/system/diskpart/partlist.c | 9 ++-
base/system/diskpart/resource.h | 1 +
14 files changed, 133 insertions(+), 21 deletions(-)
diff --git a/base/system/diskpart/diskpart.h b/base/system/diskpart/diskpart.h
index aa0e557e4e3..fbfb978f537 100644
--- a/base/system/diskpart/diskpart.h
+++ b/base/system/diskpart/diskpart.h
@@ -190,6 +190,7 @@ typedef struct _VOLENTRY
ULONG VolumeNumber;
WCHAR VolumeName[MAX_PATH];
+ WCHAR DeviceName[MAX_PATH];
WCHAR DriveLetter;
diff --git a/base/system/diskpart/filesystems.c b/base/system/diskpart/filesystems.c
index 9257068746a..2a416693b4b 100644
--- a/base/system/diskpart/filesystems.c
+++ b/base/system/diskpart/filesystems.c
@@ -11,6 +11,104 @@
#define NDEBUG
#include <debug.h>
+static
+BOOL
+GetFileSystemInfo(
+ PVOLENTRY VolumeEntry)
+{
+ WCHAR VolumeNameBuffer[MAX_PATH];
+ UNICODE_STRING VolumeName;
+ HANDLE VolumeHandle;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK IoStatusBlock;
+ ULONG ulSize, ulClusterSize = 0;
+ FILE_FS_FULL_SIZE_INFORMATION SizeInfo;
+ FILE_FS_FULL_SIZE_INFORMATION FullSizeInfo;
+ PFILE_FS_ATTRIBUTE_INFORMATION pAttributeInfo = NULL;
+ NTSTATUS Status;
+
+ wcscpy(VolumeNameBuffer, VolumeEntry->DeviceName);
+ wcscat(VolumeNameBuffer, L"\\");
+
+ RtlInitUnicodeString(&VolumeName, VolumeNameBuffer);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &VolumeName,
+ 0,
+ NULL,
+ NULL);
+
+ Status = NtOpenFile(&VolumeHandle,
+ SYNCHRONIZE,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ 0,
+ FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT |
FILE_OPEN_FOR_BACKUP_INTENT);
+ if (!NT_SUCCESS(Status))
+ {
+ if (Status == STATUS_NO_MEDIA_IN_DEVICE)
+ {
+ ConResPuts(StdOut, IDS_ERROR_NO_MEDIUM);
+ return FALSE;
+ }
+ else if (Status == STATUS_UNRECOGNIZED_VOLUME)
+ {
+ ConResPuts(StdOut, IDS_FILESYSTEMS_CURRENT);
+ ConPuts(StdOut, L"\n");
+ ConResPrintf(StdOut, IDS_FILESYSTEMS_TYPE, L"RAW");
+ ConResPrintf(StdOut, IDS_FILESYSTEMS_CLUSTERSIZE, 512);
+ }
+
+ return TRUE;
+ }
+
+ ulSize = sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 255 * sizeof(WCHAR);
+ pAttributeInfo = RtlAllocateHeap(RtlGetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ ulSize);
+
+ Status = NtQueryVolumeInformationFile(VolumeHandle,
+ &IoStatusBlock,
+ pAttributeInfo,
+ ulSize,
+ FileFsAttributeInformation);
+
+ Status = NtQueryVolumeInformationFile(VolumeHandle,
+ &IoStatusBlock,
+ &FullSizeInfo,
+ sizeof(FILE_FS_FULL_SIZE_INFORMATION),
+ FileFsFullSizeInformation);
+ if (NT_SUCCESS(Status))
+ {
+ ulClusterSize = FullSizeInfo.BytesPerSector *
FullSizeInfo.SectorsPerAllocationUnit;
+ }
+ else
+ {
+ Status = NtQueryVolumeInformationFile(VolumeHandle,
+ &IoStatusBlock,
+ &SizeInfo,
+ sizeof(FILE_FS_SIZE_INFORMATION),
+ FileFsSizeInformation);
+ if (NT_SUCCESS(Status))
+ {
+ ulClusterSize = SizeInfo.BytesPerSector *
SizeInfo.SectorsPerAllocationUnit;
+ }
+ }
+
+
+ ConResPuts(StdOut, IDS_FILESYSTEMS_CURRENT);
+ ConPuts(StdOut, L"\n");
+
+ ConResPrintf(StdOut, IDS_FILESYSTEMS_TYPE, pAttributeInfo->FileSystemName);
+ ConResPrintf(StdOut, IDS_FILESYSTEMS_CLUSTERSIZE, ulClusterSize);
+
+ if (pAttributeInfo)
+ RtlFreeHeap(RtlGetProcessHeap(), 0, pAttributeInfo);
+
+ NtClose(VolumeHandle);
+
+ return TRUE;
+}
BOOL
filesystems_main(
@@ -24,13 +122,16 @@ filesystems_main(
}
ConPuts(StdOut, L"\n");
- ConResPuts(StdOut, IDS_FILESYSTEMS_CURRENT);
- ConPuts(StdOut, L"\n");
- ConResPrintf(StdOut, IDS_FILESYSTEMS_TYPE, (CurrentVolume->pszFilesystem == NULL)
? L"RAW" : CurrentVolume->pszFilesystem);
- ConResPrintf(StdOut, IDS_FILESYSTEMS_CLUSTERSIZE);
- ConPuts(StdOut, L"\n");
- ConResPuts(StdOut, IDS_FILESYSTEMS_FORMATTING);
+ if (GetFileSystemInfo(CurrentVolume))
+ {
+ ConPuts(StdOut, L"\n");
+ ConResPuts(StdOut, IDS_FILESYSTEMS_FORMATTING);
+
+ /* FIXME: List available file systems */
+
+ }
+
ConPuts(StdOut, L"\n");
return TRUE;
diff --git a/base/system/diskpart/lang/de-DE.rc b/base/system/diskpart/lang/de-DE.rc
index bf8345d9b6f..f66f0726f18 100644
--- a/base/system/diskpart/lang/de-DE.rc
+++ b/base/system/diskpart/lang/de-DE.rc
@@ -72,7 +72,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Aktuelles Dateisystem\n"
IDS_FILESYSTEMS_FORMATTING "Zur Formatierung unterstützte Dateisysteme\n"
IDS_FILESYSTEMS_TYPE "Typ : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Größe der Zuordnungseinheit: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Größe der Zuordnungseinheit: %lu\n"
END
STRINGTABLE
@@ -233,4 +233,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "Error opening script: %s\n"
IDS_ERROR_MSG_BAD_ARG "Error processing argument: %s\n"
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
+ IDS_ERROR_NO_MEDIUM "Es befindet sich kein Medium im Gerät.\n"
END
diff --git a/base/system/diskpart/lang/en-US.rc b/base/system/diskpart/lang/en-US.rc
index af0d2185b11..c3a00e406ec 100644
--- a/base/system/diskpart/lang/en-US.rc
+++ b/base/system/diskpart/lang/en-US.rc
@@ -72,7 +72,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Current Filesystem\n"
IDS_FILESYSTEMS_FORMATTING "Filesystems available for formatting\n"
IDS_FILESYSTEMS_TYPE "Type : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
END
STRINGTABLE
@@ -233,4 +233,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "Error opening script: %s\n"
IDS_ERROR_MSG_BAD_ARG "Error processing argument: %s\n"
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
+ IDS_ERROR_NO_MEDIUM "No medium in device.\n"
END
diff --git a/base/system/diskpart/lang/pl-PL.rc b/base/system/diskpart/lang/pl-PL.rc
index f71ad8e1173..d67404e7812 100644
--- a/base/system/diskpart/lang/pl-PL.rc
+++ b/base/system/diskpart/lang/pl-PL.rc
@@ -72,7 +72,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Current Filesystem\n"
IDS_FILESYSTEMS_FORMATTING "Filesystems available for formatting\n"
IDS_FILESYSTEMS_TYPE "Type : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
END
STRINGTABLE
@@ -233,4 +233,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "Błąd podczas otwierania skryptu: %s\n"
IDS_ERROR_MSG_BAD_ARG "Błąd przetwarzania argumentu: %s\n"
IDS_ERROR_INVALID_ARGS "Nieprawidłowe argumenty\n"
+ IDS_ERROR_NO_MEDIUM "No medium in device.\n"
END
diff --git a/base/system/diskpart/lang/pt-PT.rc b/base/system/diskpart/lang/pt-PT.rc
index a9d210aee03..5d0bfab3ad7 100644
--- a/base/system/diskpart/lang/pt-PT.rc
+++ b/base/system/diskpart/lang/pt-PT.rc
@@ -74,7 +74,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Current Filesystem\n"
IDS_FILESYSTEMS_FORMATTING "Filesystems available for formatting\n"
IDS_FILESYSTEMS_TYPE "Type : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
END
STRINGTABLE
@@ -235,4 +235,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "Erro ao abrir o script: %s\n"
IDS_ERROR_MSG_BAD_ARG "Erro ao processar o argumento: %s\n"
IDS_ERROR_INVALID_ARGS "Argumento inválido\n"
+ IDS_ERROR_NO_MEDIUM "No medium in device.\n"
END
diff --git a/base/system/diskpart/lang/ro-RO.rc b/base/system/diskpart/lang/ro-RO.rc
index 7bfd771a786..81dc6afce99 100644
--- a/base/system/diskpart/lang/ro-RO.rc
+++ b/base/system/diskpart/lang/ro-RO.rc
@@ -74,7 +74,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Current Filesystem\n"
IDS_FILESYSTEMS_FORMATTING "Filesystems available for formatting\n"
IDS_FILESYSTEMS_TYPE "Type : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
END
STRINGTABLE
@@ -235,4 +235,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "Eroare la deschiderea fișierului script: %s\n"
IDS_ERROR_MSG_BAD_ARG "Eroare la prelucrarea argumentului: %s\n"
IDS_ERROR_INVALID_ARGS "Argumente nevalide\n"
+ IDS_ERROR_NO_MEDIUM "No medium in device.\n"
END
diff --git a/base/system/diskpart/lang/ru-RU.rc b/base/system/diskpart/lang/ru-RU.rc
index 0dcb1fb3377..bf9f2182875 100644
--- a/base/system/diskpart/lang/ru-RU.rc
+++ b/base/system/diskpart/lang/ru-RU.rc
@@ -74,7 +74,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Current Filesystem\n"
IDS_FILESYSTEMS_FORMATTING "Filesystems available for formatting\n"
IDS_FILESYSTEMS_TYPE "Type : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
END
STRINGTABLE
@@ -235,4 +235,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "Ошибка открытия скрипта: %s\n"
IDS_ERROR_MSG_BAD_ARG "Ошибка обработки параметров: %s\n"
IDS_ERROR_INVALID_ARGS "Ошибка в указании параметров\n"
+ IDS_ERROR_NO_MEDIUM "No medium in device.\n"
END
diff --git a/base/system/diskpart/lang/sq-AL.rc b/base/system/diskpart/lang/sq-AL.rc
index 26ca5044578..6e1ac5af471 100644
--- a/base/system/diskpart/lang/sq-AL.rc
+++ b/base/system/diskpart/lang/sq-AL.rc
@@ -76,7 +76,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Current Filesystem\n"
IDS_FILESYSTEMS_FORMATTING "Filesystems available for formatting\n"
IDS_FILESYSTEMS_TYPE "Type : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
END
STRINGTABLE
@@ -237,4 +237,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "Error në hapjen e skriptes: %s\n"
IDS_ERROR_MSG_BAD_ARG "Error argumenti i procesimit: %s\n"
IDS_ERROR_INVALID_ARGS "Invalid arguments\n"
+ IDS_ERROR_NO_MEDIUM "No medium in device.\n"
END
diff --git a/base/system/diskpart/lang/tr-TR.rc b/base/system/diskpart/lang/tr-TR.rc
index f13e48ef803..a2be5d463ce 100644
--- a/base/system/diskpart/lang/tr-TR.rc
+++ b/base/system/diskpart/lang/tr-TR.rc
@@ -74,7 +74,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Current Filesystem\n"
IDS_FILESYSTEMS_FORMATTING "Filesystems available for formatting\n"
IDS_FILESYSTEMS_TYPE "Type : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
END
STRINGTABLE
@@ -235,4 +235,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "Betik açmada yanlışlık: %s\n"
IDS_ERROR_MSG_BAD_ARG "Argüman işlemede yanlışlık: %s\n"
IDS_ERROR_INVALID_ARGS "Geçersiz değiştirgenler\n"
+ IDS_ERROR_NO_MEDIUM "No medium in device.\n"
END
diff --git a/base/system/diskpart/lang/zh-CN.rc b/base/system/diskpart/lang/zh-CN.rc
index 4f48fd8c7f2..6ede50da37e 100644
--- a/base/system/diskpart/lang/zh-CN.rc
+++ b/base/system/diskpart/lang/zh-CN.rc
@@ -81,7 +81,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Current Filesystem\n"
IDS_FILESYSTEMS_FORMATTING "Filesystems available for formatting\n"
IDS_FILESYSTEMS_TYPE "Type : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
END
STRINGTABLE
@@ -242,4 +242,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "打开脚本时出错:%s\n"
IDS_ERROR_MSG_BAD_ARG "处理参数时出错:%s\n"
IDS_ERROR_INVALID_ARGS "无效的参数\n"
+ IDS_ERROR_NO_MEDIUM "No medium in device.\n"
END
diff --git a/base/system/diskpart/lang/zh-TW.rc b/base/system/diskpart/lang/zh-TW.rc
index 814cda7e40b..f0031305c8a 100644
--- a/base/system/diskpart/lang/zh-TW.rc
+++ b/base/system/diskpart/lang/zh-TW.rc
@@ -75,7 +75,7 @@ BEGIN
IDS_FILESYSTEMS_CURRENT "Current Filesystem\n"
IDS_FILESYSTEMS_FORMATTING "Filesystems available for formatting\n"
IDS_FILESYSTEMS_TYPE "Type : %s\n"
- IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: \n"
+ IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
END
STRINGTABLE
@@ -236,4 +236,5 @@ BEGIN
IDS_ERROR_MSG_NO_SCRIPT "錯誤開始的指令碼: %s\n"
IDS_ERROR_MSG_BAD_ARG "錯誤處理參數: %s\n"
IDS_ERROR_INVALID_ARGS "無效的參數\n"
+ IDS_ERROR_NO_MEDIUM "No medium in device.\n"
END
diff --git a/base/system/diskpart/partlist.c b/base/system/diskpart/partlist.c
index 713e54ca645..dbd0ef0e24a 100644
--- a/base/system/diskpart/partlist.c
+++ b/base/system/diskpart/partlist.c
@@ -1254,7 +1254,7 @@ GetVolumeExtents(
static
VOID
GetVolumeType(
- HANDLE VolumeHandle,
+ _In_ HANDLE VolumeHandle,
_In_ PVOLENTRY VolumeEntry)
{
FILE_FS_DEVICE_INFORMATION DeviceInfo;
@@ -1306,7 +1306,6 @@ AddVolumeToList(
WCHAR szFilesystem[MAX_PATH + 1];
DWORD CharCount = 0;
- WCHAR DeviceName[MAX_PATH] = L"";
size_t Index = 0;
OBJECT_ATTRIBUTES ObjectAttributes;
@@ -1329,7 +1328,7 @@ AddVolumeToList(
pszVolumeName[Index] = L'\0';
- CharCount = QueryDosDeviceW(&pszVolumeName[4], DeviceName,
ARRAYSIZE(DeviceName));
+ CharCount = QueryDosDeviceW(&pszVolumeName[4], VolumeEntry->DeviceName,
ARRAYSIZE(VolumeEntry->DeviceName));
pszVolumeName[Index] = L'\\';
@@ -1339,9 +1338,9 @@ AddVolumeToList(
return;
}
- DPRINT("DeviceName: %S\n", DeviceName);
+ DPRINT("DeviceName: %S\n", VolumeEntry->DeviceName);
- RtlInitUnicodeString(&Name, DeviceName);
+ RtlInitUnicodeString(&Name, VolumeEntry->DeviceName);
InitializeObjectAttributes(&ObjectAttributes,
&Name,
diff --git a/base/system/diskpart/resource.h b/base/system/diskpart/resource.h
index ca9d401d3ff..5b776a324d5 100644
--- a/base/system/diskpart/resource.h
+++ b/base/system/diskpart/resource.h
@@ -185,3 +185,4 @@
#define IDS_ERROR_MSG_NO_SCRIPT 2000
#define IDS_ERROR_MSG_BAD_ARG 2001
#define IDS_ERROR_INVALID_ARGS 2002
+#define IDS_ERROR_NO_MEDIUM 2003