Reactos
at master 79 lines 1.9 kB view raw
1/* 2 * PROJECT: ReactOS DiskPart 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: base/system/diskpart/gpt.c 5 * PURPOSE: Manages all the partitions of the OS in an interactive way. 6 * PROGRAMMERS: Lee Schroeder 7 */ 8 9#include "diskpart.h" 10 11#define NDEBUG 12#include <debug.h> 13 14 15EXIT_CODE 16gpt_main( 17 _In_ INT argc, 18 _In_ PWSTR *argv) 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 EXIT_SUCCESS; 29 } 30 31 if (CurrentPartition == NULL) 32 { 33 ConResPuts(StdOut, IDS_SELECT_NO_PARTITION); 34 return EXIT_SUCCESS; 35 } 36 37 if (CurrentDisk->PartitionStyle != PARTITION_STYLE_GPT) 38 { 39 ConResPuts(StdOut, IDS_CREATE_PARTITION_INVALID_STYLE); 40 return EXIT_SUCCESS; 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 EXIT_SUCCESS; 55 } 56 } 57 else 58 { 59 ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); 60 return EXIT_SUCCESS; 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 EXIT_SUCCESS; 74 } 75 76 ConResPuts(StdOut, IDS_GPT_SUCCESS); 77 78 return EXIT_SUCCESS; 79}