LVM additional size suffixes support
PATCH 1/1 LVM additional size suffixes support
...because only wimps use less than a Petabyte of storage. :)
Add support for (P)etabyte and (E)xabyte endings.
Example:
[root@neo-04 ~]# lvcreate -L 3E -n lv vg
Logical volume "lv" created
[root@neo-04 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Devices lv vg -wi-a- 3.00E /dev/dm-2(0) lv vg -wi-a- 3.00E /dev/dm-3(0)
[root@neo-04 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg 3 1 0 wz--n- 6.00E 3.00E
[root@neo-04 ~]# pvs
PV VG Fmt Attr PSize PFree /dev/dm-2 vg lvm2 a- 2.00E 0 /dev/dm-3 vg lvm2 a- 2.00E 1024.00P /dev/dm-4 vg lvm2 a- 2.00E 2.00E /dev/hda2 VolGroupKS00 lvm2 a- 37.16G 32.00M /dev/sdd1 lvm2 -- 17.15G 17.15G /dev/sde1 lvm2 -- 17.15G 17.15G /dev/sdf1 lvm2 -- 17.15G 17.15G /dev/sdg1 lvm2 -- 17.15G 17.15G [root@neo-04 ~]# cat /proc/partitions major minor #blocks name <snip> 253 2 2251799813685248 dm-2 253 3 2251799813685248 dm-3 253 4 2251799813685248 dm-4 253 5 3377699720527872 dm-5
brassow
lib/display/display.c +17 -3
@@ -82,6 +82,12 @@ uint64_t units_to_bytes(const char *unitcase 't' : v *=KILO *KILO *KILO *KILO ;break ; +case 'p' : + v *=KILO *KILO *KILO *KILO *KILO ; +break ; +case 'e' : + v *=KILO *KILO *KILO *KILO *KILO *KILO ; +break ;#undef KILO#define KILO UINT64_C(1000)case 'K' :
@@ -96,6 +102,12 @@ uint64_t units_to_bytes(const char *unitcase 'T' : v *=KILO *KILO *KILO *KILO ;break ; +case 'P' : + v *=KILO *KILO *KILO *KILO *KILO ; +break ; +case 'E' : + v *=KILO *KILO *KILO *KILO *KILO *KILO ; +break ;#undef KILOdefault :return 0 ;
@@ -143,6 +155,8 @@ static const char *_display_size(structuint64_t units =UINT64_C (1024 );char *size_buf =NULL ;const char *size_str[][3 ] = { + {" Exabyte" ," EB" ,"E" }, + {" Petabyte" ," PB" ,"P" }, {" Terabyte" ," TB" ,"T" }, {" Gigabyte" ," GB" ,"G" }, {" Megabyte" ," MB" ,"M" },
@@ -161,7 +175,7 @@ static const char *_display_size(struct suffix = cmd->current_settings.suffix; -for (s =0 ; s <8 ; s++) +for (s =0 ; s <10 ; s++)if (toupper ((int ) cmd->current_settings.unit_type) == *size_str[s][2 ])break ;
@@ -171,7 +185,7 @@ static const char *_display_size(structreturn size_buf; } -if (s <8 ) { +if (s <10 ) { byte = cmd->current_settings.unit_factor; size *=UINT64_C (512 ); }else {
@@ -181,7 +195,7 @@ static const char *_display_size(struct units =UINT64_C (1000 ); else units =UINT64_C (1024 ); - byte = units * units * units; + byte = units * units * units * units * units; s =0 ;while (size_str[s] && size < byte) s++, byte /= units;
lib/format_text/export.c +2 -0
@@ -221,6 +221,8 @@ static int _sectors_to_units(uint64_t se"Megabytes" ,"Gigabytes" ,"Terabytes" , +"Petabytes" , +"Exabytes" , NULL };
tools/lvmcmdline.c +1 -1
@@ -186,7 +186,7 @@ static int _size_arg(struct cmd_context {char *ptr;int i; -static const char *suffixes ="kmgt" ; +static const char *suffixes ="kmgtpe" ;char *val;double v;