summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Joaquín Shourabi Porcel <david@djsp.eu>2023-01-28 16:19:16 +0100
committerDavid Joaquín Shourabi Porcel <david@djsp.eu>2023-01-28 17:45:22 +0100
commitcaf30c022c5f659bb7a5e52272c6aeca94098c70 (patch)
treed254ca8ef2c00943ae87f3ab1db6658f0a3b18a1
parent913f7b48647bdbd23fdc4abccf2168b061273aa4 (diff)
downloadsgdisk-caf30c022c5f659bb7a5e52272c6aeca94098c70.tar.gz
Allow partition dynamically allocated by --largest-new to be referenced by other options
The documentation for the option --new explains that: > [a] partnum value of 0 causes the program to use the first available > partition number. Subsequent uses of the -A (--attributes), -c > (--change-name), -t (--typecode), and -u (--partition-guid) options > may also use 0 to refer to the same partition. Although the documentation for the option --largest-new does not mention such functionality, I expected it, and was puzzled when it didn't work.
-rw-r--r--gptcl.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gptcl.cc b/gptcl.cc
index 0d578eb..e8d394a 100644
--- a/gptcl.cc
+++ b/gptcl.cc
@@ -331,8 +331,10 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
startSector = FindFirstInLargest();
Align(&startSector);
endSector = FindLastInFree(startSector, alignEnd);
- if (largestPartNum <= 0)
+ if (largestPartNum <= 0) {
largestPartNum = FindFirstFreePart() + 1;
+ newPartNum = largestPartNum - 1;
+ }
if (CreatePartition(largestPartNum - 1, startSector, endSector)) {
saveData = 1;
} else {