libfdisk: fix sun and sgi to be usable from sfdisk
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
f5aa7b613d
commit
a8a4887bcd
|
@ -39,6 +39,12 @@ sense for new devices.
|
|||
block-device I/O limits when specified by relative sizes, or when default
|
||||
values expected.
|
||||
|
||||
.B sfdisk
|
||||
does not create default system partitions for SGI and SUN disk label like
|
||||
.BR fdisk (8).
|
||||
It is necessary to explicitly create all partitions including whole-disk system
|
||||
partitions.
|
||||
|
||||
.SH COMMANDS
|
||||
The commands are mutually exclusive.
|
||||
.TP
|
||||
|
|
|
@ -1226,8 +1226,13 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
|
|||
if (rc == 0)
|
||||
rc = SFDISK_DONE_ASK;
|
||||
break;
|
||||
} else if (!rc) /* add partition */
|
||||
} else if (!rc) { /* add partition */
|
||||
rc = fdisk_add_partition(sf->cxt, pa, &cur_partno);
|
||||
if (rc) {
|
||||
errno = -rc;
|
||||
fdisk_warn(sf->cxt, _("failed to add partition"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!rc) { /* success, print reult */
|
||||
sfdisk_print_partition(sf, cur_partno);
|
||||
|
|
|
@ -552,6 +552,8 @@ static int verify_disklabel(struct fdisk_context *cxt, int verbose)
|
|||
if (sortcount == 0) {
|
||||
if (verbose)
|
||||
fdisk_info(cxt, _("No partitions defined."));
|
||||
if (lastblock)
|
||||
add_to_freelist(cxt, 0, lastblock);
|
||||
return (lastblock > 0) ? 1 : (lastblock == 0) ? 0 : -1;
|
||||
}
|
||||
|
||||
|
@ -789,7 +791,7 @@ static int sgi_add_partition(struct fdisk_context *cxt,
|
|||
"Delete it before re-adding it."), n + 1);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sgi_entire(cxt) == -1 && sys != SGI_TYPE_ENTIRE_DISK) {
|
||||
if (!cxt->script && sgi_entire(cxt) == -1 && sys != SGI_TYPE_ENTIRE_DISK) {
|
||||
fdisk_info(cxt, _("Attempting to generate entire disk entry automatically."));
|
||||
sgi_set_entire(cxt);
|
||||
sgi_set_volhdr(cxt);
|
||||
|
@ -853,11 +855,11 @@ static int sgi_add_partition(struct fdisk_context *cxt,
|
|||
|
||||
/* last sector */
|
||||
if (pa && pa->end_follow_default)
|
||||
last -= 1;
|
||||
last -= 1ULL;
|
||||
else if (pa && pa->size) {
|
||||
if (first + pa->size > last)
|
||||
if (first + pa->size - 1ULL > last)
|
||||
return -ERANGE;
|
||||
last = first + pa->size;
|
||||
last = first + pa->size - 1ULL;
|
||||
} else {
|
||||
snprintf(mesg, sizeof(mesg),
|
||||
_("Last %s or +%s or +size{K,M,G,T,P}"),
|
||||
|
@ -990,9 +992,12 @@ static int sgi_create_disklabel(struct fdisk_context *cxt)
|
|||
memset(&(sgilabel->partitions), 0,
|
||||
sizeof(struct sgi_partition) * SGI_MAXPARTITIONS);
|
||||
cxt->label->nparts_max = SGI_MAXPARTITIONS;
|
||||
sgi_set_entire(cxt);
|
||||
sgi_set_volhdr(cxt);
|
||||
|
||||
/* don't create default layout when a script defined */
|
||||
if (!cxt->script) {
|
||||
sgi_set_entire(cxt);
|
||||
sgi_set_volhdr(cxt);
|
||||
}
|
||||
cxt->label->nparts_cur = count_used_partitions(cxt);
|
||||
|
||||
fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
|
||||
|
|
|
@ -261,16 +261,19 @@ static int sun_create_disklabel(struct fdisk_context *cxt)
|
|||
} else
|
||||
ndiv = cxt->geom.cylinders * 2 / 3;
|
||||
|
||||
set_partition(cxt, 0, 0, ndiv * cxt->geom.heads * cxt->geom.sectors,
|
||||
/* create the default layout only if no-script defined */
|
||||
if (!cxt->script) {
|
||||
set_partition(cxt, 0, 0, ndiv * cxt->geom.heads * cxt->geom.sectors,
|
||||
SUN_TAG_LINUX_NATIVE);
|
||||
set_partition(cxt, 1, ndiv * cxt->geom.heads * cxt->geom.sectors,
|
||||
set_partition(cxt, 1, ndiv * cxt->geom.heads * cxt->geom.sectors,
|
||||
cxt->geom.cylinders * cxt->geom.heads * cxt->geom.sectors,
|
||||
SUN_TAG_LINUX_SWAP);
|
||||
sunlabel->vtoc.infos[1].flags |= cpu_to_be16(SUN_FLAG_UNMNT);
|
||||
sunlabel->vtoc.infos[1].flags |= cpu_to_be16(SUN_FLAG_UNMNT);
|
||||
|
||||
set_partition(cxt, 2, 0,
|
||||
set_partition(cxt, 2, 0,
|
||||
cxt->geom.cylinders * cxt->geom.heads * cxt->geom.sectors,
|
||||
SUN_TAG_WHOLEDISK);
|
||||
}
|
||||
|
||||
{
|
||||
unsigned short *ush = (unsigned short *)sunlabel;
|
||||
|
|
Loading…
Reference in New Issue