Also accept btrfs tools using IEC prefix multipliers (#706914)
Currently the btrfs command outputs figures to 2 decimal places followed by an SI multiplier, e.g. 1.00GB. This patch to btrfs-progs has been included in the integration repository and will likely be included in the official btrfs-progs repository at some point. It changes btrfs-progs to use IEC multipliers, e.g. 1.00GiB. In fact multipliers already aren't used for figures less than 1024. [PATCH] btrfs-progs: use IEC units for size http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26888 https://patchwork.kernel.org/patch/2825841/ Make GParted capable of also accepting IEC prefix multipliers, just "B" for bytes and no multiplier, as well as an optional space between the number and multiplier. Therefore accept values like these: 1.00GB 1.00 GB 1.00GiB 1.00 GiB 1073741824B 1073741824 B 1073741824 Closes Bug #706914 - Prepare for btrfs tools using IEC prefix multipliers
This commit is contained in:
parent
510f6697e1
commit
78c558c350
|
@ -51,6 +51,7 @@ const Byte_Value MEBIBYTE=(KIBIBYTE * KIBIBYTE);
|
||||||
const Byte_Value GIBIBYTE=(MEBIBYTE * KIBIBYTE);
|
const Byte_Value GIBIBYTE=(MEBIBYTE * KIBIBYTE);
|
||||||
const Byte_Value TEBIBYTE=(GIBIBYTE * KIBIBYTE);
|
const Byte_Value TEBIBYTE=(GIBIBYTE * KIBIBYTE);
|
||||||
const Byte_Value PEBIBYTE=(TEBIBYTE * KIBIBYTE);
|
const Byte_Value PEBIBYTE=(TEBIBYTE * KIBIBYTE);
|
||||||
|
const Byte_Value EXBIBYTE=(PEBIBYTE * KIBIBYTE);
|
||||||
|
|
||||||
const Glib::ustring UUID_RANDOM = _("(New UUID - will be randomly generated)") ;
|
const Glib::ustring UUID_RANDOM = _("(New UUID - will be randomly generated)") ;
|
||||||
const Glib::ustring UUID_RANDOM_NTFS_HALF = _("(Half new UUID - will be randomly generated)") ;
|
const Glib::ustring UUID_RANDOM_NTFS_HALF = _("(Half new UUID - will be randomly generated)") ;
|
||||||
|
|
|
@ -139,12 +139,12 @@ void btrfs::set_used_sectors( Partition & partition )
|
||||||
Byte_Value ptn_bytes = partition .get_byte_length() ;
|
Byte_Value ptn_bytes = partition .get_byte_length() ;
|
||||||
Glib::ustring str ;
|
Glib::ustring str ;
|
||||||
//Btrfs file system device size
|
//Btrfs file system device size
|
||||||
Glib::ustring regexp = "devid .* size ([0-9\\.]+.?B) .* path " + partition .get_path() ;
|
Glib::ustring regexp = "devid .* size ([0-9\\.]+( ?[KMGTPE]?i?B)?) .* path " + partition .get_path() ;
|
||||||
if ( ! ( str = Utils::regexp_label( output, regexp ) ) .empty() )
|
if ( ! ( str = Utils::regexp_label( output, regexp ) ) .empty() )
|
||||||
T = btrfs_size_to_num( str, ptn_bytes, true ) ;
|
T = btrfs_size_to_num( str, ptn_bytes, true ) ;
|
||||||
|
|
||||||
//Btrfs file system wide used bytes
|
//Btrfs file system wide used bytes
|
||||||
if ( ! ( str = Utils::regexp_label( output, "FS bytes used ([0-9\\.]+.?B)" ) ) .empty() )
|
if ( ! ( str = Utils::regexp_label( output, "FS bytes used ([0-9\\.]+( ?[KMGTPE]?i?B)?)" ) ) .empty() )
|
||||||
N = T - btrfs_size_to_num( str, ptn_bytes, false ) ;
|
N = T - btrfs_size_to_num( str, ptn_bytes, false ) ;
|
||||||
|
|
||||||
if ( T > -1 && N > -1 )
|
if ( T > -1 && N > -1 )
|
||||||
|
@ -371,6 +371,8 @@ gdouble btrfs::btrfs_size_to_gdouble( Glib::ustring str )
|
||||||
{
|
{
|
||||||
gchar * suffix ;
|
gchar * suffix ;
|
||||||
gdouble rawN = g_ascii_strtod( str .c_str(), & suffix ) ;
|
gdouble rawN = g_ascii_strtod( str .c_str(), & suffix ) ;
|
||||||
|
while ( isspace( suffix[0] ) ) //Skip white space before suffix
|
||||||
|
suffix ++ ;
|
||||||
unsigned long long mult ;
|
unsigned long long mult ;
|
||||||
switch ( suffix[0] )
|
switch ( suffix[0] )
|
||||||
{
|
{
|
||||||
|
@ -378,6 +380,8 @@ gdouble btrfs::btrfs_size_to_gdouble( Glib::ustring str )
|
||||||
case 'M': mult = MEBIBYTE ; break ;
|
case 'M': mult = MEBIBYTE ; break ;
|
||||||
case 'G': mult = GIBIBYTE ; break ;
|
case 'G': mult = GIBIBYTE ; break ;
|
||||||
case 'T': mult = TEBIBYTE ; break ;
|
case 'T': mult = TEBIBYTE ; break ;
|
||||||
|
case 'P': mult = PEBIBYTE ; break ;
|
||||||
|
case 'E': mult = EXBIBYTE ; break ;
|
||||||
default: mult = 1 ; break ;
|
default: mult = 1 ; break ;
|
||||||
}
|
}
|
||||||
return rawN * mult ;
|
return rawN * mult ;
|
||||||
|
|
Loading…
Reference in New Issue