|
8 | 8 |
|
9 | 9 | #include "diskpart.h" |
10 | 10 |
|
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) |
12 | 19 | { |
| 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 | + |
13 | 78 | return TRUE; |
14 | 79 | } |
0 commit comments