[gparted] Also accept btrfs tools using IEC prefix multipliers (#706914)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Also accept btrfs tools using IEC prefix multipliers (#706914)
- Date: Thu, 29 Aug 2013 16:26:53 +0000 (UTC)
commit 78c558c350a22c72fa1c9a5b7224e66a0af225d9
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Tue Aug 27 15:29:26 2013 +0100
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
include/Utils.h | 1 +
src/btrfs.cc | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/include/Utils.h b/include/Utils.h
index c1e98d9..4b6c96c 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -51,6 +51,7 @@ const Byte_Value MEBIBYTE=(KIBIBYTE * KIBIBYTE);
const Byte_Value GIBIBYTE=(MEBIBYTE * KIBIBYTE);
const Byte_Value TEBIBYTE=(GIBIBYTE * 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_NTFS_HALF = _("(Half new UUID - will be randomly generated)") ;
diff --git a/src/btrfs.cc b/src/btrfs.cc
index d3f3575..e5ac32f 100644
--- a/src/btrfs.cc
+++ b/src/btrfs.cc
@@ -139,12 +139,12 @@ void btrfs::set_used_sectors( Partition & partition )
Byte_Value ptn_bytes = partition .get_byte_length() ;
Glib::ustring str ;
//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() )
T = btrfs_size_to_num( str, ptn_bytes, true ) ;
//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 ) ;
if ( T > -1 && N > -1 )
@@ -371,6 +371,8 @@ gdouble btrfs::btrfs_size_to_gdouble( Glib::ustring str )
{
gchar * suffix ;
gdouble rawN = g_ascii_strtod( str .c_str(), & suffix ) ;
+ while ( isspace( suffix[0] ) ) //Skip white space before suffix
+ suffix ++ ;
unsigned long long mult ;
switch ( suffix[0] )
{
@@ -378,6 +380,8 @@ gdouble btrfs::btrfs_size_to_gdouble( Glib::ustring str )
case 'M': mult = MEBIBYTE ; break ;
case 'G': mult = GIBIBYTE ; break ;
case 'T': mult = TEBIBYTE ; break ;
+ case 'P': mult = PEBIBYTE ; break ;
+ case 'E': mult = EXBIBYTE ; break ;
default: mult = 1 ; break ;
}
return rawN * mult ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]