libfdisk: add FDISK_LABEL_FL_ADDPART_NOPARTNO

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2013-01-22 18:18:29 +01:00
parent 9ffeb235d6
commit baa7cccc3a
4 changed files with 14 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);