[DISKPART] Implement the detail command

Display disk and partition details.
This commit is contained in:
Eric Kohl 2022-03-28 00:25:34 +02:00
parent 8476ae6ed5
commit 38b38bbf0c
11 changed files with 212 additions and 37 deletions

View file

@ -8,7 +8,130 @@
#include "diskpart.h"
BOOL detail_main(INT argc, LPWSTR *argv)
#define NDEBUG
#include <debug.h>
/* FUNCTIONS ******************************************************************/
static
VOID
DetailDisk(
INT argc,
LPWSTR *argv)
{
DPRINT("DetailDisk()\n");
if (argc > 2)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return;
}
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
return;
}
/* TODO: Print more disk details */
ConPuts(StdOut, L"\n");
ConResPrintf(StdOut, IDS_DETAIL_INFO_DISK_ID, CurrentDisk->LayoutBuffer->Signature);
ConResPrintf(StdOut, IDS_DETAIL_INFO_PATH, CurrentDisk->PathId);
ConResPrintf(StdOut, IDS_DETAIL_INFO_TARGET, CurrentDisk->TargetId);
ConResPrintf(StdOut, IDS_DETAIL_INFO_LUN_ID, CurrentDisk->Lun);
ConPuts(StdOut, L"\n");
}
static
VOID
DetailPartition(
INT argc,
LPWSTR *argv)
{
PPARTENTRY PartEntry;
ULONGLONG PartOffset;
DPRINT("DetailPartition()\n");
if (argc > 2)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return;
}
if (CurrentDisk == NULL)
{
ConResPuts(StdOut, IDS_SELECT_PARTITION_NO_DISK);
return;
}
if (CurrentPartition == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
return;
}
PartEntry = CurrentPartition;
PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
/* TODO: Print more partition details */
ConPuts(StdOut, L"\n");
ConResPrintf(StdOut, IDS_DETAIL_PARTITION_NUMBER, PartEntry->PartitionNumber);
ConResPrintf(StdOut, IDS_DETAIL_PARTITION_TYPE, PartEntry->PartitionType);
ConResPrintf(StdOut, IDS_DETAIL_PARTITION_HIDDEN, "");
ConResPrintf(StdOut, IDS_DETAIL_PARTITION_ACTIVE, PartEntry->BootIndicator ? L"Yes" : L"No");
ConResPrintf(StdOut, IDS_DETAIL_PARTITION_OFFSET, PartOffset);
ConPuts(StdOut, L"\n");
}
static
VOID
DetailVolume(
INT argc,
LPWSTR *argv)
{
DPRINT("DetailVolume()\n");
if (argc > 2)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
return;
}
if (CurrentVolume == NULL)
{
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
return;
}
/* TODO: Print volume details */
}
BOOL
detail_main(
INT argc,
LPWSTR *argv)
{
/* gets the first word from the string */
if (argc == 1)
{
ConResPuts(StdOut, IDS_HELP_CMD_DETAIL);
return TRUE;
}
/* determines which details to print (disk, partition, etc.) */
if (!wcsicmp(argv[1], L"disk"))
DetailDisk(argc, argv);
else if (!wcsicmp(argv[1], L"partition"))
DetailPartition(argc, argv);
else if (!wcsicmp(argv[1], L"volume"))
DetailVolume(argc, argv);
else
ConResPuts(StdOut, IDS_HELP_CMD_DETAIL);
return TRUE;
}

View file

@ -18,12 +18,12 @@ END
/* Disk Information Labels */
STRINGTABLE
BEGIN
IDS_DETAIL_INFO_DISK_ID "Disk"
IDS_DETAIL_INFO_DISK_ID "Disk ID: %08lx\n"
IDS_DETAIL_INFO_TYPE "Type"
IDS_DETAIL_INFO_STATUS "Status"
IDS_DETAIL_INFO_PATH "Path"
IDS_DETAIL_INFO_TARGET "Target"
IDS_DETAIL_INFO_LUN_ID "LUN ID"
IDS_DETAIL_INFO_PATH "Path : %hu\n"
IDS_DETAIL_INFO_TARGET "Target : %hu\n"
IDS_DETAIL_INFO_LUN_ID "Lun ID : %hu\n"
IDS_DETAIL_INFO_LOC_PATH "Location Path"
IDS_DETAIL_INFO_CURR_RO_STATE "Current Read-only State"
IDS_DETAIL_INFO_RO "Read-only"
@ -32,6 +32,11 @@ BEGIN
IDS_DETAIL_INFO_HIBER_FILE_DSK "Hibernation File Disk"
IDS_DETAIL_INFO_CRASH_DSK "Crashdump Disk"
IDS_DETAIL_INFO_CLST_DSK "Clustered Disk"
IDS_DETAIL_PARTITION_NUMBER "Partition %lu\n"
IDS_DETAIL_PARTITION_TYPE "Type : %02x\n"
IDS_DETAIL_PARTITION_HIDDEN "Hidden : %s\n"
IDS_DETAIL_PARTITION_ACTIVE "Active : %s\n"
IDS_DETAIL_PARTITION_OFFSET "Offset in Byte: %I64u\n"
END
/* Detail header titles */

View file

@ -18,12 +18,12 @@ END
/* Disk Information Labels */
STRINGTABLE
BEGIN
IDS_DETAIL_INFO_DISK_ID "Dysk"
IDS_DETAIL_INFO_DISK_ID "Dysk ID: %08lx\n"
IDS_DETAIL_INFO_TYPE "Typ"
IDS_DETAIL_INFO_STATUS "Stan"
IDS_DETAIL_INFO_PATH "Ścieżka"
IDS_DETAIL_INFO_TARGET "Docelowy"
IDS_DETAIL_INFO_LUN_ID "Identyfikator LUN"
IDS_DETAIL_INFO_PATH "Ścieżka : %hu\n"
IDS_DETAIL_INFO_TARGET "Docelowy : %hu\n"
IDS_DETAIL_INFO_LUN_ID "Identyfikator LUN : %hu\n"
IDS_DETAIL_INFO_LOC_PATH "Ścieżka lokalizacji"
IDS_DETAIL_INFO_CURR_RO_STATE "Aktualny stan Read-only"
IDS_DETAIL_INFO_RO "Tylko do odczytu"
@ -32,6 +32,11 @@ BEGIN
IDS_DETAIL_INFO_HIBER_FILE_DSK "Dysk pliku hibernacji"
IDS_DETAIL_INFO_CRASH_DSK "Dysk zrzutu awarii systemu"
IDS_DETAIL_INFO_CLST_DSK "Dysk klastrowany"
IDS_DETAIL_PARTITION_NUMBER "Partition %lu\n"
IDS_DETAIL_PARTITION_TYPE "Type : %02x\n"
IDS_DETAIL_PARTITION_HIDDEN "Hidden : %s\n"
IDS_DETAIL_PARTITION_ACTIVE "Active : %s\n"
IDS_DETAIL_PARTITION_OFFSET "Offset in Byte: %I64u\n"
END
/* Detail header titles */

View file

@ -20,12 +20,12 @@ END
/* Disk Information Labels */
STRINGTABLE
BEGIN
IDS_DETAIL_INFO_DISK_ID "Disco"
IDS_DETAIL_INFO_DISK_ID "Disco ID: %08lx\n"
IDS_DETAIL_INFO_TYPE "Tipo"
IDS_DETAIL_INFO_STATUS "Estado"
IDS_DETAIL_INFO_PATH "Caminho"
IDS_DETAIL_INFO_TARGET "Alvo"
IDS_DETAIL_INFO_LUN_ID "LUN ID"
IDS_DETAIL_INFO_PATH "Caminho : %hu\n"
IDS_DETAIL_INFO_TARGET "Alvo : %hu\n"
IDS_DETAIL_INFO_LUN_ID "LUN ID : %hu\n"
IDS_DETAIL_INFO_LOC_PATH "Caminho de localização"
IDS_DETAIL_INFO_CURR_RO_STATE "Estado actual somente de leitura"
IDS_DETAIL_INFO_RO "Apenas leitura"
@ -34,6 +34,11 @@ BEGIN
IDS_DETAIL_INFO_HIBER_FILE_DSK "Ficheiro de hibernação de disco"
IDS_DETAIL_INFO_CRASH_DSK "Despejo de memória de disco"
IDS_DETAIL_INFO_CLST_DSK "Disco em cluster"
IDS_DETAIL_PARTITION_NUMBER "Partition %lu\n"
IDS_DETAIL_PARTITION_TYPE "Type : %02x\n"
IDS_DETAIL_PARTITION_HIDDEN "Hidden : %s\n"
IDS_DETAIL_PARTITION_ACTIVE "Active : %s\n"
IDS_DETAIL_PARTITION_OFFSET "Offset in Byte: %I64u\n"
END
/* Detail header titles */

View file

@ -20,12 +20,12 @@ END
/* Disk Information Labels */
STRINGTABLE
BEGIN
IDS_DETAIL_INFO_DISK_ID "Disc"
IDS_DETAIL_INFO_DISK_ID "Disc ID: %08lx\n"
IDS_DETAIL_INFO_TYPE "Tip"
IDS_DETAIL_INFO_STATUS "Stare"
IDS_DETAIL_INFO_PATH "Cale"
IDS_DETAIL_INFO_TARGET "Țintă"
IDS_DETAIL_INFO_LUN_ID "LUN ID"
IDS_DETAIL_INFO_PATH "Cale : %hu\n"
IDS_DETAIL_INFO_TARGET "Țintă : %hu\n"
IDS_DETAIL_INFO_LUN_ID "LUN ID : %hu\n"
IDS_DETAIL_INFO_LOC_PATH "Localizat în"
IDS_DETAIL_INFO_CURR_RO_STATE "Stare curentă nemodificabilă"
IDS_DETAIL_INFO_RO "Nemodificabil"
@ -34,6 +34,11 @@ BEGIN
IDS_DETAIL_INFO_HIBER_FILE_DSK "Disc cu fișier de hibernare"
IDS_DETAIL_INFO_CRASH_DSK "Disc cu fișier «crashdump»"
IDS_DETAIL_INFO_CLST_DSK "Disc în «cluster»"
IDS_DETAIL_PARTITION_NUMBER "Partition %lu\n"
IDS_DETAIL_PARTITION_TYPE "Type : %02x\n"
IDS_DETAIL_PARTITION_HIDDEN "Hidden : %s\n"
IDS_DETAIL_PARTITION_ACTIVE "Active : %s\n"
IDS_DETAIL_PARTITION_OFFSET "Offset in Byte: %I64u\n"
END
/* Detail header titles */

View file

@ -20,12 +20,12 @@ END
/* Disk Information Labels */
STRINGTABLE
BEGIN
IDS_DETAIL_INFO_DISK_ID "Диск"
IDS_DETAIL_INFO_DISK_ID "Disk ID: %08lx\n"
IDS_DETAIL_INFO_TYPE "Тип"
IDS_DETAIL_INFO_STATUS "Состояние"
IDS_DETAIL_INFO_PATH "Путь"
IDS_DETAIL_INFO_TARGET "Цель"
IDS_DETAIL_INFO_LUN_ID "LUN ID"
IDS_DETAIL_INFO_PATH "Path : %hu\n"
IDS_DETAIL_INFO_TARGET "Target : %hu\n"
IDS_DETAIL_INFO_LUN_ID "Lun ID : %hu\n"
IDS_DETAIL_INFO_LOC_PATH "Путь к диску"
IDS_DETAIL_INFO_CURR_RO_STATE "Текущее состояние ""Только для чтения"""
IDS_DETAIL_INFO_RO "Только для чтения"
@ -34,6 +34,11 @@ BEGIN
IDS_DETAIL_INFO_HIBER_FILE_DSK "Hibernation File диск"
IDS_DETAIL_INFO_CRASH_DSK "Crashdump диск"
IDS_DETAIL_INFO_CLST_DSK "Кластерный диск"
IDS_DETAIL_PARTITION_NUMBER "Partition %lu\n"
IDS_DETAIL_PARTITION_TYPE "Type : %02x\n"
IDS_DETAIL_PARTITION_HIDDEN "Hidden : %s\n"
IDS_DETAIL_PARTITION_ACTIVE "Active : %s\n"
IDS_DETAIL_PARTITION_OFFSET "Offset in Byte: %I64u\n"
END
/* Detail header titles */

View file

@ -22,12 +22,12 @@ END
/* Disk Information Labels */
STRINGTABLE
BEGIN
IDS_DETAIL_INFO_DISK_ID "Disk"
IDS_DETAIL_INFO_DISK_ID "Disk ID: %08lx\n"
IDS_DETAIL_INFO_TYPE "Tipi"
IDS_DETAIL_INFO_STATUS "Gjendja"
IDS_DETAIL_INFO_PATH "Rrugë"
IDS_DETAIL_INFO_TARGET "Objektivi"
IDS_DETAIL_INFO_LUN_ID "LUN ID"
IDS_DETAIL_INFO_PATH "Path : %hu\n"
IDS_DETAIL_INFO_TARGET "Target : %hu\n"
IDS_DETAIL_INFO_LUN_ID "Lun ID : %hu\n"
IDS_DETAIL_INFO_LOC_PATH "Rruga e vendndodhjes"
IDS_DETAIL_INFO_CURR_RO_STATE "Read-only Gjendja aktuale"
IDS_DETAIL_INFO_RO "Read-only"
@ -36,6 +36,11 @@ BEGIN
IDS_DETAIL_INFO_HIBER_FILE_DSK "Hibernimi i dokumeteve Disk"
IDS_DETAIL_INFO_CRASH_DSK "Hedhja e te dhenave Disk"
IDS_DETAIL_INFO_CLST_DSK "Grupimet ne Disk"
IDS_DETAIL_PARTITION_NUMBER "Partition %lu\n"
IDS_DETAIL_PARTITION_TYPE "Type : %02x\n"
IDS_DETAIL_PARTITION_HIDDEN "Hidden : %s\n"
IDS_DETAIL_PARTITION_ACTIVE "Active : %s\n"
IDS_DETAIL_PARTITION_OFFSET "Offset in Byte: %I64u\n"
END
/* Detail header titles */

View file

@ -20,12 +20,12 @@ END
/* Disk Information Labels */
STRINGTABLE
BEGIN
IDS_DETAIL_INFO_DISK_ID "Disk"
IDS_DETAIL_INFO_DISK_ID "Disk ID: %08lx\n"
IDS_DETAIL_INFO_TYPE "Tür"
IDS_DETAIL_INFO_STATUS "Durum"
IDS_DETAIL_INFO_PATH "Yol"
IDS_DETAIL_INFO_TARGET "Varış"
IDS_DETAIL_INFO_LUN_ID "LUN ID"
IDS_DETAIL_INFO_PATH "Path : %hu\n"
IDS_DETAIL_INFO_TARGET "Target : %hu\n"
IDS_DETAIL_INFO_LUN_ID "Lun ID : %hu\n"
IDS_DETAIL_INFO_LOC_PATH "Konum Yolu"
IDS_DETAIL_INFO_CURR_RO_STATE "Şimdiki Yalnızca Okunur Durumu"
IDS_DETAIL_INFO_RO "Yalnızca Okunur"
@ -34,6 +34,11 @@ BEGIN
IDS_DETAIL_INFO_HIBER_FILE_DSK "Hazırda Bekletme Dosyası Diski"
IDS_DETAIL_INFO_CRASH_DSK "Çöküş Dökümü Diski"
IDS_DETAIL_INFO_CLST_DSK "Kümelenmiş Disk"
IDS_DETAIL_PARTITION_NUMBER "Partition %lu\n"
IDS_DETAIL_PARTITION_TYPE "Type : %02x\n"
IDS_DETAIL_PARTITION_HIDDEN "Hidden : %s\n"
IDS_DETAIL_PARTITION_ACTIVE "Active : %s\n"
IDS_DETAIL_PARTITION_OFFSET "Offset in Byte: %I64u\n"
END
/* Detail header titles */

View file

@ -21,12 +21,12 @@ END
/* Disk Information Labels */
STRINGTABLE
BEGIN
IDS_DETAIL_INFO_DISK_ID "磁盘"
IDS_DETAIL_INFO_DISK_ID "Disk ID: %08lx\n"
IDS_DETAIL_INFO_TYPE "类型"
IDS_DETAIL_INFO_STATUS "状态"
IDS_DETAIL_INFO_PATH "路径"
IDS_DETAIL_INFO_TARGET "目标"
IDS_DETAIL_INFO_LUN_ID "LUN ID"
IDS_DETAIL_INFO_PATH "Path : %hu\n"
IDS_DETAIL_INFO_TARGET "Target : %hu\n"
IDS_DETAIL_INFO_LUN_ID "Lun ID : %hu\n"
IDS_DETAIL_INFO_LOC_PATH "位置路径"
IDS_DETAIL_INFO_CURR_RO_STATE "当前的只读状态"
IDS_DETAIL_INFO_RO "只读模式"
@ -35,6 +35,11 @@ BEGIN
IDS_DETAIL_INFO_HIBER_FILE_DSK "休眠文件磁盘"
IDS_DETAIL_INFO_CRASH_DSK "故障转储磁盘"
IDS_DETAIL_INFO_CLST_DSK "群集的磁盘"
IDS_DETAIL_PARTITION_NUMBER "Partition %lu\n"
IDS_DETAIL_PARTITION_TYPE "Type : %02x\n"
IDS_DETAIL_PARTITION_HIDDEN "Hidden : %s\n"
IDS_DETAIL_PARTITION_ACTIVE "Active : %s\n"
IDS_DETAIL_PARTITION_OFFSET "Offset in Byte: %I64u\n"
END
/* Detail header titles */

View file

@ -21,12 +21,12 @@ END
/* Disk Information Labels */
STRINGTABLE
BEGIN
IDS_DETAIL_INFO_DISK_ID "磁碟"
IDS_DETAIL_INFO_DISK_ID "Disk ID: %08lx\n"
IDS_DETAIL_INFO_TYPE "類型"
IDS_DETAIL_INFO_STATUS "狀態"
IDS_DETAIL_INFO_PATH "路徑"
IDS_DETAIL_INFO_TARGET "目標"
IDS_DETAIL_INFO_LUN_ID "LUN ID"
IDS_DETAIL_INFO_PATH "Path : %hu\n"
IDS_DETAIL_INFO_TARGET "Target : %hu\n"
IDS_DETAIL_INFO_LUN_ID "Lun ID : %hu\n"
IDS_DETAIL_INFO_LOC_PATH "位置路徑"
IDS_DETAIL_INFO_CURR_RO_STATE "當前的唯讀狀態"
IDS_DETAIL_INFO_RO "唯讀模式"
@ -35,6 +35,11 @@ BEGIN
IDS_DETAIL_INFO_HIBER_FILE_DSK "休眠檔案磁碟"
IDS_DETAIL_INFO_CRASH_DSK "損毀傾印磁碟"
IDS_DETAIL_INFO_CLST_DSK "叢集磁碟"
IDS_DETAIL_PARTITION_NUMBER "Partition %lu\n"
IDS_DETAIL_PARTITION_TYPE "Type : %02x\n"
IDS_DETAIL_PARTITION_HIDDEN "Hidden : %s\n"
IDS_DETAIL_PARTITION_ACTIVE "Active : %s\n"
IDS_DETAIL_PARTITION_OFFSET "Offset in Byte: %I64u\n"
END
/* Detail header titles */

View file

@ -32,6 +32,12 @@
#define IDS_DETAIL_INFO_CRASH_DSK 19
#define IDS_DETAIL_INFO_CLST_DSK 20
#define IDS_DETAIL_PARTITION_NUMBER 30
#define IDS_DETAIL_PARTITION_TYPE 31
#define IDS_DETAIL_PARTITION_HIDDEN 32
#define IDS_DETAIL_PARTITION_ACTIVE 33
#define IDS_DETAIL_PARTITION_OFFSET 34
#define IDS_LIST_DISK_HEAD 3300
#define IDS_LIST_DISK_LINE 3301
#define IDS_LIST_DISK_FORMAT 3302
@ -121,6 +127,7 @@
#define IDS_HELP_CMD_COMPACT 113
#define IDS_HELP_CMD_CONVERT 114
#define IDS_HELP_CMD_CREATE 115
#define IDS_HELP_CMD_CREATE_PARTITION 180
#define IDS_HELP_CMD_DELETE 116
#define IDS_HELP_CMD_DETACH 117
#define IDS_HELP_CMD_DETAIL 118