4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2006 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
20 static int lvscan_single(struct cmd_context
*cmd
, struct logical_volume
*lv
,
21 void *handle
__attribute((unused
)))
25 uint64_t lv_capacity_total
= 0;
26 int inkernel
, snap_active
= 1;
27 struct lv_segment
*snap_seg
= NULL
;
28 float snap_percent
; /* fused, fsize; */
29 percent_range_t percent_range
;
31 const char *active_str
, *snapshot_str
;
33 if (!arg_count(cmd
, all_ARG
) && !lv_is_visible(lv
))
34 return ECMD_PROCESSED
;
36 inkernel
= lv_info(cmd
, lv
, &info
, 1, 0) && info
.exists
;
37 if (lv_is_origin(lv
)) {
38 dm_list_iterate_items_gen(snap_seg
, &lv
->snapshot_segs
,
41 (snap_active
= lv_snapshot_percent(snap_seg
->cow
,
44 if (percent_range
== PERCENT_INVALID
)
48 } else if (lv_is_cow(lv
)) {
50 (snap_active
= lv_snapshot_percent(lv
, &snap_percent
,
52 if (percent_range
== PERCENT_INVALID
)
56 /* FIXME Add -D arg to skip this! */
57 if (inkernel
&& snap_active
)
58 active_str
= "ACTIVE ";
60 active_str
= "inactive ";
63 snapshot_str
= "Original";
64 else if (lv_is_cow(lv
))
65 snapshot_str
= "Snapshot";
69 log_print("%s%s '%s%s/%s' [%s] %s", active_str
, snapshot_str
,
70 cmd
->dev_dir
, lv
->vg
->name
, lv
->name
,
71 display_size(cmd
, lv
->size
),
72 get_alloc_string(lv
->alloc
));
76 lv_capacity_total
+= lv
->size
;
78 return ECMD_PROCESSED
;
81 int lvscan(struct cmd_context
*cmd
, int argc
, char **argv
)
84 log_error("No additional command line arguments allowed");
85 return EINVALID_CMD_LINE
;
88 return process_each_lv(cmd
, argc
, argv
, 0, NULL
,