aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2015-02-23 16:41:48 -0800
committerJeff Sharkey <jsharkey@android.com>2015-02-23 16:41:48 -0800
commit729f7bd5fe0b23ed16084f0e4591c7a6eb4de40f (patch)
treeb8ede78610445643980cb3ba8fb7f5692b161b8d
parent05760b7f1daa1e6e1ce5a6cdfb55f6b75015a4c8 (diff)
downloadgptfdisk-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.cc4
-rw-r--r--gpt.h2
-rw-r--r--gptcl.cc6
-rw-r--r--gptpart.cc9
-rw-r--r--gptpart.h2
5 files changed, 17 insertions, 6 deletions
diff --git a/gpt.cc b/gpt.cc
index 18247c5..49fc025 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -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
diff --git a/gpt.h b/gpt.h
index e9afd06..dd0586b 100644
--- a/gpt.h
+++ b/gpt.h
@@ -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);
diff --git a/gptcl.cc b/gptcl.cc
index e20048e..a37b845 100644
--- a/gptcl.cc
+++ b/gptcl.cc
@@ -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);
diff --git a/gptpart.cc b/gptpart.cc
index 17d6f15..8d8ac64 100644
--- a/gptpart.cc
+++ b/gptpart.cc
@@ -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";
diff --git a/gptpart.h b/gptpart.h
index 657b3f9..377ec55 100644
--- a/gptpart.h
+++ b/gptpart.h
@@ -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