diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-02-23 16:41:48 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2015-02-23 16:41:48 -0800 |
commit | 729f7bd5fe0b23ed16084f0e4591c7a6eb4de40f (patch) | |
tree | b8ede78610445643980cb3ba8fb7f5692b161b8d | |
parent | 05760b7f1daa1e6e1ce5a6cdfb55f6b75015a4c8 (diff) | |
download | gptfdisk-729f7bd5fe0b23ed16084f0e4591c7a6eb4de40f.tar.gz |
Offer to print partition info in raw format.
This raw format is easier for other scripts to parse.
Change-Id: I15b3011376e27c28fd40b9c3b2722a75bb8cde25
-rw-r--r-- | gpt.cc | 4 | ||||
-rw-r--r-- | gpt.h | 2 | ||||
-rw-r--r-- | gptcl.cc | 6 | ||||
-rw-r--r-- | gptpart.cc | 9 | ||||
-rw-r--r-- | gptpart.h | 2 |
5 files changed, 17 insertions, 6 deletions
@@ -1449,9 +1449,9 @@ void GPTData::DisplayGPTData(void) { } // GPTData::DisplayGPTData() // Show detailed information on the specified partition -void GPTData::ShowPartDetails(uint32_t partNum) { +void GPTData::ShowPartDetails(uint32_t partNum, bool raw) { if ((partNum < numParts) && !IsFreePartNum(partNum)) { - partitions[partNum].ShowDetails(blockSize); + partitions[partNum].ShowDetails(blockSize, raw); } else { cout << "Partition #" << partNum + 1 << " does not exist.\n"; } // if @@ -129,7 +129,7 @@ public: void ShowGPTState(void); void DisplayGPTData(void); void DisplayMBRData(void) {protectiveMBR.DisplayMBRData();} - void ShowPartDetails(uint32_t partNum); + void ShowPartDetails(uint32_t partNum, bool raw); // Convert between GPT and other formats virtual WhichToUse UseWhichPartitions(void); @@ -86,6 +86,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { {"randomize-guids", 'G', POPT_ARG_NONE, NULL, 'G', "randomize disk and partition GUIDs", ""}, {"hybrid", 'h', POPT_ARG_STRING, &hybrids, 'h', "create hybrid MBR", "partnum[:partnum...]"}, {"info", 'i', POPT_ARG_INT, &infoPartNum, 'i', "show detailed information on partition", "partnum"}, + {"info-raw", 'I', POPT_ARG_INT, &infoPartNum, 'I', "show detailed information on partition", "partnum"}, {"load-backup", 'l', POPT_ARG_STRING, &backupFile, 'l', "load GPT backup from file", "file"}, {"list-types", 'L', POPT_ARG_NONE, NULL, 'L', "list known partition types", ""}, {"gpttombr", 'm', POPT_ARG_STRING, &mbrParts, 'm', "convert GPT to MBR", "partnum[:partnum...]"}, @@ -258,7 +259,10 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { saveData = 1; break; case 'i': - ShowPartDetails(infoPartNum - 1); + ShowPartDetails(infoPartNum - 1, false); + break; + case 'I': + ShowPartDetails(infoPartNum - 1, true); break; case 'l': LoadBackupFile(backupFile, saveData, neverSaveData); @@ -360,10 +360,17 @@ void GPTPart::ShowSummary(int partNum, uint32_t blockSize) { // Show detailed partition information. Does nothing if the partition is // empty (as determined by firstLBA being 0). -void GPTPart::ShowDetails(uint32_t blockSize) { +void GPTPart::ShowDetails(uint32_t blockSize, bool raw) { uint64_t size; if (firstLBA != 0) { + if (raw) { + cout << "TYPE_GUID=" << partitionType << "\n"; + cout << "PART_GUID=" << uniqueGUID << "\n"; + cout << "PART_NAME=" << GetDescription() << "\n"; + return; + } + cout << "Partition GUID code: " << partitionType; cout << " (" << partitionType.TypeName() << ")\n"; cout << "Partition unique GUID: " << uniqueGUID << "\n"; @@ -89,7 +89,7 @@ class GPTPart { GPTPart & operator=(const GPTPart & orig); bool operator<(const GPTPart &other) const; void ShowSummary(int partNum, uint32_t blockSize); // display summary information (1-line) - void ShowDetails(uint32_t blockSize); // display detailed information (multi-line) + void ShowDetails(uint32_t blockSize, bool raw); // display detailed information (multi-line) void BlankPartition(void); // empty partition of data int DoTheyOverlap(const GPTPart & other); // returns 1 if there's overlap void ReversePartBytes(void); // reverse byte order of all integer fields |