]> sourceware.org Git - lvm2.git/blame - tools/vgscan.c
thin: tighten discard string conversions
[lvm2.git] / tools / vgscan.c
CommitLineData
6e91eeef 1/*
67cdbd7e 2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
905240f9 3 * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
6e91eeef 4 *
6606c3ae 5 * This file is part of LVM2.
6e91eeef 6 *
6606c3ae
AK
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
be684599 9 * of the GNU Lesser General Public License v.2.1.
6e91eeef 10 *
be684599 11 * You should have received a copy of the GNU Lesser General Public License
6606c3ae
AK
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
6e91eeef
AK
14 */
15
16#include "tools.h"
17
3be9089c
PR
18static int _lvmetad;
19
5a52dca9 20static int vgscan_single(struct cmd_context *cmd, const char *vg_name,
13e8c7e4 21 struct volume_group *vg,
08f1ddea 22 void *handle __attribute__((unused)))
5a52dca9 23{
5a52dca9 24 log_print("Found %svolume group \"%s\" using metadata type %s",
905240f9 25 vg_is_exported(vg) ? "exported " : "", vg_name,
5a52dca9
AK
26 vg->fid->fmt->name);
27
24e65464 28 check_current_backup(vg);
dc9ef7a0 29
3be9089c
PR
30 /* keep lvmetad up to date, restore the "active" state temporarily */
31 lvmetad_set_active(_lvmetad);
dc9ef7a0
AK
32 if (!lvmetad_vg_update(vg))
33 stack;
3be9089c 34 lvmetad_set_active(0);
24e65464 35
cfb7bfc7 36 return ECMD_PROCESSED;
5a52dca9 37}
6e91eeef 38
60274aba 39int vgscan(struct cmd_context *cmd, int argc, char **argv)
6e91eeef 40{
3be9089c 41 int maxret, ret;
5a8fa8c9 42
6e91eeef
AK
43 if (argc) {
44 log_error("Too many parameters on command line");
45 return EINVALID_CMD_LINE;
46 }
47
e935d217
AK
48 if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
49 log_error("Unable to obtain global lock.");
50 return ECMD_FAILED;
51 }
52
60274aba 53 persistent_filter_wipe(cmd->filter);
6eb44b50 54 lvmcache_destroy(cmd, 1);
3be9089c
PR
55
56 _lvmetad = lvmetad_active();
57 if (arg_count(cmd, cache_ARG)) {
58 if (_lvmetad)
59 lvmetad_set_active(0); /* do not rely on lvmetad info */
60 else {
61 log_error("Cannot proceed since lvmetad is not active.");
62 unlock_vg(cmd, VG_GLOBAL);
63 return ECMD_FAILED;
64 }
65 }
d2393d23 66
1176eb25 67 log_print("Reading all physical volumes. This may take a while...");
6e91eeef 68
13e8c7e4 69 maxret = process_each_vg(cmd, argc, argv, 0, NULL,
5a8fa8c9
AK
70 &vgscan_single);
71
72 if (arg_count(cmd, mknodes_ARG)) {
73 ret = vgmknodes(cmd, argc, argv);
74 if (ret > maxret)
75 maxret = ret;
76 }
77
3be9089c 78 lvmetad_set_active(_lvmetad); /* restore */
e935d217 79 unlock_vg(cmd, VG_GLOBAL);
5a8fa8c9 80 return maxret;
6e91eeef 81}
This page took 0.106842 seconds and 5 git commands to generate.