From ccfb061a2b1285c77d33eb154b5fbf8ebd069f1e Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 15 Dec 2025 20:36:51 +0100 Subject: [PATCH] [DISKPART] list partition: Show a message when there are no partitions on a disk --- base/system/diskpart/lang/de-DE.rc | 1 + base/system/diskpart/lang/en-US.rc | 1 + base/system/diskpart/lang/it-IT.rc | 1 + base/system/diskpart/lang/pl-PL.rc | 1 + base/system/diskpart/lang/pt-PT.rc | 1 + base/system/diskpart/lang/ro-RO.rc | 1 + base/system/diskpart/lang/ru-RU.rc | 1 + base/system/diskpart/lang/sq-AL.rc | 1 + base/system/diskpart/lang/tr-TR.rc | 1 + base/system/diskpart/lang/zh-CN.rc | 1 + base/system/diskpart/lang/zh-TW.rc | 1 + base/system/diskpart/list.c | 34 ++++++++++++++++++++++++++++++ base/system/diskpart/resource.h | 7 +++--- 13 files changed, 49 insertions(+), 3 deletions(-) diff --git a/base/system/diskpart/lang/de-DE.rc b/base/system/diskpart/lang/de-DE.rc index 34378eb73e2..bcd458c485d 100644 --- a/base/system/diskpart/lang/de-DE.rc +++ b/base/system/diskpart/lang/de-DE.rc @@ -112,6 +112,7 @@ BEGIN IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n" IDS_LIST_PARTITION_FORMAT "%c Partition %-3lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\nThere is no disk to list partitions.\nPlease select a disk and try again.\n\n" + IDS_LIST_PARTITION_NONE "\nAuf dem Datenträger sind keine Partitionen vorhanden, die angezeigt werden können.\n" IDS_LIST_VOLUME_HEAD " Volume ### Ltr Label FS Type Size Status Info\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c Volume %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/en-US.rc b/base/system/diskpart/lang/en-US.rc index ce7cfc6b697..67413ec8e9b 100644 --- a/base/system/diskpart/lang/en-US.rc +++ b/base/system/diskpart/lang/en-US.rc @@ -112,6 +112,7 @@ BEGIN IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n" IDS_LIST_PARTITION_FORMAT "%c Partition %-3lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\nThere is no disk to list partitions.\nPlease select a disk and try again.\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " Volume ### Ltr Label FS Type Size Status Info\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c Volume %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/it-IT.rc b/base/system/diskpart/lang/it-IT.rc index 7b729e0934a..f69469f8b88 100644 --- a/base/system/diskpart/lang/it-IT.rc +++ b/base/system/diskpart/lang/it-IT.rc @@ -119,6 +119,7 @@ BEGIN IDS_LIST_PARTITION_LINE " -------------- ---------------- ---------- -------\n" IDS_LIST_PARTITION_FORMAT "%c Partizione %-3lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\nNon c'è nessun disco per mostrare partizioni.\nSelezionare un disco e riprova.\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " Volume ### Ltr Etichetta FS Tipo Dimensione Stato Info\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ---------- ----- --------\n" IDS_LIST_VOLUME_FORMAT "%c Volume %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/pl-PL.rc b/base/system/diskpart/lang/pl-PL.rc index 6201af74fb9..c17a4455b77 100644 --- a/base/system/diskpart/lang/pl-PL.rc +++ b/base/system/diskpart/lang/pl-PL.rc @@ -112,6 +112,7 @@ BEGIN IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- ------------\n" IDS_LIST_PARTITION_FORMAT "%c Partycja %2lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\nNie wybrano dysku do wyświetlenia partycji.\nWybierz dysk i spróbuj ponownie.\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " Wolumin ### Lit Etykieta FS Typ Rozmiar Stan Info\n" IDS_LIST_VOLUME_LINE " ----------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c Wolumin %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/pt-PT.rc b/base/system/diskpart/lang/pt-PT.rc index 7376c92b802..045b650c206 100644 --- a/base/system/diskpart/lang/pt-PT.rc +++ b/base/system/diskpart/lang/pt-PT.rc @@ -114,6 +114,7 @@ BEGIN IDS_LIST_PARTITION_LINE " ------------- ------- --------- -------\n" IDS_LIST_PARTITION_FORMAT "%c Partição %2lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\nSem discos para listar Partições.\nPor favor seleccione um disco e tente novamente.\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " Volume ### Ltr Label FS Type Size Status Info\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c Volume %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/ro-RO.rc b/base/system/diskpart/lang/ro-RO.rc index f54c7386b8f..7d728de6765 100644 --- a/base/system/diskpart/lang/ro-RO.rc +++ b/base/system/diskpart/lang/ro-RO.rc @@ -120,6 +120,7 @@ BEGIN IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n" IDS_LIST_PARTITION_FORMAT "%c Partiție %2lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\nNu există niciun disc pentru a afișa partiții.\nSelectați un disc apoi reîncercați.\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " Volum ### Ltr Etichetă FS Tip Mărime Stare Informații\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c Volum %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/ru-RU.rc b/base/system/diskpart/lang/ru-RU.rc index ab4db71aaad..e6fb931b90e 100644 --- a/base/system/diskpart/lang/ru-RU.rc +++ b/base/system/diskpart/lang/ru-RU.rc @@ -114,6 +114,7 @@ BEGIN IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n" IDS_LIST_PARTITION_FORMAT "%c Раздел %2lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\nДиск с разметкой элементов не выбран.\nУкажите диск и повторите попытку.\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " Volume ### Ltr Label FS Type Size Status Info\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c Volume %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/sq-AL.rc b/base/system/diskpart/lang/sq-AL.rc index 6464c6eed62..e9e7842b274 100644 --- a/base/system/diskpart/lang/sq-AL.rc +++ b/base/system/diskpart/lang/sq-AL.rc @@ -116,6 +116,7 @@ BEGIN IDS_LIST_PARTITION_LINE "%c ------------- ---------------- ------- -------\n" IDS_LIST_PARTITION_FORMAT " Partition %2lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\nThere is no disk to list partitions.\nPlease select a disk and try again.\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " Volume ### Ltr Label FS Type Size Status Info\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c Volume %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/tr-TR.rc b/base/system/diskpart/lang/tr-TR.rc index 4129d7712fb..98677ef0196 100644 --- a/base/system/diskpart/lang/tr-TR.rc +++ b/base/system/diskpart/lang/tr-TR.rc @@ -122,6 +122,7 @@ BEGIN IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n" IDS_LIST_PARTITION_FORMAT "%c Bölüm %2lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\nBölümleri listelemek için bir disk yok.\nLütfen bir disk seçiniz ve yeniden deneyiniz.\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " Birim ### Hrf Etiket DS Dür Boyut Durum Bilgi\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c Birim %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/zh-CN.rc b/base/system/diskpart/lang/zh-CN.rc index 2fa8302b5d3..286bd5f82ae 100644 --- a/base/system/diskpart/lang/zh-CN.rc +++ b/base/system/diskpart/lang/zh-CN.rc @@ -121,6 +121,7 @@ BEGIN IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n" IDS_LIST_PARTITION_FORMAT "%c Partition %2lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\n这里没有要列出分区的磁盘。\n请选择一个磁盘,再试一次。\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " Volume ### Ltr Label FS Type Size Status Info\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c Volume %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/lang/zh-TW.rc b/base/system/diskpart/lang/zh-TW.rc index 2ae1d505929..ea72d653e0a 100644 --- a/base/system/diskpart/lang/zh-TW.rc +++ b/base/system/diskpart/lang/zh-TW.rc @@ -121,6 +121,7 @@ BEGIN IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n" IDS_LIST_PARTITION_FORMAT "%c 磁碟分割 %2lu %-16s %4I64u %-2s %4I64u %-2s\n" IDS_LIST_PARTITION_NO_DISK "\n沒有可列出分區的磁碟。\n請選擇一個磁碟,再試一次。\n\n" + IDS_LIST_PARTITION_NONE "\nThere are no partitions on this disk to show.\n" IDS_LIST_VOLUME_HEAD " 磁碟區 ### Ltr 標籤 FS 類型 大小 狀態 資訊\n" IDS_LIST_VOLUME_LINE " ---------- --- ----------- ----- ---------- ------- ------- --------\n" IDS_LIST_VOLUME_FORMAT "%c 磁碟區 %-3lu %c %-11.11s %-5s %-10.10s %4I64u %-2s\n" diff --git a/base/system/diskpart/list.c b/base/system/diskpart/list.c index ce5ca8d4186..3f0e87c9e2d 100644 --- a/base/system/diskpart/list.c +++ b/base/system/diskpart/list.c @@ -189,6 +189,7 @@ ListPartition( LPWSTR lpSizeUnit; LPWSTR lpOffsetUnit; ULONG PartNumber = 1; + BOOL bPartitionFound = FALSE; if (CurrentDisk == NULL) { @@ -196,6 +197,39 @@ ListPartition( return TRUE; } + if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR) + { + Entry = CurrentDisk->PrimaryPartListHead.Flink; + while (Entry != &CurrentDisk->PrimaryPartListHead) + { + PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry); + if (PartEntry->Mbr.PartitionType != PARTITION_ENTRY_UNUSED) + bPartitionFound = TRUE; + + Entry = Entry->Flink; + } + } + else if (CurrentDisk->PartitionStyle == PARTITION_STYLE_GPT) + { + Entry = CurrentDisk->PrimaryPartListHead.Flink; + while (Entry != &CurrentDisk->PrimaryPartListHead) + { + PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry); + if (!IsEqualGUID(&PartEntry->Gpt.PartitionType, &PARTITION_ENTRY_UNUSED_GUID)) + bPartitionFound = TRUE; + + Entry = Entry->Flink; + } + } + + if (bPartitionFound == FALSE) + { + ConPuts(StdOut, L"\n"); + ConResPuts(StdOut, IDS_LIST_PARTITION_NONE); + ConPuts(StdOut, L"\n"); + return TRUE; + } + /* Header labels */ ConPuts(StdOut, L"\n"); ConResPuts(StdOut, IDS_LIST_PARTITION_HEAD); diff --git a/base/system/diskpart/resource.h b/base/system/diskpart/resource.h index ec83e8969b7..ce3068c36c3 100644 --- a/base/system/diskpart/resource.h +++ b/base/system/diskpart/resource.h @@ -85,9 +85,10 @@ #define IDS_LIST_PARTITION_LINE 3304 #define IDS_LIST_PARTITION_FORMAT 3305 #define IDS_LIST_PARTITION_NO_DISK 3306 -#define IDS_LIST_VOLUME_HEAD 3307 -#define IDS_LIST_VOLUME_LINE 3308 -#define IDS_LIST_VOLUME_FORMAT 3309 +#define IDS_LIST_PARTITION_NONE 3307 +#define IDS_LIST_VOLUME_HEAD 3308 +#define IDS_LIST_VOLUME_LINE 3309 +#define IDS_LIST_VOLUME_FORMAT 3310 #define IDS_RESCAN_START 4100 #define IDS_RESCAN_END 4101