diff options
author | Karel Zak | 2012-12-06 15:13:23 +0100 |
---|---|---|
committer | Karel Zak | 2013-03-11 11:20:41 +0100 |
commit | 7ce10975339ca231953050a6cb6f518d88e64f28 (patch) | |
tree | c61c70d1876fd1c48b4542045a2e936507c739a9 /fdisks/utils.c | |
parent | libfdisk: add fdisk_reset_alignment() (diff) | |
download | kernel-qcow2-util-linux-7ce10975339ca231953050a6cb6f518d88e64f28.tar.gz kernel-qcow2-util-linux-7ce10975339ca231953050a6cb6f518d88e64f28.tar.xz kernel-qcow2-util-linux-7ce10975339ca231953050a6cb6f518d88e64f28.zip |
libfdisk: add probing function
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/utils.c')
-rw-r--r-- | fdisks/utils.c | 82 |
1 files changed, 1 insertions, 81 deletions
diff --git a/fdisks/utils.c b/fdisks/utils.c index 5f4aaccb3..3a6332f2e 100644 --- a/fdisks/utils.c +++ b/fdisks/utils.c @@ -35,86 +35,6 @@ int fdisk_debug_mask; -/* - * Label probing functions. - */ -static const struct fdisk_label *labels[] = -{ - &gpt_label, - &dos_label, - &sun_label, - &sgi_label, - &aix_label, - &bsd_label, - &mac_label, -}; - - -static int __probe_labels(struct fdisk_context *cxt) -{ - size_t i; - - cxt->disklabel = FDISK_DISKLABEL_ANY; - - for (i = 0; i < ARRAY_SIZE(labels); i++) { - if (!labels[i]->probe || labels[i]->probe(cxt) != 1) - continue; - - cxt->label = labels[i]; - - DBG(LABEL, dbgprint("detected a %s label", cxt->label->name)); - return 0; - } - - return 1; /* not found */ -} - -/** - * fdisk_create_disklabel: - * @cxt: fdisk context - * @name: label name - * - * Creates a new disk label of type @name. If @name is NULL, then it - * will create a default system label type, either SUN or DOS. - * - * Returns 0 on success, otherwise, a corresponding error. - */ -int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name) -{ - if (!cxt) - return -EINVAL; - - cxt->label = NULL; - - if (!name) { /* use default label creation */ -#ifdef __sparc__ - cxt->label = &sun_label; -#else - cxt->label = &dos_label; -#endif - } else { - size_t i; - - for (i = 0; i < ARRAY_SIZE(labels); i++) { - if (strcmp(name, labels[i]->name) != 0) - continue; - - cxt->label = labels[i]; - DBG(LABEL, dbgprint("changing to %s label\n", cxt->label->name)); - break; - } - } - - if (!cxt->label) - return -EINVAL; - if (!cxt->label->create) - return -ENOSYS; - - fdisk_reset_alignment(cxt); - - return cxt->label->create(cxt); -} - /** * fdisk_new_context: * @fname: path to the device to be handled @@ -156,7 +76,7 @@ struct fdisk_context *fdisk_new_context_from_filename(const char *fname, int rea /* detect labels and apply labes specific stuff (e.g geomery) * to the context */ - __probe_labels(cxt); + fdisk_probe_labels(cxt); fdisk_reset_alignment(cxt); |