diff options
-rw-r--r-- | NEWS | 8 | ||||
-rw-r--r-- | gdisk.8 | 2 | ||||
-rw-r--r-- | gptcl.cc | 27 | ||||
-rw-r--r-- | support.h | 2 |
4 files changed, 29 insertions, 10 deletions
@@ -1,6 +1,14 @@ 0.8.10 (?/??/2014): ------------------- +- Added feature to sgdisk's -A/--attributes, -c/--change-name, + -t/--typecode, and -u/--partition-guid commands: If a -n/--new option + with "0" as the partition number precedes these options on the command + line, passin "0" as the partition number to the following options causes + them to use the newly-created partition. For instance, "sgdisk -n + 0:0:+550M -t 0:EF00 /dev/sda" creates a new partition with a type code of + EF00. (Previous versions would ignore the "-t 0:EF00" option.) + - Fixed bug that caused incorrect partition number to be displayed by sgdisk in error messages when the user specified a non-existent partition for inclusion in a hybrid MBR or conversion to a conventional MBR. @@ -335,7 +335,7 @@ OSes, or those that can't boot from a GPT disk, to access up to three of the partitions on the disk by creating MBR entries for them. Note that these hybrid MBR entries can easily go out of sync with the GPT entries, particularly when hybrid\-unaware GPT utilities are used to edit the disk. -Thus, you may need to recreate the hybrid MBR if you use such tools. Unlike +Thus, you may need to re\-create the hybrid MBR if you use such tools. Unlike the 'g' option, this option does not support converting any partitions into MBR logical partitions. @@ -63,7 +63,7 @@ void GPTDataCL::LoadBackupFile(string backupFile, int &saveData, int &neverSaveD int GPTDataCL::DoOptions(int argc, char* argv[]) { GPTData secondDevice; int opt, numOptions = 0, saveData = 0, neverSaveData = 0; - int partNum = 0, saveNonGPT = 1, retval = 0, pretend = 0; + int partNum = 0, newPartNum = -1, saveNonGPT = 1, retval = 0, pretend = 0; uint64_t low, high, startSector, endSector, sSize; uint64_t temp; // temporary variable; free to use in any case char *device; @@ -122,7 +122,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { // Do one loop through the options to find the device filename and deal // with options that don't require a device filename, to flag destructive - // (o, z, or Z) options, and to flag presence of an + // (o, z, or Z) options, and to flag presence of a --pretend/-P option while ((opt = poptGetNextOpt(poptCon)) > 0) { switch (opt) { case 'A': @@ -161,6 +161,8 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { case 'A': { if (cmd != "list") { partNum = (int) GetInt(attributeOperation, 1) - 1; + if (partNum < 0) + partNum = newPartNum; if ((partNum >= 0) && (partNum < (int) GetNumParts())) { switch (ManageAttributes(partNum, GetString(attributeOperation, 2), GetString(attributeOperation, 3))) { @@ -191,9 +193,14 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { free(backupFile); break; case 'c': + cout << "Setting name!\n"; JustLooking(0); partNum = (int) GetInt(partName, 1) - 1; + if (partNum < 0) + partNum = newPartNum; + cout << "partNum is " << partNum << "\n"; if ((partNum >= 0) && (partNum < (int) GetNumParts())) { + cout << "REALLY setting name!\n"; name = GetString(partName, 2); if (SetName(partNum, (UnicodeString) name.c_str())) { saveData = 1; @@ -276,19 +283,19 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { break; case 'n': JustLooking(0); - partNum = (int) GetInt(newPartInfo, 1) - 1; - if (partNum < 0) - partNum = FindFirstFreePart(); + newPartNum = (int) GetInt(newPartInfo, 1) - 1; + if (newPartNum < 0) + newPartNum = FindFirstFreePart(); low = FindFirstInLargest(); Align(&low); high = FindLastInFree(low); startSector = IeeeToInt(GetString(newPartInfo, 2), sSize, low, high, low); endSector = IeeeToInt(GetString(newPartInfo, 3), sSize, startSector, high, high); - if (CreatePartition(partNum, startSector, endSector)) { + if (CreatePartition(newPartNum, startSector, endSector)) { saveData = 1; } else { - cerr << "Could not create partition " << partNum + 1 << " from " - << startSector << " to " << endSector << "\n"; + cerr << "Could not create partition " << newPartNum + 1 << " from " + << startSector << " to " << endSector << "\n"; neverSaveData = 1; } // if/else free(newPartInfo); @@ -351,6 +358,8 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { case 't': JustLooking(0); partNum = (int) GetInt(typeCode, 1) - 1; + if (partNum < 0) + partNum = newPartNum; if ((partNum >= 0) && (partNum < (int) GetNumParts())) { typeHelper = GetString(typeCode, 2); if ((typeHelper != (GUIDData) "00000000-0000-0000-0000-000000000000") && @@ -373,6 +382,8 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { JustLooking(0); saveData = 1; partNum = (int) GetInt(partGUID, 1) - 1; + if (partNum < 0) + partNum = newPartNum; if ((partNum >= 0) && (partNum < (int) GetNumParts())) { SetPartitionGUID(partNum, GetString(partGUID, 2).c_str()); } @@ -8,7 +8,7 @@ #ifndef __GPTSUPPORT #define __GPTSUPPORT -#define GPTFDISK_VERSION "0.8.9.2" +#define GPTFDISK_VERSION "0.8.9.3" #if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__) // Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64 |