Branch data Line data Source code
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 : 0 : 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 [ # # ]: 0 : if (!vg_check_status(vg, EXPORTED_VG)) {
26 : 0 : stack;
27 : 0 : return ECMD_FAILED;
28 : : }
29 : :
30 : 0 : lv_count = vg_visible_lvs(vg);
31 : :
32 : 0 : force = arg_count(cmd, force_ARG);
33 [ # # ]: 0 : if (lv_count) {
34 [ # # ]: 0 : if (force == PROMPT) {
35 [ # # ]: 0 : if ((missing = vg_missing_pv_count(vg)))
36 : 0 : log_warn("WARNING: %d physical volumes are currently missing "
37 : : "from the system.", missing);
38 [ # # ]: 0 : 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 : 0 : log_error("Volume group \"%s\" not removed", vg_name);
43 : 0 : return ECMD_FAILED;
44 : : }
45 : : }
46 [ # # ]: 0 : if (!remove_lvs_in_vg(cmd, vg, force)) {
47 : 0 : stack;
48 : 0 : return ECMD_FAILED;
49 : : }
50 : : }
51 : :
52 [ # # ]: 0 : if (!vg_remove_check(vg)) {
53 : 0 : stack;
54 : 0 : return ECMD_FAILED;
55 : : }
56 : :
57 [ # # ]: 0 : if (!vg_remove(vg)) {
58 : 0 : stack;
59 : 0 : return ECMD_FAILED;
60 : : }
61 : :
62 : 0 : return ECMD_PROCESSED;
63 : : }
64 : :
65 : 0 : int vgremove(struct cmd_context *cmd, int argc, char **argv)
66 : : {
67 : : int ret;
68 : :
69 [ # # ]: 0 : if (!argc) {
70 : 0 : log_error("Please enter one or more volume group paths");
71 : 0 : return EINVALID_CMD_LINE;
72 : : }
73 : :
74 : 0 : cmd->handles_missing_pvs = 1;
75 : 0 : ret = process_each_vg(cmd, argc, argv,
76 : : READ_FOR_UPDATE,
77 : : NULL, &vgremove_single);
78 : :
79 : 0 : return ret;
80 : : }
|