From baa7cccc3a9bff1a9a99a9232deac994f811785c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 22 Jan 2013 18:18:29 +0100 Subject: [PATCH] libfdisk: add FDISK_LABEL_FL_ADDPART_NOPARTNO Signed-off-by: Karel Zak --- fdisks/fdisk.c | 5 +---- fdisks/fdiskbsdlabel.c | 3 +++ fdisks/fdiskdoslabel.c | 3 +++ libfdisk/src/fdiskP.h | 7 +++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index d091a5d51..094b7e0f6 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 5ef49cddb..060852bc3 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 e622ac517..a65466bac 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 1301695a6..cef03fc20 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);