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
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);
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;
}
"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);
/* 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}"),
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,
} 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;