]> sourceware.org Git - lvm2.git/blob - tools/vgremove.c
Reinstate accidentally-deleted line.
[lvm2.git] / tools / vgremove.c
1 /*
2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
4 *
5 * This file is part of LVM2.
6 *
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
10 *
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 */
15
16 #include "tools.h"
17
18 static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
19 struct volume_group *vg,
20 void *handle __attribute__((unused)))
21 {
22 unsigned lv_count, missing;
23 force_t force;
24
25 if (!vg_check_status(vg, EXPORTED_VG)) {
26 stack;
27 return ECMD_FAILED;
28 }
29
30 lv_count = vg_visible_lvs(vg);
31
32 force = (force_t) arg_count(cmd, force_ARG);
33 if (lv_count) {
34 if (force == PROMPT) {
35 if ((missing = vg_missing_pv_count(vg)))
36 log_warn("WARNING: %d physical volumes are currently missing "
37 "from the system.", missing);
38 if (yes_no_prompt("Do you really want to remove volume "
39 "group \"%s\" containing %u "
40 "logical volumes? [y/n]: ",
41 vg_name, lv_count) == 'n') {
42 log_error("Volume group \"%s\" not removed", vg_name);
43 return ECMD_FAILED;
44 }
45 }
46 if (!remove_lvs_in_vg(cmd, vg, force)) {
47 stack;
48 return ECMD_FAILED;
49 }
50 }
51
52 if (!force && !vg_remove_check(vg)) {
53 stack;
54 return ECMD_FAILED;
55 }
56
57 vg_remove_pvs(vg);
58
59 if (!vg_remove(vg)) {
60 stack;
61 return ECMD_FAILED;
62 }
63
64 return ECMD_PROCESSED;
65 }
66
67 int vgremove(struct cmd_context *cmd, int argc, char **argv)
68 {
69 int ret;
70
71 if (!argc) {
72 log_error("Please enter one or more volume group paths");
73 return EINVALID_CMD_LINE;
74 }
75
76 cmd->handles_missing_pvs = 1;
77 ret = process_each_vg(cmd, argc, argv,
78 READ_FOR_UPDATE,
79 NULL, &vgremove_single);
80
81 return ret;
82 }
This page took 0.037389 seconds and 5 git commands to generate.