Tentative support for duplicating one disk's partition table on another

disk.
This commit is contained in:
srs5694
2010-07-06 15:39:51 -04:00
parent 61768bccde
commit f9312b0ca9
5 changed files with 40 additions and 11 deletions

11
gpt.cc
View File

@@ -869,13 +869,16 @@ int GPTData::CheckTable(struct GPTHeader *header) {
// Writes GPT (and protective MBR) to disk. Returns 1 on successful
// write, 0 if there was a problem.
int GPTData::SaveGPTData(int quiet) {
int GPTData::SaveGPTData(int quiet, string filename) {
int allOK = 1, littleEndian;
char answer;
if (filename == "")
filename = device;
littleEndian = IsLittleEndian();
if (device == "") {
if (filename == "") {
cerr << "Device not defined.\n";
} // if
@@ -938,7 +941,7 @@ int GPTData::SaveGPTData(int quiet) {
// Do it!
if (allOK) {
if (myDisk.OpenForWrite(device)) {
if (myDisk.OpenForWrite(filename)) {
// As per UEFI specs, write the secondary table and GPT first....
allOK = SavePartitionTable(myDisk, secondHeader.partitionEntriesLBA);
if (!allOK)
@@ -971,7 +974,7 @@ int GPTData::SaveGPTData(int quiet) {
myDisk.Close();
} else {
cerr << "Unable to open device " << device << " for writing! Errno is "
cerr << "Unable to open device " << filename << " for writing! Errno is "
<< errno << "! Aborting write!\n";
allOK = 0;
} // if/else