diff options
author | David Joaquín Shourabi Porcel <david@djsp.eu> | 2023-01-28 16:19:16 +0100 |
---|---|---|
committer | David Joaquín Shourabi Porcel <david@djsp.eu> | 2023-01-28 17:45:22 +0100 |
commit | caf30c022c5f659bb7a5e52272c6aeca94098c70 (patch) | |
tree | d254ca8ef2c00943ae87f3ab1db6658f0a3b18a1 | |
parent | 913f7b48647bdbd23fdc4abccf2168b061273aa4 (diff) | |
download | sgdisk-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.cc | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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 { |