2001-09-25 12:49:28 +00:00
/*
2004-03-30 19:35:44 +00:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2007-08-20 20:55:30 +00:00
* Copyright ( C ) 2004 - 2007 Red Hat , Inc . All rights reserved .
2001-09-25 12:49:28 +00:00
*
2004-03-30 19:35:44 +00:00
* This file is part of LVM2 .
2001-09-25 12:49:28 +00:00
*
2004-03-30 19:35:44 +00: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-20 20:55:30 +00:00
* of the GNU Lesser General Public License v .2 .1 .
2001-09-25 12:49:28 +00:00
*
2007-08-20 20:55:30 +00:00
* You should have received a copy of the GNU Lesser General Public License
2004-03-30 19:35:44 +00:00
* along with this program ; if not , write to the Free Software Foundation ,
2016-01-21 11:49:46 +01:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
2001-09-25 12:49:28 +00:00
*/
# include "tools.h"
2006-05-09 21:23:51 +00:00
static int _pvdisplay_single ( struct cmd_context * cmd ,
2007-11-14 18:41:05 +00:00
struct volume_group * vg ,
2014-11-27 15:02:13 +01:00
struct physical_volume * pv ,
struct processing_handle * handle __attribute__ ( ( unused ) ) )
2001-09-25 12:49:28 +00:00
{
2014-10-07 00:34:04 +01:00
const char * pv_name = pv_dev_name ( pv ) ;
2006-10-16 16:29:40 +00:00
int ret = ECMD_PROCESSED ;
2002-02-11 21:00:35 +00:00
uint64_t size ;
2006-10-16 16:29:40 +00:00
2007-11-02 14:54:40 +00:00
if ( is_orphan ( pv ) )
2007-06-15 22:16:55 +00:00
size = pv_size ( pv ) ;
2001-10-25 14:04:18 +00:00
else
2012-08-16 20:07:30 +02:00
size = ( uint64_t ) ( pv_pe_count ( pv ) - pv_pe_alloc_count ( pv ) ) *
2007-06-15 22:16:55 +00:00
pv_pe_size ( pv ) ;
2001-09-25 12:49:28 +00:00
2016-06-21 22:24:52 +01:00
if ( arg_is_set ( cmd , short_ARG ) ) {
2002-12-12 20:55:49 +00:00
log_print ( " Device \" %s \" has a capacity of %s " , pv_name ,
2006-05-09 21:23:51 +00:00
display_size ( cmd , size ) ) ;
2006-10-16 16:29:40 +00:00
goto out ;
2001-09-25 12:49:28 +00:00
}
2007-06-15 22:16:55 +00:00
if ( pv_status ( pv ) & EXPORTED_VG )
2014-03-19 00:35:27 +01:00
log_print_unless_silent ( " Physical volume \" %s \" of volume group \" %s \" "
" is exported " , pv_name , pv_vg_name ( pv ) ) ;
2001-09-25 12:49:28 +00:00
2007-11-02 14:54:40 +00:00
if ( is_orphan ( pv ) )
2014-03-19 00:35:27 +01:00
log_print_unless_silent ( " \" %s \" is a new physical volume of \" %s \" " ,
pv_name , display_size ( cmd , size ) ) ;
2001-09-25 12:49:28 +00:00
2024-12-05 14:50:06 -06:00
if ( arg_is_set ( cmd , colon_ARG ) )
2001-10-18 16:55:19 +00:00
pvdisplay_colons ( pv ) ;
2024-12-05 14:50:06 -06:00
else
pvdisplay_full ( cmd , pv , NULL ) ;
2001-09-25 12:49:28 +00:00
2016-06-21 22:24:52 +01:00
if ( arg_is_set ( cmd , maps_ARG ) )
2007-05-30 20:43:09 +00:00
pvdisplay_segments ( pv ) ;
2006-10-16 16:29:40 +00:00
out :
return ret ;
2002-11-18 14:04:08 +00:00
}
2024-12-05 14:50:06 -06:00
int pvdisplay_cmd ( struct cmd_context * cmd , int argc , char * * argv )
2002-11-18 14:04:08 +00:00
{
2024-12-05 14:50:06 -06:00
return process_each_pv ( cmd , argc , argv , NULL , 0 , 0 , NULL , _pvdisplay_single ) ;
}
2002-11-18 14:04:08 +00:00
2024-12-05 14:50:06 -06:00
int pvdisplay_columns_cmd ( struct cmd_context * cmd , int argc , char * * argv )
{
2018-12-07 14:35:22 -06:00
/*
* Without - a , command only looks at PVs and can use hints ,
* with - a , the command looks at all ( non - hinted ) devices .
*/
if ( arg_is_set ( cmd , all_ARG ) )
cmd - > use_hints = 0 ;
2024-12-05 14:50:06 -06:00
return pvs ( cmd , argc , argv ) ;
2001-09-25 12:49:28 +00:00
}
2024-11-22 13:25:29 +01:00
2024-12-05 14:50:06 -06:00
int pvdisplay ( struct cmd_context * cmd , int argc , char * * argv )
2024-11-22 13:25:29 +01:00
{
2024-12-05 14:50:06 -06:00
log_error ( INTERNAL_ERROR " Missing function for command definition %d:%s. " ,
cmd - > command - > command_index , command_enum ( cmd - > command - > command_enum ) ) ;
return ECMD_FAILED ;
2024-11-22 13:25:29 +01:00
}