Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / tools / vgimport.c
blob987307bf726b151bd521f0b30f494bde6e312df3
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 vgimport_single(struct cmd_context *cmd __attribute((unused)),
21 const char *vg_name,
22 struct volume_group *vg,
23 void *handle __attribute((unused)))
25 struct pv_list *pvl;
26 struct physical_volume *pv;
28 if (!vg_is_exported(vg)) {
29 log_error("Volume group \"%s\" is not exported", vg_name);
30 goto bad;
33 if (vg_status(vg) & PARTIAL_VG) {
34 log_error("Volume group \"%s\" is partially missing", vg_name);
35 goto bad;
38 if (!archive(vg))
39 goto_bad;
41 vg->status &= ~EXPORTED_VG;
43 dm_list_iterate_items(pvl, &vg->pvs) {
44 pv = pvl->pv;
45 pv->status &= ~EXPORTED_VG;
48 if (!vg_write(vg) || !vg_commit(vg))
49 goto_bad;
51 backup(vg);
53 log_print("Volume group \"%s\" successfully imported", vg->name);
55 return ECMD_PROCESSED;
57 bad:
58 return ECMD_FAILED;
61 int vgimport(struct cmd_context *cmd, int argc, char **argv)
63 if (!argc && !arg_count(cmd, all_ARG)) {
64 log_error("Please supply volume groups or use -a for all.");
65 return ECMD_FAILED;
68 if (argc && arg_count(cmd, all_ARG)) {
69 log_error("No arguments permitted when using -a for all.");
70 return ECMD_FAILED;
73 return process_each_vg(cmd, argc, argv,
74 READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
75 NULL,
76 &vgimport_single);