Skip to content

Commit 5047e62

Browse files
committed
[DISKPART] Implement the gpt command keep the partition number up to date
1 parent ccfb061 commit 5047e62

File tree

14 files changed

+137
-1
lines changed

14 files changed

+137
-1
lines changed

base/system/diskpart/gpt.c

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,72 @@
88

99
#include "diskpart.h"
1010

11-
BOOL gpt_main(INT argc, LPWSTR *argv)
11+
#define NDEBUG
12+
#include <debug.h>
13+
14+
15+
BOOL
16+
gpt_main(
17+
INT argc,
18+
LPWSTR *argv)
1219
{
20+
ULONGLONG ullAttributes = 0ULL;
21+
PWSTR pszSuffix = NULL;
22+
INT i;
23+
NTSTATUS Status;
24+
25+
if (CurrentDisk == NULL)
26+
{
27+
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
28+
return TRUE;
29+
}
30+
31+
if (CurrentPartition == NULL)
32+
{
33+
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
34+
return TRUE;
35+
}
36+
37+
if (CurrentDisk->PartitionStyle != PARTITION_STYLE_GPT)
38+
{
39+
ConResPuts(StdOut, IDS_CREATE_PARTITION_INVALID_STYLE);
40+
return TRUE;
41+
}
42+
43+
for (i = 1; i < argc; i++)
44+
{
45+
if (HasPrefix(argv[i], L"attributes=", &pszSuffix))
46+
{
47+
/* attributes=<N> */
48+
DPRINT("Attributes: %s\n", pszSuffix);
49+
50+
ullAttributes = _wcstoui64(pszSuffix, NULL, 0);
51+
if ((ullAttributes == 0) && (errno == ERANGE))
52+
{
53+
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
54+
return TRUE;
55+
}
56+
}
57+
else
58+
{
59+
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
60+
return TRUE;
61+
}
62+
}
63+
64+
DPRINT("Attributes: 0x%I64x\n", ullAttributes);
65+
CurrentPartition->Gpt.Attributes = ullAttributes;
66+
CurrentDisk->Dirty = TRUE;
67+
68+
UpdateGptDiskLayout(CurrentDisk, FALSE);
69+
Status = WriteGptPartitions(CurrentDisk);
70+
if (!NT_SUCCESS(Status))
71+
{
72+
ConResPuts(StdOut, IDS_GPT_FAIL);
73+
return TRUE;
74+
}
75+
76+
ConResPuts(StdOut, IDS_GPT_SUCCESS);
77+
1378
return TRUE;
1479
}

base/system/diskpart/lang/de-DE.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ BEGIN
8989
IDS_FILESYSTEMS_CLUSTERSIZE "Größe der Zuordnungseinheit: %lu\n"
9090
END
9191

92+
STRINGTABLE
93+
BEGIN
94+
IDS_GPT_FAIL "\nDiskPart failed to assign atttributes to the selected GPT partition.\n"
95+
IDS_GPT_SUCCESS "\nDiskPart successfully assigned the attributes the selected GPT partition.\n"
96+
END
97+
9298
STRINGTABLE
9399
BEGIN
94100
IDS_HELP_FORMAT_STRING "%-11.11s - %s"

base/system/diskpart/lang/en-US.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ BEGIN
8989
IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
9090
END
9191

92+
STRINGTABLE
93+
BEGIN
94+
IDS_GPT_FAIL "\nDiskPart failed to assign atttributes to the selected GPT partition.\n"
95+
IDS_GPT_SUCCESS "\nDiskPart successfully assigned the attributes the selected GPT partition.\n"
96+
END
97+
9298
STRINGTABLE
9399
BEGIN
94100
IDS_HELP_FORMAT_STRING "%-11.11s - %s"

base/system/diskpart/lang/it-IT.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ BEGIN
9696
IDS_FILESYSTEMS_CLUSTERSIZE "Dimensione cluster: %lu\n"
9797
END
9898

99+
STRINGTABLE
100+
BEGIN
101+
IDS_GPT_FAIL "\nDiskPart failed to assign atttributes to the selected GPT partition.\n"
102+
IDS_GPT_SUCCESS "\nDiskPart successfully assigned the attributes the selected GPT partition.\n"
103+
END
104+
99105
STRINGTABLE
100106
BEGIN
101107
IDS_HELP_FORMAT_STRING "%-11.11s - %s"

base/system/diskpart/lang/pl-PL.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ BEGIN
8989
IDS_FILESYSTEMS_CLUSTERSIZE "Rozmiar klastra: %lu\n"
9090
END
9191

92+
STRINGTABLE
93+
BEGIN
94+
IDS_GPT_FAIL "\nDiskPart failed to assign atttributes to the selected GPT partition.\n"
95+
IDS_GPT_SUCCESS "\nDiskPart successfully assigned the attributes the selected GPT partition.\n"
96+
END
97+
9298
STRINGTABLE
9399
BEGIN
94100
IDS_HELP_FORMAT_STRING "%-11.11s - %s"

base/system/diskpart/lang/pt-PT.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ BEGIN
9191
IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
9292
END
9393

94+
STRINGTABLE
95+
BEGIN
96+
IDS_GPT_FAIL "\nDiskPart failed to assign atttributes to the selected GPT partition.\n"
97+
IDS_GPT_SUCCESS "\nDiskPart successfully assigned the attributes the selected GPT partition.\n"
98+
END
99+
94100
STRINGTABLE
95101
BEGIN
96102
IDS_HELP_FORMAT_STRING "%-11.11s - %s"

base/system/diskpart/lang/ro-RO.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ BEGIN
9797
IDS_FILESYSTEMS_CLUSTERSIZE "Mărimea cluster-ului: %lu\n"
9898
END
9999

100+
STRINGTABLE
101+
BEGIN
102+
IDS_GPT_FAIL "\nDiskPart failed to assign atttributes to the selected GPT partition.\n"
103+
IDS_GPT_SUCCESS "\nDiskPart successfully assigned the attributes the selected GPT partition.\n"
104+
END
105+
100106
STRINGTABLE
101107
BEGIN
102108
IDS_HELP_FORMAT_STRING "%-11.11s - %s"

base/system/diskpart/lang/ru-RU.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ BEGIN
9191
IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
9292
END
9393

94+
STRINGTABLE
95+
BEGIN
96+
IDS_GPT_FAIL "\nDiskPart failed to assign atttributes to the selected GPT partition.\n"
97+
IDS_GPT_SUCCESS "\nDiskPart successfully assigned the attributes the selected GPT partition.\n"
98+
END
99+
94100
STRINGTABLE
95101
BEGIN
96102
IDS_HELP_FORMAT_STRING "%-11.11s - %s"

base/system/diskpart/lang/sq-AL.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ BEGIN
9393
IDS_FILESYSTEMS_CLUSTERSIZE "Cluster size: %lu\n"
9494
END
9595

96+
STRINGTABLE
97+
BEGIN
98+
IDS_GPT_FAIL "\nDiskPart failed to assign atttributes to the selected GPT partition.\n"
99+
IDS_GPT_SUCCESS "\nDiskPart successfully assigned the attributes the selected GPT partition.\n"
100+
END
101+
96102
STRINGTABLE
97103
BEGIN
98104
IDS_HELP_FORMAT_STRING "%-11.11s - %s"

base/system/diskpart/lang/tr-TR.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ BEGIN
9999
IDS_FILESYSTEMS_CLUSTERSIZE "Küme boyutu : %lu\n"
100100
END
101101

102+
STRINGTABLE
103+
BEGIN
104+
IDS_GPT_FAIL "\nDiskPart failed to assign atttributes to the selected GPT partition.\n"
105+
IDS_GPT_SUCCESS "\nDiskPart successfully assigned the attributes the selected GPT partition.\n"
106+
END
107+
102108
STRINGTABLE
103109
BEGIN
104110
IDS_HELP_FORMAT_STRING "%-11.11s - %s"

0 commit comments

Comments
 (0)