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
This commit is contained in:
parent
809a7e0954
commit
324d99a172
|
@ -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
|
||||
|
|
|
@ -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() ;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 ) ;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue