2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
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.
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
18 static int vgexport_single(struct cmd_context *cmd __attribute__((unused)),
20 struct volume_group *vg,
21 void *handle __attribute__((unused)))
24 struct physical_volume *pv;
26 if (lvs_in_vg_activated(vg)) {
27 log_error("Volume group \"%s\" has active logical volumes",
35 vg->status |= EXPORTED_VG;
37 dm_list_iterate_items(pvl, &vg->pvs) {
39 pv->status |= EXPORTED_VG;
42 if (!vg_write(vg) || !vg_commit(vg))
47 log_print("Volume group \"%s\" successfully exported", vg->name);
49 return ECMD_PROCESSED;
55 int vgexport(struct cmd_context *cmd, int argc, char **argv)
57 if (!argc && !arg_count(cmd, all_ARG)) {
58 log_error("Please supply volume groups or use -a for all.");
62 if (argc && arg_count(cmd, all_ARG)) {
63 log_error("No arguments permitted when using -a for all.");
67 return process_each_vg(cmd, argc, argv, READ_FOR_UPDATE, NULL,