sfdisk: fix previous --append patch, improve man page
- fix stupid typo (!has_container_or_unused(sf)) - use fdisk_is_partition_used() as fdisk_get_partition() returns nothing for unused partition - update tests - add more hints to the man page Addresses: https://github.com/calamares/calamares/issues/1332 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
fa3fface0f
commit
ac762ed71f
|
@ -74,6 +74,10 @@ the event handling on the device. For example:
|
||||||
.sp
|
.sp
|
||||||
.RE
|
.RE
|
||||||
Note, this semantic is not currently supported by udevd for MD and DM devices.
|
Note, this semantic is not currently supported by udevd for MD and DM devices.
|
||||||
|
.PP
|
||||||
|
The sfdisk prompt is only a hint for users and a displayed partition number does
|
||||||
|
not mean that the same partition table entry will be created (if -N not
|
||||||
|
specified), especially for tables with gaps.
|
||||||
|
|
||||||
.SH COMMANDS
|
.SH COMMANDS
|
||||||
The commands are mutually exclusive.
|
The commands are mutually exclusive.
|
||||||
|
@ -189,6 +193,10 @@ tools can automatically relocate the header to follow the standard.
|
||||||
.TP
|
.TP
|
||||||
.BR \-a , " \-\-append"
|
.BR \-a , " \-\-append"
|
||||||
Don't create a new partition table, but only append the specified partitions.
|
Don't create a new partition table, but only append the specified partitions.
|
||||||
|
.sp
|
||||||
|
Note that unused partition maybe be re-used in this case although it is not the
|
||||||
|
last partition in the partition table. See also \fB\-N\fR to specify entry in
|
||||||
|
the partition table.
|
||||||
.TP
|
.TP
|
||||||
.BR \-b , " \-\-backup"
|
.BR \-b , " \-\-backup"
|
||||||
Back up the current partition table sectors before starting the partitioning.
|
Back up the current partition table sectors before starting the partitioning.
|
||||||
|
|
|
@ -1530,10 +1530,13 @@ static int has_container_or_unused(struct sfdisk *sf)
|
||||||
|
|
||||||
nparts = fdisk_get_npartitions(sf->cxt);
|
nparts = fdisk_get_npartitions(sf->cxt);
|
||||||
for (i = 0; i < nparts; i++) {
|
for (i = 0; i < nparts; i++) {
|
||||||
|
|
||||||
|
if (!fdisk_is_partition_used(sf->cxt, i)) {
|
||||||
|
sf->unused = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (fdisk_get_partition(sf->cxt, i, &pa) != 0)
|
if (fdisk_get_partition(sf->cxt, i, &pa) != 0)
|
||||||
continue;
|
continue;
|
||||||
if (!fdisk_partition_is_used(pa))
|
|
||||||
sf->unused = 1;
|
|
||||||
if (fdisk_partition_is_container(pa))
|
if (fdisk_partition_is_container(pa))
|
||||||
sf->container = 1;
|
sf->container = 1;
|
||||||
}
|
}
|
||||||
|
@ -1840,7 +1843,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
|
||||||
if (created
|
if (created
|
||||||
&& partno < 0
|
&& partno < 0
|
||||||
&& next_partno == fdisk_get_npartitions(sf->cxt)
|
&& next_partno == fdisk_get_npartitions(sf->cxt)
|
||||||
&& has_container_or_unused(sf)) {
|
&& !has_container_or_unused(sf)) {
|
||||||
fdisk_info(sf->cxt, _("All partitions used."));
|
fdisk_info(sf->cxt, _("All partitions used."));
|
||||||
rc = SFDISK_DONE_ASK;
|
rc = SFDISK_DONE_ASK;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,7 +12,7 @@ I/O size (minimum/optimal): 4096 bytes / <removed> bytes
|
||||||
<removed>2: Ignoring partition.
|
<removed>2: Ignoring partition.
|
||||||
<removed>3: Created a new <removed>.
|
<removed>3: Created a new <removed>.
|
||||||
<removed>4: Ignoring partition.
|
<removed>4: Ignoring partition.
|
||||||
All partitions used.
|
<removed>5: Done.
|
||||||
|
|
||||||
New situation:
|
New situation:
|
||||||
Disklabel type: dos
|
Disklabel type: dos
|
||||||
|
|
|
@ -12,7 +12,7 @@ I/O size (minimum/optimal): 4096 bytes / <removed> bytes
|
||||||
<removed>2: Ignoring partition.
|
<removed>2: Ignoring partition.
|
||||||
<removed>3: Ignoring partition.
|
<removed>3: Ignoring partition.
|
||||||
<removed>4: Ignoring partition.
|
<removed>4: Ignoring partition.
|
||||||
All partitions used.
|
<removed>5: Done.
|
||||||
|
|
||||||
New situation:
|
New situation:
|
||||||
Disklabel type: dos
|
Disklabel type: dos
|
||||||
|
|
Loading…
Reference in New Issue