diff options
author | Karel Zak | 2013-10-09 16:02:33 +0200 |
---|---|---|
committer | Karel Zak | 2013-10-09 16:02:33 +0200 |
commit | 7a188aedbf4468e9753200716ec845a00dd8b30e (patch) | |
tree | cbdf161b040688bc81cd1d6b1369d311a25569c6 /libfdisk/src/context.c | |
parent | cytune: fix glush typo in cytune (diff) | |
download | kernel-qcow2-util-linux-7a188aedbf4468e9753200716ec845a00dd8b30e.tar.gz kernel-qcow2-util-linux-7a188aedbf4468e9753200716ec845a00dd8b30e.tar.xz kernel-qcow2-util-linux-7a188aedbf4468e9753200716ec845a00dd8b30e.zip |
libfdisk: add API to disable specified label
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r-- | libfdisk/src/context.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index c5d2329cf..9106e29b3 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -102,11 +102,38 @@ struct fdisk_label *fdisk_context_get_label(struct fdisk_context *cxt, const cha return NULL; } +int fdisk_context_next_label(struct fdisk_context *cxt, struct fdisk_label **lb) +{ + size_t i; + struct fdisk_label *res = NULL; + + if (!lb || !cxt) + return -EINVAL; + + if (!*lb) + res = cxt->labels[0]; + else { + for (i = 1; i < cxt->nlabels; i++) { + if (*lb == cxt->labels[i - 1]) { + res = cxt->labels[i]; + break; + } + } + } + + *lb = res; + return res ? 0 : 1; +} + int __fdisk_context_switch_label(struct fdisk_context *cxt, struct fdisk_label *lb) { - if (!lb) + if (!lb || !cxt) + return -EINVAL; + if (lb->disabled) { + DBG(LABEL, dbgprint("*** attempt to switch to disabled label %s -- ignore!", lb->name)); return -EINVAL; + } cxt->label = lb; DBG(LABEL, dbgprint("--> switching context to %s!", lb->name)); return 0; |