From e17bcc743207dc90e81e04e7edba0d2210a98cf5 Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Wed, 24 Feb 2010 18:15:05 +0000 Subject: Refactor _vgchange_tag() to vg_change_tag() library function. Pull out common code to be called from tools as well as lvm2app. Leave archive() at tool level so we can use from vgcreate as well as vgchange. Should be no functional change. - add stack macro in vgchange Signed-off-by: Dave Wysochanski --- tools/vgchange.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'tools/vgchange.c') diff --git a/tools/vgchange.c b/tools/vgchange.c index b4f5d003..6d869f96 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -447,28 +447,14 @@ static int _vgchange_tag(struct cmd_context *cmd, struct volume_group *vg, return ECMD_FAILED; } - if (!(vg->fid->fmt->features & FMT_TAGS)) { - log_error("Volume group %s does not support tags", vg->name); - return ECMD_FAILED; - } - if (!archive(vg)) { stack; return ECMD_FAILED; } - if ((arg == addtag_ARG)) { - if (!str_list_add(cmd->mem, &vg->tags, tag)) { - log_error("Failed to add tag %s to volume group %s", - tag, vg->name); - return ECMD_FAILED; - } - } else { - if (!str_list_del(&vg->tags, tag)) { - log_error("Failed to remove tag %s from volume group " - "%s", tag, vg->name); - return ECMD_FAILED; - } + if (!vg_change_tag(vg, tag, arg == addtag_ARG)) { + stack; + return ECMD_FAILED; } if (!vg_write(vg) || !vg_commit(vg)) { -- cgit