Fix sscanf modifier for long long (#768239)
POSIX says that %lld is the modifier for long long. http://pubs.opengroup.org/onlinepubs/9699919799/functions/fscanf.html This fixes wrong sizes with musl libc. Bug 768239 - sizes are wrong with musl libc due to use of non-standard sscanf "%Ld" modifier
This commit is contained in:
parent
8ac3a0e4ad
commit
25209904a9
10
src/ext2.cc
10
src/ext2.cc
|
@ -179,12 +179,12 @@ void ext2::set_used_sectors( Partition & partition )
|
|||
{
|
||||
Glib::ustring::size_type index = output.find( "Block count:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output.substr( index ) .c_str(), "Block count: %Ld", &T ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "Block count: %lld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
||||
index = output .find( "Block size:" ) ;
|
||||
if ( index >= output.length() ||
|
||||
sscanf( output.substr( index ) .c_str(), "Block size: %Ld", &S ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "Block size: %lld", &S ) != 1 )
|
||||
S = -1 ;
|
||||
|
||||
if ( T > -1 && S > -1 )
|
||||
|
@ -207,7 +207,7 @@ void ext2::set_used_sectors( Partition & partition )
|
|||
{
|
||||
index = output .find( "Free blocks:" ) ;
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output.substr( index ) .c_str(), "Free blocks: %Ld", &N ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "Free blocks: %lld", &N ) != 1 )
|
||||
N = -1 ;
|
||||
|
||||
if ( N > -1 && S > -1 )
|
||||
|
@ -382,7 +382,7 @@ void ext2::create_progress( OperationDetail *operationdetail )
|
|||
Glib::ustring line = Utils::last_line( output );
|
||||
// Text progress on the LAST LINE looks like "Writing inode tables: 105/1600"
|
||||
long long progress, target;
|
||||
if ( sscanf( line.c_str(), "Writing inode tables: %Ld/%Ld", &progress, &target ) == 2 )
|
||||
if ( sscanf( line.c_str(), "Writing inode tables: %lld/%lld", &progress, &target ) == 2 )
|
||||
{
|
||||
operationdetail->run_progressbar( (double)progress, (double)target );
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ void ext2::copy_progress( OperationDetail *operationdetail )
|
|||
Glib::ustring line = Utils::last_line( error );
|
||||
// Text progress on the LAST LINE of STDERR looks like "Copying 146483 / 258033 blocks ..."
|
||||
long long progress, target;
|
||||
if ( sscanf( line.c_str(), "Copying %Ld / %Ld blocks", &progress, &target ) == 2 )
|
||||
if ( sscanf( line.c_str(), "Copying %lld / %lld blocks", &progress, &target ) == 2 )
|
||||
{
|
||||
operationdetail->run_progressbar( (double)(progress * fs_block_size),
|
||||
(double)(target * fs_block_size),
|
||||
|
|
|
@ -137,12 +137,12 @@ void fat16::set_used_sectors( Partition & partition )
|
|||
{
|
||||
//total file system size in logical sectors
|
||||
Glib::ustring::size_type index = output.rfind( "\n", output.find( "sectors total" ) ) + 1;
|
||||
if ( index >= output .length() || sscanf( output .substr( index ) .c_str(), "%Ld", &T ) != 1 )
|
||||
if ( index >= output.length() || sscanf( output.substr( index ).c_str(), "%lld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
||||
//bytes per logical sector
|
||||
index = output .rfind( "\n", output .find( "bytes per logical sector" ) ) +1 ;
|
||||
if ( index >= output .length() || sscanf( output .substr( index ) .c_str(), "%Ld", &S ) != 1 )
|
||||
if ( index >= output.length() || sscanf( output.substr( index ).c_str(), "%lld", &S ) != 1 )
|
||||
S = -1 ;
|
||||
|
||||
if ( T > -1 && S > -1 )
|
||||
|
@ -150,14 +150,14 @@ void fat16::set_used_sectors( Partition & partition )
|
|||
|
||||
//free clusters
|
||||
index = output .find( ",", output .find( partition .get_path() ) + partition .get_path() .length() ) +1 ;
|
||||
if ( index < output .length() && sscanf( output .substr( index ) .c_str(), "%Ld/%Ld", &S, &N ) == 2 )
|
||||
if ( index < output.length() && sscanf( output.substr( index ).c_str(), "%lld/%lld", &S, &N ) == 2 )
|
||||
N -= S ;
|
||||
else
|
||||
N = -1 ;
|
||||
|
||||
//bytes per cluster
|
||||
index = output .rfind( "\n", output .find( "bytes per cluster" ) ) +1 ;
|
||||
if ( index >= output .length() || sscanf( output .substr( index ) .c_str(), "%Ld", &S ) != 1 )
|
||||
if ( index >= output.length() || sscanf( output.substr( index ).c_str(), "%lld", &S ) != 1 )
|
||||
S = -1 ;
|
||||
|
||||
if ( N > -1 && S > -1 )
|
||||
|
|
|
@ -81,19 +81,19 @@ void jfs::set_used_sectors( Partition & partition )
|
|||
//blocksize
|
||||
Glib::ustring::size_type index = output.find( "Block Size:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "Block Size: %Ld", &S ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "Block Size: %lld", &S ) != 1 )
|
||||
S = -1 ;
|
||||
|
||||
//total blocks
|
||||
index = output .find( "dn_mapsize:" ) ;
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "dn_mapsize: %Lx", &T ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "dn_mapsize: %llx", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
||||
//free blocks
|
||||
index = output .find( "dn_nfree:" ) ;
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "dn_nfree: %Lx", &N ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "dn_nfree: %llx", &N ) != 1 )
|
||||
N = -1 ;
|
||||
|
||||
if ( T > -1 && N > -1 && S > -1 )
|
||||
|
|
|
@ -85,7 +85,7 @@ void linux_swap::set_used_sectors( Partition & partition )
|
|||
{
|
||||
if ( line .substr( 0, path_len ) == path )
|
||||
{
|
||||
sscanf( line.substr( path_len ).c_str(), " %*s %*d %Ld", &N );
|
||||
sscanf( line.substr( path_len ).c_str(), " %*s %*d %lld", &N );
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,20 +79,20 @@ void nilfs2::set_used_sectors( Partition & partition )
|
|||
//File system size in bytes
|
||||
Glib::ustring::size_type index = output .find( "Device size:" ) ;
|
||||
if ( index == Glib::ustring::npos
|
||||
|| sscanf( output.substr( index ) .c_str(), "Device size: %Ld", &T ) != 1
|
||||
|| sscanf( output.substr( index ).c_str(), "Device size: %lld", &T ) != 1
|
||||
)
|
||||
T = -1 ;
|
||||
|
||||
//Free space in blocks
|
||||
index = output .find( "Free blocks count:" ) ;
|
||||
if ( index == Glib::ustring::npos
|
||||
|| sscanf( output.substr( index ) .c_str(), "Free blocks count: %Ld", &N ) != 1
|
||||
|| sscanf( output.substr( index ).c_str(), "Free blocks count: %lld", &N ) != 1
|
||||
)
|
||||
N = -1 ;
|
||||
|
||||
index = output .find( "Block size:" ) ;
|
||||
if ( index == Glib::ustring::npos
|
||||
|| sscanf( output.substr( index ) .c_str(), "Block size: %Ld", &S ) != 1
|
||||
|| sscanf( output.substr( index ).c_str(), "Block size: %lld", &S ) != 1
|
||||
)
|
||||
S = -1 ;
|
||||
|
||||
|
|
|
@ -129,12 +129,12 @@ void ntfs::set_used_sectors( Partition & partition )
|
|||
{
|
||||
Glib::ustring::size_type index = output.find( "Current volume size:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "Current volume size: %Ld", &T ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "Current volume size: %lld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
||||
index = output .find( "resize at" ) ;
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "resize at %Ld", &N ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "resize at %lld", &N ) != 1 )
|
||||
N = -1 ;
|
||||
//For an absolutely full NTFS, "ntfsresize --info" exits
|
||||
// with status 1 and reports this message instead
|
||||
|
@ -144,7 +144,7 @@ void ntfs::set_used_sectors( Partition & partition )
|
|||
|
||||
index = output.find( "Cluster size" );
|
||||
if ( index >= output.length() ||
|
||||
sscanf( output.substr( index ).c_str(), "Cluster size : %Ld", &S ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "Cluster size : %lld", &S ) != 1 )
|
||||
S = -1;
|
||||
|
||||
if ( T > -1 && N > -1 )
|
||||
|
|
|
@ -66,17 +66,17 @@ void reiser4::set_used_sectors( Partition & partition )
|
|||
{
|
||||
Glib::ustring::size_type index = output.find( "\nblocks:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output.substr( index ) .c_str(), "\nblocks: %Ld", &T ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "\nblocks: %lld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
||||
index = output .find( "\nfree blocks:" ) ;
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output.substr( index ) .c_str(), "\nfree blocks: %Ld", &N ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "\nfree blocks: %lld", &N ) != 1 )
|
||||
N = -1 ;
|
||||
|
||||
index = output .find( "\nblksize:" ) ;
|
||||
if ( index >= output.length() ||
|
||||
sscanf( output.substr( index ) .c_str(), "\nblksize: %Ld", &S ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "\nblksize: %lld", &S ) != 1 )
|
||||
S = -1 ;
|
||||
|
||||
if ( T > -1 && N > -1 && S > -1 )
|
||||
|
|
|
@ -83,17 +83,17 @@ void reiserfs::set_used_sectors( Partition & partition )
|
|||
{
|
||||
Glib::ustring::size_type index = output.find( "Count of blocks on the device:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "Count of blocks on the device: %Ld", &T ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "Count of blocks on the device: %lld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
||||
index = output .find( "Blocksize:" ) ;
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "Blocksize: %Ld", &S ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "Blocksize: %lld", &S ) != 1 )
|
||||
S = -1 ;
|
||||
|
||||
index = output .find( ":", output .find( "Free blocks" ) ) +1 ;
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "%Ld", &N ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "%lld", &N ) != 1 )
|
||||
N = -1 ;
|
||||
|
||||
if ( T > -1 && N > -1 && S > -1 )
|
||||
|
|
|
@ -95,19 +95,19 @@ void xfs::set_used_sectors( Partition & partition )
|
|||
true ) )
|
||||
{
|
||||
//blocksize
|
||||
if ( sscanf( output .c_str(), "blocksize = %Ld", &S ) != 1 )
|
||||
if ( sscanf( output.c_str(), "blocksize = %lld", &S ) != 1 )
|
||||
S = -1 ;
|
||||
|
||||
//filesystem blocks
|
||||
Glib::ustring::size_type index = output.find( "\ndblocks" );
|
||||
if ( index > output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "\ndblocks = %Ld", &T ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "\ndblocks = %lld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
||||
//free blocks
|
||||
index = output .find( "\nfdblocks" ) ;
|
||||
if ( index > output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "\nfdblocks = %Ld", &N ) != 1 )
|
||||
sscanf( output.substr( index ).c_str(), "\nfdblocks = %lld", &N ) != 1 )
|
||||
N = -1 ;
|
||||
|
||||
if ( T > -1 && N > -1 && S > -1 )
|
||||
|
|
Loading…
Reference in New Issue