2002-12-12 23:55:49 +03:00
/*
2008-01-30 17:00:02 +03:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2009-02-09 12:45:49 +03:00
* Copyright ( C ) 2004 - 2009 Red Hat , Inc . All rights reserved .
2002-12-12 23:55:49 +03:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2 .
2002-12-12 23:55:49 +03:00
*
2004-03-30 23:35:44 +04:00
* This copyrighted material is made available to anyone wishing to use ,
* modify , copy , or redistribute it subject to the terms and conditions
2007-08-21 00:55:30 +04:00
* of the GNU Lesser General Public License v .2 .1 .
2002-12-12 23:55:49 +03:00
*
2007-08-21 00:55:30 +04:00
* You should have received a copy of the GNU Lesser General Public License
2004-03-30 23:35:44 +04:00
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
2002-12-12 23:55:49 +03:00
*/
# include "tools.h"
# include "report.h"
2010-07-09 19:34:40 +04:00
static int _vgs_single ( struct cmd_context * cmd __attribute__ ( ( unused ) ) ,
2006-05-10 01:23:51 +04:00
const char * vg_name , struct volume_group * vg ,
2009-07-01 21:00:50 +04:00
void * handle )
2002-12-12 23:55:49 +03:00
{
2009-09-15 02:47:49 +04:00
if ( ! report_object ( handle , vg , NULL , NULL , NULL , NULL ) ) {
stack ;
2002-12-12 23:55:49 +03:00
return ECMD_FAILED ;
2009-09-15 02:47:49 +04:00
}
2002-12-12 23:55:49 +03:00
2005-05-17 17:44:02 +04:00
check_current_backup ( vg ) ;
2003-10-22 02:06:07 +04:00
return ECMD_PROCESSED ;
2002-12-12 23:55:49 +03:00
}
static int _lvs_single ( struct cmd_context * cmd , struct logical_volume * lv ,
void * handle )
{
2009-09-15 02:47:49 +04:00
if ( ! report_object ( handle , lv - > vg , lv , NULL , NULL , NULL ) ) {
stack ;
2002-12-12 23:55:49 +03:00
return ECMD_FAILED ;
2009-09-15 02:47:49 +04:00
}
2002-12-12 23:55:49 +03:00
2003-10-22 02:06:07 +04:00
return ECMD_PROCESSED ;
2002-12-12 23:55:49 +03:00
}
2010-07-09 19:34:40 +04:00
static int _segs_single ( struct cmd_context * cmd __attribute__ ( ( unused ) ) ,
2006-05-10 01:23:51 +04:00
struct lv_segment * seg , void * handle )
2002-12-12 23:55:49 +03:00
{
2009-09-15 02:47:49 +04:00
if ( ! report_object ( handle , seg - > lv - > vg , seg - > lv , NULL , seg , NULL ) ) {
stack ;
2002-12-12 23:55:49 +03:00
return ECMD_FAILED ;
2009-09-15 02:47:49 +04:00
}
2002-12-12 23:55:49 +03:00
2003-10-22 02:06:07 +04:00
return ECMD_PROCESSED ;
2002-12-12 23:55:49 +03:00
}
2009-04-21 16:59:18 +04:00
static int _pvsegs_sub_single ( struct cmd_context * cmd ,
2007-11-14 21:41:05 +03:00
struct volume_group * vg ,
2005-04-20 00:58:25 +04:00
struct pv_segment * pvseg , void * handle )
{
int ret = ECMD_PROCESSED ;
2007-12-15 00:53:02 +03:00
struct lv_segment * seg = pvseg - > lvseg ;
2005-04-20 00:58:25 +04:00
2009-04-21 16:59:18 +04:00
struct volume_group _free_vg = {
. cmd = cmd ,
2011-02-18 17:47:28 +03:00
. name = " " ,
2011-03-09 15:44:42 +03:00
. vgmem = NULL ,
2009-04-21 16:59:18 +04:00
} ;
2008-06-25 20:52:27 +04:00
struct logical_volume _free_logical_volume = {
2009-04-21 16:59:18 +04:00
. vg = vg ? : & _free_vg ,
2011-02-18 17:47:28 +03:00
. name = " " ,
2010-03-16 18:30:48 +03:00
. snapshot = NULL ,
2008-06-25 20:52:27 +04:00
. status = VISIBLE_LV ,
. major = - 1 ,
. minor = - 1 ,
} ;
struct lv_segment _free_lv_segment = {
2010-03-16 18:30:48 +03:00
. lv = & _free_logical_volume ,
. le = 0 ,
. status = 0 ,
. stripe_size = 0 ,
. area_count = 0 ,
. area_len = 0 ,
. origin = NULL ,
. cow = NULL ,
. chunk_size = 0 ,
. region_size = 0 ,
. extents_copied = 0 ,
. log_lv = NULL ,
. areas = NULL ,
2008-06-25 20:52:27 +04:00
} ;
2010-03-16 18:30:48 +03:00
_free_lv_segment . segtype = get_segtype_from_string ( cmd , " free " ) ;
2008-06-25 20:52:27 +04:00
_free_lv_segment . len = pvseg - > len ;
2009-04-21 16:59:18 +04:00
dm_list_init ( & _free_vg . pvs ) ;
dm_list_init ( & _free_vg . lvs ) ;
dm_list_init ( & _free_vg . tags ) ;
2009-01-10 20:21:17 +03:00
dm_list_init ( & _free_lv_segment . tags ) ;
dm_list_init ( & _free_lv_segment . origin_list ) ;
2008-11-04 01:14:30 +03:00
dm_list_init ( & _free_logical_volume . tags ) ;
dm_list_init ( & _free_logical_volume . segments ) ;
dm_list_init ( & _free_logical_volume . segs_using_this_lv ) ;
2009-01-10 20:21:17 +03:00
dm_list_init ( & _free_logical_volume . snapshot_segs ) ;
2008-06-25 20:52:27 +04:00
if ( ! report_object ( handle , vg , seg ? seg - > lv : & _free_logical_volume , pvseg - > pv ,
2009-09-15 02:47:49 +04:00
seg ? : & _free_lv_segment , pvseg ) ) {
2006-09-02 05:18:17 +04:00
ret = ECMD_FAILED ;
2010-11-18 01:26:42 +03:00
goto_out ;
2009-09-15 02:47:49 +04:00
}
2011-03-09 15:44:42 +03:00
2010-11-18 01:26:42 +03:00
out :
2005-04-20 00:58:25 +04:00
return ret ;
}
2002-12-12 23:55:49 +03:00
static int _lvsegs_single ( struct cmd_context * cmd , struct logical_volume * lv ,
void * handle )
{
2009-05-14 01:27:43 +04:00
if ( ! arg_count ( cmd , all_ARG ) & & ! lv_is_visible ( lv ) )
2005-06-03 18:49:51 +04:00
return ECMD_PROCESSED ;
2002-12-12 23:55:49 +03:00
return process_each_segment_in_lv ( cmd , lv , handle , _segs_single ) ;
}
2005-04-20 00:58:25 +04:00
static int _pvsegs_single ( struct cmd_context * cmd , struct volume_group * vg ,
struct physical_volume * pv , void * handle )
{
return process_each_segment_in_pv ( cmd , vg , pv , handle ,
_pvsegs_sub_single ) ;
}
2002-12-12 23:55:49 +03:00
static int _pvs_single ( struct cmd_context * cmd , struct volume_group * vg ,
struct physical_volume * pv , void * handle )
{
2007-11-02 23:40:05 +03:00
struct pv_list * pvl ;
2004-05-24 18:14:10 +04:00
int ret = ECMD_PROCESSED ;
2007-11-02 23:40:05 +03:00
const char * vg_name = NULL ;
2009-04-10 14:01:38 +04:00
struct volume_group * old_vg = vg ;
2010-07-09 19:34:40 +04:00
char uuid [ 64 ] __attribute__ ( ( aligned ( 8 ) ) ) ;
2002-12-12 23:55:49 +03:00
2008-01-07 23:42:57 +03:00
if ( is_pv ( pv ) & & ! is_orphan ( pv ) & & ! vg ) {
2007-11-02 23:40:05 +03:00
vg_name = pv_vg_name ( pv ) ;
2009-07-01 20:59:37 +04:00
vg = vg_read ( cmd , vg_name , ( char * ) & pv - > vgid , 0 ) ;
if ( vg_read_error ( vg ) ) {
2007-11-15 05:20:03 +03:00
log_error ( " Skipping volume group %s " , vg_name ) ;
2011-08-11 00:25:29 +04:00
release_vg ( vg ) ;
2004-06-19 23:27:00 +04:00
return ECMD_FAILED ;
}
2004-05-24 18:14:10 +04:00
2007-11-02 23:40:05 +03:00
/*
* Replace possibly incomplete PV structure with new one
2010-03-16 18:30:48 +03:00
* allocated in vg_read .
2007-11-02 23:40:05 +03:00
*/
2010-03-16 18:30:48 +03:00
if ( ! is_missing_pv ( pv ) ) {
if ( ! ( pvl = find_pv_in_vg ( vg , pv_dev_name ( pv ) ) ) ) {
log_error ( " Unable to find \" %s \" in volume group \" %s \" " ,
pv_dev_name ( pv ) , vg - > name ) ;
ret = ECMD_FAILED ;
goto out ;
}
} else if ( ! ( pvl = find_pv_in_vg_by_uuid ( vg , & pv - > id ) ) ) {
if ( ! id_write_format ( & pv - > id , uuid , sizeof ( uuid ) ) ) {
stack ;
uuid [ 0 ] = ' \0 ' ;
}
log_error ( " Unable to find missing PV %s in volume group %s " ,
uuid , vg - > name ) ;
2007-11-02 23:40:05 +03:00
ret = ECMD_FAILED ;
goto out ;
}
2010-03-16 18:30:48 +03:00
pv = pvl - > pv ;
2003-03-24 21:22:48 +03:00
}
2002-12-12 23:55:49 +03:00
2009-09-15 02:47:49 +04:00
if ( ! report_object ( handle , vg , NULL , pv , NULL , NULL ) ) {
stack ;
2004-05-24 18:14:10 +04:00
ret = ECMD_FAILED ;
2009-09-15 02:47:49 +04:00
}
2002-12-12 23:55:49 +03:00
2006-09-02 05:18:17 +04:00
out :
2007-11-02 23:40:05 +03:00
if ( vg_name )
unlock_vg ( cmd , vg_name ) ;
2004-06-19 23:27:00 +04:00
2009-04-10 14:01:38 +04:00
if ( ! old_vg )
2011-08-11 00:25:29 +04:00
release_vg ( vg ) ;
2009-04-10 14:01:38 +04:00
2004-05-24 18:14:10 +04:00
return ret ;
2002-12-12 23:55:49 +03:00
}
2009-02-09 12:45:49 +03:00
static int _label_single ( struct cmd_context * cmd , struct volume_group * vg ,
struct physical_volume * pv , void * handle )
{
2009-09-15 02:47:49 +04:00
if ( ! report_object ( handle , vg , NULL , pv , NULL , NULL ) ) {
stack ;
2009-02-09 12:45:49 +03:00
return ECMD_FAILED ;
2009-09-15 02:47:49 +04:00
}
2009-02-09 12:45:49 +03:00
return ECMD_PROCESSED ;
}
2007-01-27 05:09:06 +03:00
static int _pvs_in_vg ( struct cmd_context * cmd , const char * vg_name ,
2007-08-22 18:38:18 +04:00
struct volume_group * vg ,
2007-01-27 05:09:06 +03:00
void * handle )
{
2009-09-15 02:47:49 +04:00
if ( vg_read_error ( vg ) ) {
stack ;
2009-07-01 21:00:50 +04:00
return ECMD_FAILED ;
2009-09-15 02:47:49 +04:00
}
2009-07-01 21:00:50 +04:00
2007-01-27 05:09:06 +03:00
return process_each_pv_in_vg ( cmd , vg , NULL , handle , & _pvs_single ) ;
}
2007-01-27 05:32:31 +03:00
static int _pvsegs_in_vg ( struct cmd_context * cmd , const char * vg_name ,
2007-08-22 18:38:18 +04:00
struct volume_group * vg ,
2007-01-27 05:32:31 +03:00
void * handle )
{
2009-09-15 02:47:49 +04:00
if ( vg_read_error ( vg ) ) {
stack ;
2009-07-01 21:00:50 +04:00
return ECMD_FAILED ;
2009-09-15 02:47:49 +04:00
}
2009-07-01 21:00:50 +04:00
2007-01-27 05:32:31 +03:00
return process_each_pv_in_vg ( cmd , vg , NULL , handle , & _pvsegs_single ) ;
}
2002-12-12 23:55:49 +03:00
static int _report ( struct cmd_context * cmd , int argc , char * * argv ,
report_type_t report_type )
{
void * report_handle ;
2002-12-20 02:25:55 +03:00
const char * opts ;
char * str ;
const char * keys = NULL , * options = NULL , * separator ;
2003-10-22 02:06:07 +04:00
int r = ECMD_PROCESSED ;
2008-06-25 01:21:04 +04:00
int aligned , buffered , headings , field_prefixes , quoted ;
2008-06-25 02:48:53 +04:00
int columns_as_rows ;
2007-01-27 05:09:06 +03:00
unsigned args_are_pvs ;
2002-12-12 23:55:49 +03:00
2006-05-16 20:48:31 +04:00
aligned = find_config_tree_int ( cmd , " report/aligned " ,
2002-12-12 23:55:49 +03:00
DEFAULT_REP_ALIGNED ) ;
2006-05-16 20:48:31 +04:00
buffered = find_config_tree_int ( cmd , " report/buffered " ,
2002-12-12 23:55:49 +03:00
DEFAULT_REP_BUFFERED ) ;
2006-05-16 20:48:31 +04:00
headings = find_config_tree_int ( cmd , " report/headings " ,
2002-12-12 23:55:49 +03:00
DEFAULT_REP_HEADINGS ) ;
2006-05-16 20:48:31 +04:00
separator = find_config_tree_str ( cmd , " report/separator " ,
2002-12-12 23:55:49 +03:00
DEFAULT_REP_SEPARATOR ) ;
2008-04-20 04:15:08 +04:00
field_prefixes = find_config_tree_int ( cmd , " report/prefixes " ,
DEFAULT_REP_PREFIXES ) ;
2008-06-25 01:21:04 +04:00
quoted = find_config_tree_int ( cmd , " report/quoted " ,
DEFAULT_REP_QUOTED ) ;
2008-06-25 02:48:53 +04:00
columns_as_rows = find_config_tree_int ( cmd , " report/columns_as_rows " ,
DEFAULT_REP_COLUMNS_AS_ROWS ) ;
2002-12-12 23:55:49 +03:00
2009-02-09 12:45:49 +03:00
args_are_pvs = ( report_type = = PVS | |
report_type = = LABEL | |
report_type = = PVSEGS ) ? 1 : 0 ;
2007-01-27 05:09:06 +03:00
2002-12-12 23:55:49 +03:00
switch ( report_type ) {
case LVS :
2006-05-16 20:48:31 +04:00
keys = find_config_tree_str ( cmd , " report/lvs_sort " ,
2002-12-12 23:55:49 +03:00
DEFAULT_LVS_SORT ) ;
if ( ! arg_count ( cmd , verbose_ARG ) )
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2004-03-08 21:28:45 +03:00
" report/lvs_cols " ,
2002-12-12 23:55:49 +03:00
DEFAULT_LVS_COLS ) ;
else
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2002-12-12 23:55:49 +03:00
" report/lvs_cols_verbose " ,
2004-03-08 21:28:45 +03:00
DEFAULT_LVS_COLS_VERB ) ;
2002-12-12 23:55:49 +03:00
break ;
case VGS :
2006-05-16 20:48:31 +04:00
keys = find_config_tree_str ( cmd , " report/vgs_sort " ,
2002-12-12 23:55:49 +03:00
DEFAULT_VGS_SORT ) ;
if ( ! arg_count ( cmd , verbose_ARG ) )
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2004-03-08 21:28:45 +03:00
" report/vgs_cols " ,
2002-12-12 23:55:49 +03:00
DEFAULT_VGS_COLS ) ;
else
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2002-12-12 23:55:49 +03:00
" report/vgs_cols_verbose " ,
2004-03-08 21:28:45 +03:00
DEFAULT_VGS_COLS_VERB ) ;
2002-12-12 23:55:49 +03:00
break ;
2009-02-09 12:45:49 +03:00
case LABEL :
2002-12-12 23:55:49 +03:00
case PVS :
2006-05-16 20:48:31 +04:00
keys = find_config_tree_str ( cmd , " report/pvs_sort " ,
2002-12-12 23:55:49 +03:00
DEFAULT_PVS_SORT ) ;
if ( ! arg_count ( cmd , verbose_ARG ) )
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2004-03-08 21:28:45 +03:00
" report/pvs_cols " ,
2002-12-12 23:55:49 +03:00
DEFAULT_PVS_COLS ) ;
else
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2002-12-12 23:55:49 +03:00
" report/pvs_cols_verbose " ,
2004-03-08 21:28:45 +03:00
DEFAULT_PVS_COLS_VERB ) ;
2002-12-12 23:55:49 +03:00
break ;
case SEGS :
2006-05-16 20:48:31 +04:00
keys = find_config_tree_str ( cmd , " report/segs_sort " ,
2002-12-12 23:55:49 +03:00
DEFAULT_SEGS_SORT ) ;
if ( ! arg_count ( cmd , verbose_ARG ) )
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2004-03-08 21:28:45 +03:00
" report/segs_cols " ,
2002-12-12 23:55:49 +03:00
DEFAULT_SEGS_COLS ) ;
else
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2002-12-12 23:55:49 +03:00
" report/segs_cols_verbose " ,
2004-03-08 21:28:45 +03:00
DEFAULT_SEGS_COLS_VERB ) ;
2002-12-12 23:55:49 +03:00
break ;
2005-04-20 00:58:25 +04:00
case PVSEGS :
2006-05-16 20:48:31 +04:00
keys = find_config_tree_str ( cmd , " report/pvsegs_sort " ,
2005-04-20 00:58:25 +04:00
DEFAULT_PVSEGS_SORT ) ;
if ( ! arg_count ( cmd , verbose_ARG ) )
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2005-04-20 00:58:25 +04:00
" report/pvsegs_cols " ,
DEFAULT_PVSEGS_COLS ) ;
else
2006-05-16 20:48:31 +04:00
options = find_config_tree_str ( cmd ,
2005-04-20 00:58:25 +04:00
" report/pvsegs_cols_verbose " ,
DEFAULT_PVSEGS_COLS_VERB ) ;
break ;
2002-12-12 23:55:49 +03:00
}
/* If -o supplied use it, else use default for report_type */
if ( arg_count ( cmd , options_ARG ) ) {
opts = arg_str_value ( cmd , options_ARG , " " ) ;
if ( ! opts | | ! * opts ) {
log_error ( " Invalid options string: %s " , opts ) ;
2008-01-20 04:23:46 +03:00
return EINVALID_CMD_LINE ;
2002-12-12 23:55:49 +03:00
}
if ( * opts = = ' + ' ) {
2006-05-10 21:49:25 +04:00
if ( ! ( str = dm_pool_alloc ( cmd - > mem ,
strlen ( options ) + strlen ( opts ) + 1 ) ) ) {
log_error ( " options string allocation failed " ) ;
2008-01-20 04:23:46 +03:00
return ECMD_FAILED ;
2006-05-10 21:49:25 +04:00
}
2002-12-12 23:55:49 +03:00
strcpy ( str , options ) ;
2002-12-20 02:25:55 +03:00
strcat ( str , " , " ) ;
strcat ( str , opts + 1 ) ;
2002-12-12 23:55:49 +03:00
options = str ;
} else
options = opts ;
}
/* -O overrides default sort settings */
2009-11-03 18:50:42 +03:00
keys = arg_str_value ( cmd , sort_ARG , keys ) ;
2002-12-12 23:55:49 +03:00
2009-11-03 18:50:42 +03:00
separator = arg_str_value ( cmd , separator_ARG , separator ) ;
2002-12-12 23:55:49 +03:00
if ( arg_count ( cmd , separator_ARG ) )
aligned = 0 ;
if ( arg_count ( cmd , aligned_ARG ) )
aligned = 1 ;
if ( arg_count ( cmd , unbuffered_ARG ) & & ! arg_count ( cmd , sort_ARG ) )
buffered = 0 ;
if ( arg_count ( cmd , noheadings_ARG ) )
headings = 0 ;
2008-06-06 23:28:35 +04:00
if ( arg_count ( cmd , nameprefixes_ARG ) ) {
2008-04-20 04:15:08 +04:00
aligned = 0 ;
field_prefixes = 1 ;
}
2008-06-25 01:21:04 +04:00
if ( arg_count ( cmd , unquoted_ARG ) )
quoted = 0 ;
2008-06-25 02:48:53 +04:00
if ( arg_count ( cmd , rows_ARG ) )
columns_as_rows = 1 ;
2002-12-12 23:55:49 +03:00
if ( ! ( report_handle = report_init ( cmd , options , keys , & report_type ,
separator , aligned , buffered ,
2008-06-25 02:48:53 +04:00
headings , field_prefixes , quoted ,
columns_as_rows ) ) ) {
2010-06-17 17:15:51 +04:00
if ( ! strcasecmp ( options , " help " ) | | ! strcmp ( options , " ? " ) )
return r ;
2008-01-20 04:23:46 +03:00
stack ;
return ECMD_FAILED ;
}
2002-12-12 23:55:49 +03:00
2007-01-16 21:06:12 +03:00
/* Ensure options selected are compatible */
if ( report_type & SEGS )
report_type | = LVS ;
if ( report_type & PVSEGS )
report_type | = PVS ;
2009-02-09 12:45:49 +03:00
if ( ( report_type & LVS ) & & ( report_type & ( PVS | LABEL ) ) & & ! args_are_pvs ) {
2007-01-16 21:06:12 +03:00
log_error ( " Can't report LV and PV fields at the same time " ) ;
2007-02-14 18:18:31 +03:00
dm_report_free ( report_handle ) ;
2008-01-20 04:23:46 +03:00
return ECMD_FAILED ;
2007-01-16 21:06:12 +03:00
}
/* Change report type if fields specified makes this necessary */
2007-12-15 00:53:02 +03:00
if ( ( report_type & PVSEGS ) | |
2009-02-09 12:45:49 +03:00
( ( report_type & ( PVS | LABEL ) ) & & ( report_type & LVS ) ) )
2007-01-16 21:06:12 +03:00
report_type = PVSEGS ;
2009-02-09 12:45:49 +03:00
else if ( ( report_type & LABEL ) & & ( report_type & VGS ) )
report_type = PVS ;
2007-01-16 21:06:12 +03:00
else if ( report_type & PVS )
report_type = PVS ;
2007-12-15 00:53:02 +03:00
else if ( report_type & SEGS )
report_type = SEGS ;
else if ( report_type & LVS )
report_type = LVS ;
2007-01-16 21:06:12 +03:00
2002-12-12 23:55:49 +03:00
switch ( report_type ) {
case LVS :
2009-07-01 21:00:50 +04:00
r = process_each_lv ( cmd , argc , argv , 0 , report_handle ,
2003-10-22 02:06:07 +04:00
& _lvs_single ) ;
2002-12-12 23:55:49 +03:00
break ;
case VGS :
2009-07-01 21:00:50 +04:00
r = process_each_vg ( cmd , argc , argv , 0 ,
2003-10-22 02:06:07 +04:00
report_handle , & _vgs_single ) ;
2002-12-12 23:55:49 +03:00
break ;
2009-02-09 12:45:49 +03:00
case LABEL :
2009-07-15 09:50:22 +04:00
r = process_each_pv ( cmd , argc , argv , NULL , READ_WITHOUT_LOCK ,
2009-02-09 12:45:49 +03:00
1 , report_handle , & _label_single ) ;
break ;
2002-12-12 23:55:49 +03:00
case PVS :
2007-01-27 05:09:06 +03:00
if ( args_are_pvs )
2009-07-15 09:50:22 +04:00
r = process_each_pv ( cmd , argc , argv , NULL , 0 ,
2009-02-09 12:45:49 +03:00
0 , report_handle , & _pvs_single ) ;
2007-01-27 05:09:06 +03:00
else
2009-07-01 21:00:50 +04:00
r = process_each_vg ( cmd , argc , argv , 0 ,
2007-01-27 05:09:06 +03:00
report_handle , & _pvs_in_vg ) ;
2002-12-12 23:55:49 +03:00
break ;
case SEGS :
2009-07-01 21:00:50 +04:00
r = process_each_lv ( cmd , argc , argv , 0 , report_handle ,
2003-10-22 02:06:07 +04:00
& _lvsegs_single ) ;
2002-12-12 23:55:49 +03:00
break ;
2005-04-20 00:58:25 +04:00
case PVSEGS :
2007-01-27 05:09:06 +03:00
if ( args_are_pvs )
2009-07-15 09:50:22 +04:00
r = process_each_pv ( cmd , argc , argv , NULL , 0 ,
2009-02-09 12:45:49 +03:00
0 , report_handle , & _pvsegs_single ) ;
2007-01-27 05:09:06 +03:00
else
2009-07-01 21:00:50 +04:00
r = process_each_vg ( cmd , argc , argv , 0 ,
2007-01-27 05:32:31 +03:00
report_handle , & _pvsegs_in_vg ) ;
2005-04-20 00:58:25 +04:00
break ;
2002-12-12 23:55:49 +03:00
}
2007-01-16 21:06:12 +03:00
dm_report_output ( report_handle ) ;
2002-12-12 23:55:49 +03:00
2007-01-16 21:06:12 +03:00
dm_report_free ( report_handle ) ;
2003-10-22 02:06:07 +04:00
return r ;
2002-12-12 23:55:49 +03:00
}
int lvs ( struct cmd_context * cmd , int argc , char * * argv )
{
report_type_t type ;
if ( arg_count ( cmd , segments_ARG ) )
type = SEGS ;
else
type = LVS ;
return _report ( cmd , argc , argv , type ) ;
}
int vgs ( struct cmd_context * cmd , int argc , char * * argv )
{
return _report ( cmd , argc , argv , VGS ) ;
}
int pvs ( struct cmd_context * cmd , int argc , char * * argv )
{
2005-04-20 00:58:25 +04:00
report_type_t type ;
if ( arg_count ( cmd , segments_ARG ) )
type = PVSEGS ;
else
2009-02-09 12:45:49 +03:00
type = LABEL ;
2005-04-20 00:58:25 +04:00
return _report ( cmd , argc , argv , type ) ;
2002-12-12 23:55:49 +03:00
}