[gparted] Record file system block size where known (#760709)



commit 324d99a172848e4ff3fb7eb189f490bb4e6c53e5
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Jan 16 10:40:58 2016 +0000

    Record file system block size where known (#760709)
    
    Record the file system block size in the Partition object.  Only
    implemented for file systems when set_used_sectors() method has already
    parsed the value or can easily parse the value from the existing
    executed command(s).
    
    Needed for ext2/3/4 copies and moves performed using e2image so that
    they can be tracked in bytes by the ProgressBar class as e2image reports
    progress in file system block size units.
    
    Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific
                 copy methods

 include/Partition.h |    3 +++
 src/Partition.cc    |    1 +
 src/ext2.cc         |    5 ++++-
 src/fat16.cc        |    3 +++
 src/jfs.cc          |    1 +
 src/nilfs2.cc       |    1 +
 src/ntfs.cc         |    7 +++++++
 src/reiser4.cc      |    1 +
 src/reiserfs.cc     |    1 +
 src/xfs.cc          |    1 +
 10 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/include/Partition.h b/include/Partition.h
index 25e80b1..cf05b04 100644
--- a/include/Partition.h
+++ b/include/Partition.h
@@ -26,6 +26,8 @@
 #include "../include/Utils.h"
 #include "../include/PartitionVector.h"
 
+#include <glibmm/ustring.h>
+
 namespace GParted
 {
        
@@ -160,6 +162,7 @@ public:
        Sector free_space_before ;  //Free space preceding partition value
 
        Byte_Value sector_size ;  //Sector size of the disk device needed for converting to/from sectors and 
bytes.
+       Byte_Value fs_block_size;  // Block size of of the file system, or -1 when unknown.
 
 private:
        Partition & operator=( Partition & rhs );  // Not implemented copy assignment operator
diff --git a/src/Partition.cc b/src/Partition.cc
index b7ccfb4..7c41e6d 100644
--- a/src/Partition.cc
+++ b/src/Partition.cc
@@ -51,6 +51,7 @@ void Partition::Reset()
        significant_threshold = 1 ;
        free_space_before = -1 ;
        sector_size = 0 ;
+       fs_block_size = -1;
        inside_extended = busy = strict_start = false ;
        logicals .clear() ;
        flags .clear() ;
diff --git a/src/ext2.cc b/src/ext2.cc
index d68d113..4fe5910 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -165,8 +165,11 @@ void ext2::set_used_sectors( Partition & partition )
                                N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
                }
 
-               if ( T > -1 && N > -1 )
+               if ( T > -1 && N > -1 && S > -1 )
+               {
                        partition .set_sector_usage( T, N ) ;
+                       partition.fs_block_size = S;
+               }
        }
        else
        {
diff --git a/src/fat16.cc b/src/fat16.cc
index d02b357..f89f6e1 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -156,7 +156,10 @@ void fat16::set_used_sectors( Partition & partition )
                        S = -1 ;
        
                if ( N > -1 && S > -1 )
+               {
                        N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
+                       partition.fs_block_size = S;
+               }
 
                if ( T > -1 && N > -1 )
                        partition .set_sector_usage( T, N ) ;
diff --git a/src/jfs.cc b/src/jfs.cc
index 673483f..866bce0 100644
--- a/src/jfs.cc
+++ b/src/jfs.cc
@@ -101,6 +101,7 @@ void jfs::set_used_sectors( Partition & partition )
                        T = Utils::round( T * ( S / double(partition .sector_size) ) ) ;
                        N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
                        partition .set_sector_usage( T, N ) ;
+                       partition.fs_block_size = S;
                }
        }
        else
diff --git a/src/nilfs2.cc b/src/nilfs2.cc
index 0baacda..ec84bf9 100644
--- a/src/nilfs2.cc
+++ b/src/nilfs2.cc
@@ -101,6 +101,7 @@ void nilfs2::set_used_sectors( Partition & partition )
                        T = Utils::round( T / double(partition .sector_size) ) ;
                        N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
                        partition .set_sector_usage( T, N ) ;
+                       partition.fs_block_size = S;
                }
        }
        else
diff --git a/src/ntfs.cc b/src/ntfs.cc
index 979f6d9..5d2df89 100644
--- a/src/ntfs.cc
+++ b/src/ntfs.cc
@@ -143,12 +143,19 @@ void ntfs::set_used_sectors( Partition & partition )
                if ( index < output .length() )
                        N = T ;
 
+               index = output.find( "Cluster size" );
+               if ( index == output.npos ||
+                    sscanf( output.substr( index ).c_str(), "Cluster size       : %Ld", &S ) != 1 )
+                       S = -1;
+
                if ( T > -1 && N > -1 )
                {
                        T = Utils::round( T / double(partition .sector_size) ) ;
                        N = Utils::round( N / double(partition .sector_size) ) ;
                        partition .set_sector_usage( T, T - N );
                }
+               if ( S > -1 )
+                       partition.fs_block_size = S;
        }
        else
        {
diff --git a/src/reiser4.cc b/src/reiser4.cc
index 3f4b3e1..92d4911 100644
--- a/src/reiser4.cc
+++ b/src/reiser4.cc
@@ -84,6 +84,7 @@ void reiser4::set_used_sectors( Partition & partition )
                        T = Utils::round( T * ( S / double(partition .sector_size) ) ) ;
                        N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
                        partition .set_sector_usage( T, N ) ;
+                       partition.fs_block_size = S;
                }
        }
        else
diff --git a/src/reiserfs.cc b/src/reiserfs.cc
index 96466fc..710f3f9 100644
--- a/src/reiserfs.cc
+++ b/src/reiserfs.cc
@@ -101,6 +101,7 @@ void reiserfs::set_used_sectors( Partition & partition )
                        T = Utils::round( T * ( S / double(partition .sector_size) ) ) ;
                        N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
                        partition .set_sector_usage( T, N ) ;
+                       partition.fs_block_size = S;
                }
        }
        else
diff --git a/src/xfs.cc b/src/xfs.cc
index 449859f..12021fb 100644
--- a/src/xfs.cc
+++ b/src/xfs.cc
@@ -115,6 +115,7 @@ void xfs::set_used_sectors( Partition & partition )
                        T = Utils::round( T * ( S / double(partition .sector_size) ) ) ;
                        N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
                        partition .set_sector_usage( T, N ) ;
+                       partition.fs_block_size = S;
                }
 
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]