aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Hartman <ghartman@google.com>2017-03-28 01:02:21 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-03-28 01:02:21 +0000
commitf08cbdc772016a5ac3d49a5d5095369a9b24d2a9 (patch)
tree7452ff4451a0cc4c07b32a3345b8eca5fea987f8
parentfa990d2e3b93ce7563f03188d52e784774239c1b (diff)
parent1e25b13a151de675e8f7c335a4c8f1cf91b7fd7b (diff)
downloadgptfdisk-f08cbdc772016a5ac3d49a5d5095369a9b24d2a9.tar.gz
Add an option to allow disk syncing to be turned off am: 3c01fa7513
am: 1e25b13a15 Change-Id: I575627881592fa6c6ebc94112d0b3a9aa8f1bb63
-rw-r--r--gpt.cc9
-rw-r--r--gpt.h2
-rw-r--r--gptcl.cc4
3 files changed, 13 insertions, 2 deletions
diff --git a/gpt.cc b/gpt.cc
index 278f392..9ad769a 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -71,6 +71,7 @@ GPTData::GPTData(void) {
state = gpt_valid;
device = "";
justLooking = 0;
+ syncing = 1;
mainCrcOk = 0;
secondCrcOk = 0;
mainPartsCrcOk = 0;
@@ -95,6 +96,7 @@ GPTData::GPTData(string filename) {
state = gpt_invalid;
device = "";
justLooking = 0;
+ syncing = 1;
mainCrcOk = 0;
secondCrcOk = 0;
mainPartsCrcOk = 0;
@@ -130,6 +132,7 @@ GPTData & GPTData::operator=(const GPTData & orig) {
diskSize = orig.diskSize;
state = orig.state;
justLooking = orig.justLooking;
+ syncing = orig.syncing;
mainCrcOk = orig.mainCrcOk;
secondCrcOk = orig.secondCrcOk;
mainPartsCrcOk = orig.mainPartsCrcOk;
@@ -1144,7 +1147,7 @@ int GPTData::SaveGPTData(int quiet) {
// original partition table from its cache. OTOH, such restoration might be
// desirable if the error occurs later; but that seems unlikely unless the initial
// write fails....
- if (syncIt)
+ if (syncIt && syncing)
myDisk.DiskSync();
if (allOK) { // writes completed OK
@@ -1376,7 +1379,9 @@ int GPTData::DestroyGPT(void) {
allOK = 0;
} // if
} // if
- myDisk.DiskSync();
+ if (syncing) {
+ myDisk.DiskSync();
+ }
myDisk.Close();
cout << "GPT data structures destroyed! You may now partition the disk using fdisk or\n"
<< "other utilities.\n";
diff --git a/gpt.h b/gpt.h
index e9afd06..1c0eaaf 100644
--- a/gpt.h
+++ b/gpt.h
@@ -72,6 +72,7 @@ protected:
uint64_t diskSize; // size of device, in blocks
GPTValidity state; // is GPT valid?
int justLooking; // Set to 1 if program launched with "-l" or if read-only
+ bool syncing; // Set to true if we should sync and reload the partition table
int mainCrcOk;
int secondCrcOk;
int mainPartsCrcOk;
@@ -189,6 +190,7 @@ public:
uint32_t ComputeAlignment(void); // Set alignment based on current partitions
uint32_t GetAlignment(void) {return sectorAlignment;}
void JustLooking(int i = 1) {justLooking = i;}
+ void TurnOffSyncing() {syncing = 0;}
void BeQuiet(int i = 1) {beQuiet = i;}
WhichToUse WhichWasUsed(void) {return whichWasUsed;}
diff --git a/gptcl.cc b/gptcl.cc
index 183b4a9..9834788 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"},
+ {"skip-sync", 'j', POPT_ARG_NONE, NULL, 'j', "Don't atempt to sync and update the parittion table", ""},
{"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...]"},
@@ -260,6 +261,9 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
case 'i':
ShowPartDetails(infoPartNum - 1);
break;
+ case 'j':
+ TurnOffSyncing();
+ break;
case 'l':
LoadBackupFile(backupFile, saveData, neverSaveData);
free(backupFile);