From: Karel Zak Date: Tue, 22 Jan 2013 17:18:29 +0000 (+0100) Subject: libfdisk: add FDISK_LABEL_FL_ADDPART_NOPARTNO X-Git-Tag: v2.23-rc1~129 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=baa7cccc3a9bff1a9a99a9232deac994f811785c;p=thirdparty%2Futil-linux.git libfdisk: add FDISK_LABEL_FL_ADDPART_NOPARTNO Signed-off-by: Karel Zak --- diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index d091a5d517..094b7e0f60 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -760,10 +760,7 @@ static void new_partition(struct fdisk_context *cxt) if (warn_geometry(cxt)) return; - if (fdisk_is_disklabel(cxt, SUN) || - fdisk_is_disklabel(cxt, SGI) || - fdisk_is_disklabel(cxt, GPT)) - + if (!(cxt->label->flags & FDISK_LABEL_FL_ADDPART_NOPARTNO)) partnum = get_partition_dflt(cxt, 0, cxt->label->nparts_max, cxt->label->nparts_cur + 1); diff --git a/fdisks/fdiskbsdlabel.c b/fdisks/fdiskbsdlabel.c index 5ef49cddb8..060852bc35 100644 --- a/fdisks/fdiskbsdlabel.c +++ b/fdisks/fdiskbsdlabel.c @@ -972,5 +972,8 @@ struct fdisk_label *fdisk_new_bsd_label(struct fdisk_context *cxt) lb->parttypes = xbsd_fstypes; lb->nparttypes = ARRAY_SIZE(xbsd_fstypes); + /* don't ask for partition number for op->part_add() */ + lb->flags = FDISK_LABEL_FL_ADDPART_NOPARTNO; + return lb; } diff --git a/fdisks/fdiskdoslabel.c b/fdisks/fdiskdoslabel.c index e622ac5176..a65466bac1 100644 --- a/fdisks/fdiskdoslabel.c +++ b/fdisks/fdiskdoslabel.c @@ -1501,6 +1501,9 @@ struct fdisk_label *fdisk_new_dos_label(struct fdisk_context *cxt) lb->parttypes = dos_parttypes; lb->nparttypes = ARRAY_SIZE(dos_parttypes); + /* don't ask for partition number for op->part_add() */ + lb->flags = FDISK_LABEL_FL_ADDPART_NOPARTNO; + return lb; } diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h index 1301695a6b..cef03fc203 100644 --- a/libfdisk/src/fdiskP.h +++ b/libfdisk/src/fdiskP.h @@ -172,11 +172,18 @@ struct fdisk_label { size_t nparts_max; /* maximal number of partitions */ size_t nparts_cur; /* number of currently used partitions */ + int flags; /* FDISK_LABEL_FL_* flags */ + unsigned int changed:1; /* label has been modified */ const struct fdisk_label_operations *op; }; +/* label driver flags */ +enum { + FDISK_LABEL_FL_ADDPART_NOPARTNO = (1 << 1) +}; + /* label allocators */ extern struct fdisk_label *fdisk_new_gpt_label(struct fdisk_context *cxt); extern struct fdisk_label *fdisk_new_dos_label(struct fdisk_context *cxt);