Bug 1249893 - sfdisk: Clarification of "+" and "-" as size arguments
Summary: sfdisk: Clarification of "+" and "-" as size arguments
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-08-04 05:12 UTC by Ian Wienand
Modified: 2015-08-05 07:24 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-08-05 07:24:06 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
clarification for sfdisk man page (3.54 KB, patch)
2015-08-05 02:27 UTC, Ian Wienand
no flags Details | Diff

Description Ian Wienand 2015-08-04 05:12:15 UTC
The man page says

"The default value of size is as much as possible (until the next partition or end-of-device).  A '+' can be used instead of a number for size, which also means as much as possible."

However the source is setting FDISK_RESIZE_ENLARGE when you use a '+' for size; something not done for the default case? [1]

I can't find any difference between the "+" and "-" in some empirical testing, but it would be good to clarify what's going on. 

[1] https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/libfdisk/src/script.c#n1050

Comment 1 Karel Zak 2015-08-04 07:29:47 UTC
The "-" has no any meaning, it's just place-holder to support formats without delimiters, like "2048 - L *". Note that "-<num>" means reduce size.

The unspecified size field means "follow the label driver default" -- it's usually all available space for a new partition.

The "+" calls generic resize code if used for *already existing partition*, if the partition does not exist then it's the same as the previous case (driver default).

For example:

 2048 , , L
 2048, -, L
 2048, +, L

all have the same meaning, for empty disk, but

 echo "2048, +, L" | sfdisk -N 1 /dev/sdb

enlarge the first partition (-N 1) as much as possible.

So, it depends on context, for empty disks where you create a new partitions (fdisk_add_partition()) it's always driver default, for existing partition it's about resizing (fdisk_set_partition()).

Note that the parser in the script.c has no clue about the current disk layout, it's the reason why it sets fdisk_partition_end_follow_default() as well as FDISK_RESIZE_ENLARGE for alone "+". The final interpretation depends on used function (fdisk_{add,set}_partition()).

Please, close if you have enough information :-) Thanks.

Comment 2 Ian Wienand 2015-08-05 02:27:07 UTC
Created attachment 1059296 [details]
clarification for sfdisk man page

Thank you for the info.  Do you think something like the attached patch might help clarify the sfdisk man page?

Comment 3 Karel Zak 2015-08-05 07:24:06 UTC
(In reply to Ian Wienand from comment #2)
> Do you think something like the attached patch
> might help clarify the sfdisk man page?

Applied, thanks.

https://github.com/karelzak/util-linux/commit/11aa2aa290d2d654d621bd4729b535234480734b

The change will be available in f23.


Note You need to log in before you can comment on or make changes to this bug.