static void sgi_add_partition(int n, int sys) { char mesg[256]; unsigned int first = 0, last = 0; if (n == 10) { sys = SGI_VOLUME; } else if (n == 8) { sys = 0; } if (sgi_get_num_sectors(n)) { printf(msg_part_already_defined, n + 1); return; } if ((sgi_entire() == -1) && (sys != SGI_VOLUME)) { printf("Attempting to generate entire disk entry automatically\n"); sgi_set_entire(); sgi_set_volhdr(); } if ((sgi_gaps() == 0) && (sys != SGI_VOLUME)) { printf("The entire disk is already covered with partitions\n"); return; } if (sgi_gaps() < 0) { printf("You got a partition overlap on the disk. Fix it first!\n"); return; } snprintf(mesg, sizeof(mesg), "First %s", str_units(SINGULAR)); while (1) { if (sys == SGI_VOLUME) { last = sgi_get_lastblock(); first = read_int(0, 0, last-1, 0, mesg); if (first != 0) { printf("It is highly recommended that eleventh partition\n" "covers the entire disk and is of type 'SGI volume'\n"); } } else { first = freelist[0].first; last = freelist[0].last; first = read_int(scround(first), scround(first), scround(last)-1, 0, mesg); } if (display_in_cyl_units) first *= units_per_sector; else first = first; /* align to cylinder if you know how ... */ if (!last ) last = isinfreelist(first); if (last != 0) break; printf("You will get a partition overlap on the disk. " "Fix it first!\n"); } snprintf(mesg, sizeof(mesg), " Last %s", str_units(SINGULAR)); last = read_int(scround(first), scround(last)-1, scround(last)-1, scround(first), mesg)+1; if (display_in_cyl_units) last *= units_per_sector; else last = last; /* align to cylinder if You know how ... */ if ( (sys == SGI_VOLUME) && (first != 0 || last != sgi_get_lastblock() ) ) printf("It is highly recommended that eleventh partition\n" "covers the entire disk and is of type 'SGI volume'\n"); sgi_set_partition(n, first, last-first, sys); }
static int sgi_add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype *t) { char mesg[256]; unsigned int first=0, last=0; int sys = t ? t->type : SGI_XFS; if (n == 10) sys = SGI_VOLUME; else if (n == 8) sys = 0; if (sgi_get_num_sectors(cxt, n)) { printf(_("Partition %d is already defined. Delete " "it before re-adding it.\n"), n + 1); return -EINVAL; } if ((sgi_entire(cxt) == -1) && (sys != SGI_VOLUME)) { printf(_("Attempting to generate entire disk entry automatically.\n")); sgi_set_entire(cxt); sgi_set_volhdr(cxt); } if ((sgi_gaps(cxt) == 0) && (sys != SGI_VOLUME)) { printf(_("The entire disk is already covered with partitions.\n")); return -EINVAL; } if (sgi_gaps(cxt) < 0) { printf(_("You got a partition overlap on the disk. Fix it first!\n")); return -EINVAL; } snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); for (;;) { if (sys == SGI_VOLUME) { last = sgi_get_lastblock(cxt); first = read_int(cxt, 0, 0, last-1, 0, mesg); if (first != 0) { printf(_("It is highly recommended that eleventh partition\n" "covers the entire disk and is of type `SGI volume'\n")); } } else { first = freelist[0].first; last = freelist[0].last; first = read_int(cxt, scround(first), scround(first), scround(last)-1, 0, mesg); } if (display_in_cyl_units) first *= units_per_sector; /*else first = first; * align to cylinder if you know how ... */ if (!last) last = isinfreelist(first); if (last == 0) { printf(_("You will get a partition overlap on the disk. " "Fix it first!\n")); } else break; } snprintf(mesg, sizeof(mesg), _(" Last %s"), str_units(SINGULAR)); last = read_int(cxt, scround(first), scround(last)-1, scround(last)-1, scround(first), mesg)+1; if (display_in_cyl_units) last *= units_per_sector; /*else last = last; * align to cylinder if You know how ... */ if ((sys == SGI_VOLUME) && (first != 0 || last != sgi_get_lastblock(cxt))) printf(_("It is highly recommended that eleventh partition\n" "covers the entire disk and is of type `SGI volume'\n")); sgi_set_partition(cxt, n, first, last-first, sys); return 0; }