struct fdisk_context *cxt;
struct fdisk_partition *pa;
const char *label = NULL, *device = NULL;
- int n = 0, c;
+ int n = 0, c, nopartno = 0;
unsigned int sectorsize;
static const struct option longopts[] = {
{ "label", required_argument, NULL, 'x' },
{ "device", required_argument, NULL, 'd' },
+ { "nopartno", no_argument, NULL, 'p' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 },
};
case 'd':
device = optarg;
break;
+ case 'p':
+ nopartno = 1;
+ break;
case 'h':
printf("%s [options] <size> ...", program_invocation_short_name);
fputs(USAGE_SEPARATOR, stdout);
fputs(USAGE_OPTIONS, stdout);
fputs(" -x, --label <dos,gpt,...> disk label type\n", stdout);
fputs(" -d, --device <path> block device\n", stdout);
+ fputs(" -p, --nopartno don't set partno (use default)\n", stdout);
fputs(" -h, --help this help\n", stdout);
fputs(USAGE_SEPARATOR, stdout);
return EXIT_SUCCESS;
sectorsize = fdisk_get_sector_size(cxt);
+ fdisk_disable_dialogs(cxt, 1);
+
while (optind < argc) {
int rc;
uint64_t size;
/* defaults */
fdisk_partition_start_follow_default(pa, 1);
fdisk_partition_end_follow_default(pa, 1);
+ fdisk_partition_partno_follow_default(pa, 1);
/* set size */
if (isdigit(*str)) {
* This is possible by explicitly specified partition
* number, <4 means primary, >=4 means logical.
*/
- fdisk_partition_partno_follow_default(pa, 0);
- fdisk_partition_set_partno(pa, n);
+ if (!nopartno) {
+ fdisk_partition_partno_follow_default(pa, 0);
+ fdisk_partition_set_partno(pa, n);
+ }
/* Make sure last primary partition is extended if user
* wants more than 4 partitions.
fdisk_partition_set_type(pa, type);
fdisk_unref_parttype(type);
}
- } else
- fdisk_partition_partno_follow_default(pa, 1);
-
+ }
rc = fdisk_add_partition(cxt, pa, NULL);
if (rc) {
--- /dev/null
+Created a new <removed>.
+Created a new <removed>.
+Created a new <removed>.
+Created a new <removed>.
+Created a new <removed>.
+Adding logical partition 5
+Created a new <removed>.
+Adding logical partition 6
+Created a new <removed>.
+Adding logical partition 7
+Created a new <removed>.
+Disk <removed>: 15 MiB, 15728640 bytes, 30720 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 2048 4095 2048 1M 83 Linux
+<removed>2 4096 6143 2048 1M 83 Linux
+<removed>3 6144 8191 2048 1M 83 Linux
+<removed>4 8192 30719 22528 11M 5 Extended
+<removed>5 10240 12287 2048 1M 83 Linux
+<removed>6 14336 16383 2048 1M 83 Linux
+<removed>7 18432 30719 12288 6M 83 Linux