Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / tools / vgremove.c
blob5fa63548b14b26cea442f1fd8f5f0beec8646307
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
7 * This file is part of LVM2.
9 * This copyrighted material is made available to anyone wishing to use,
10 * modify, copy, or redistribute it subject to the terms and conditions
11 * of the GNU Lesser General Public License v.2.1.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #include "tools.h"
20 static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
21 struct volume_group *vg,
22 void *handle __attribute((unused)))
24 unsigned lv_count;
25 force_t force;
27 if (!vg_check_status(vg, EXPORTED_VG)) {
28 stack;
29 return ECMD_FAILED;
32 lv_count = vg_visible_lvs(vg);
34 force = arg_count(cmd, force_ARG);
35 if (lv_count) {
36 if ((force == PROMPT) &&
37 (yes_no_prompt("Do you really want to remove volume "
38 "group \"%s\" containing %u "
39 "logical volumes? [y/n]: ",
40 vg_name, lv_count) == 'n')) {
41 log_print("Volume group \"%s\" not removed", vg_name);
42 return ECMD_FAILED;
44 if (!remove_lvs_in_vg(cmd, vg, force)) {
45 stack;
46 return ECMD_FAILED;
50 if (!vg_remove_check(vg)) {
51 stack;
52 return ECMD_FAILED;
55 if (!vg_remove(vg)) {
56 stack;
57 return ECMD_FAILED;
60 return ECMD_PROCESSED;
63 int vgremove(struct cmd_context *cmd, int argc, char **argv)
65 int ret;
67 if (!argc) {
68 log_error("Please enter one or more volume group paths");
69 return EINVALID_CMD_LINE;
72 ret = process_each_vg(cmd, argc, argv,
73 READ_FOR_UPDATE,
74 NULL, &vgremove_single);
76 return ret;