2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2006 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 lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
19 void *handle __attribute__((unused)))
23 uint64_t lv_capacity_total = 0;
24 int inkernel, snap_active = 1;
25 struct lv_segment *snap_seg = NULL;
26 percent_t snap_percent; /* fused, fsize; */
28 const char *active_str, *snapshot_str;
30 if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
31 return ECMD_PROCESSED;
33 inkernel = lv_info(cmd, lv, 0, &info, 1, 0) && info.exists;
34 if (lv_is_origin(lv)) {
35 dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs,
38 (snap_active = lv_snapshot_percent(snap_seg->cow,
40 if (snap_percent == PERCENT_INVALID)
44 } else if (lv_is_cow(lv)) {
46 (snap_active = lv_snapshot_percent(lv, &snap_percent)))
47 if (snap_percent == PERCENT_INVALID)
51 /* FIXME Add -D arg to skip this! */
52 if (inkernel && snap_active)
53 active_str = "ACTIVE ";
55 active_str = "inactive ";
58 snapshot_str = "Original";
59 else if (lv_is_cow(lv))
60 snapshot_str = "Snapshot";
64 log_print("%s%s '%s%s/%s' [%s] %s", active_str, snapshot_str,
65 cmd->dev_dir, lv->vg->name, lv->name,
66 display_size(cmd, lv->size),
67 get_alloc_string(lv->alloc));
71 lv_capacity_total += lv->size;
73 return ECMD_PROCESSED;
76 int lvscan(struct cmd_context *cmd, int argc, char **argv)
79 log_error("No additional command line arguments allowed");
80 return EINVALID_CMD_LINE;
83 return process_each_lv(cmd, argc, argv, 0, NULL,