diff options
author | Antoine Viallon | 2019-03-18 23:05:28 +0000 |
---|---|---|
committer | Antoine Viallon | 2019-03-18 23:05:28 +0000 |
commit | 637c0a356a3ce22b6b2b78d7de2b11742f84a72f (patch) | |
tree | f81e463be5000e6aac77e62f317e663b78531646 | |
parent | d47a23f16634e6d2246c692333fc7dd95db29f02 (diff) | |
download | aur-gparted-f2fs-patch.tar.gz |
Updated f2fs patch to latest version
-rw-r--r-- | .SRCINFO | 2 | ||||
-rw-r--r-- | PKGBUILD | 2 | ||||
-rw-r--r-- | f2fs-verify-resize.patch | 134 |
3 files changed, 55 insertions, 83 deletions
@@ -1,7 +1,7 @@ pkgbase = gparted-f2fs-patch pkgdesc = A Partition Magic clone, frontend to GNU Parted. Patched with experimental F2FS features. pkgver = 0.33.0 - pkgrel = 1 + pkgrel = 2 url = http://gparted.sourceforge.net arch = x86_64 license = GPL @@ -4,7 +4,7 @@ pkgname=gparted-f2fs-patch _pkgname=gparted pkgver=0.33.0 norigpkgver=0.33.0 -pkgrel=1 +pkgrel=2 pkgdesc="A Partition Magic clone, frontend to GNU Parted. Patched with experimental F2FS features." arch=('x86_64') url="http://gparted.sourceforge.net" diff --git a/f2fs-verify-resize.patch b/f2fs-verify-resize.patch index 674e3345850f..fca05bb595be 100644 --- a/f2fs-verify-resize.patch +++ b/f2fs-verify-resize.patch @@ -1,23 +1,20 @@ -diff --git a/include/f2fs.h b/include/f2fs.h -index a7b6cb0c..e2de221d 100644 ---- a/include/f2fs.h +diff -u b/include/f2fs.h b/include/f2fs.h +--- b/include/f2fs.h +++ b/include/f2fs.h -@@ -29,6 +29,10 @@ class f2fs : public FileSystem +@@ -29,6 +29,9 @@ public: FS get_filesystem_support() ; bool create( const Partition & new_partition, OperationDetail & operationdetail ) ; + bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition ); + bool check_repair( const Partition & partition, OperationDetail & operationdetail ); + void set_used_sectors( Partition & partition ) ; -+ void read_label( Partition & partition ); }; } //GParted -diff --git a/src/f2fs.cc b/src/f2fs.cc -index 9bb945c3..704bb71e 100644 ---- a/src/f2fs.cc +diff -u b/src/f2fs.cc b/src/f2fs.cc +--- b/src/f2fs.cc +++ b/src/f2fs.cc -@@ -37,6 +37,26 @@ FS f2fs::get_filesystem_support() +@@ -37,6 +37,20 @@ fs.create_with_label = FS::EXTERNAL; } @@ -35,78 +32,56 @@ index 9bb945c3..704bb71e 100644 + fs.read = FS::EXTERNAL; + } + -+ if ( ! Glib::find_program_in_path( "blkid" ).empty() ) -+ { -+ fs.read_label = FS::EXTERNAL; -+ //fs.write_label = FS::EXTERNAL; -+ } -+ fs .copy = FS::GPARTED ; fs .move = FS::GPARTED ; fs .online_read = FS::GPARTED ; -@@ -44,6 +64,76 @@ FS f2fs::get_filesystem_support() +@@ -44,6 +58,60 @@ return fs ; } -+void f2fs::read_label( Partition & partition ) -+{ -+ if ( ! Utils::execute_command( "blkid -s LABEL " + Glib::shell_quote( partition.get_path() ), -+ output, error, true ) ) -+ { -+ partition.set_filesystem_label( Utils::regexp_label( output, "LABEL=\"(\\w*)\"" ) ); -+ } -+ else -+ { -+ if ( ! output .empty() ) -+ partition.push_back_message( output ); -+ -+ if ( ! error .empty() ) -+ partition.push_back_message( error ); -+ } -+} -+ +void f2fs::set_used_sectors( Partition & partition ) +{ -+ // Try to get an estimation on how many free "segments" there is. It seems to be proportional. + if ( ! Utils::execute_command( "dump.f2fs -d 1 " + Glib::shell_quote( partition.get_path() ), output, error, true )) + { ++ long long int user_block_count; ++ long long int valid_block_count; ++ long long int log_blocksize; ++ long long int blocksize; ++ long long int total_fs_sectors; ++ ++ Glib::ustring temp; ++ temp = Utils::regexp_label( output, "user_block_count\\s+\\[0x\\s+[0-9a-f]+ : ([0-9]+)\\]" ) ; ++ sscanf( temp.c_str(), "%lld", &user_block_count ); + -+ if ( partition .busy ) -+ { -+ Byte_Value ignored ; -+ Byte_Value fs_free ; -+ if ( Utils::get_mounted_filesystem_usage( partition .get_mountpoint(), -+ ignored, fs_free, error ) == 0 ) -+ { -+ N = fs_free / S; -+ } -+ else -+ { -+ N = -1 ; -+ partition.push_back_message( error ); -+ } -+ } else { -+ Glib::ustring temp; -+ temp = Utils::regexp_label( output, "segment_count\\s+\\[0x\\s+[0-9a-f]+ : ([0-9]+)\\]" ) ; -+ sscanf( temp.c_str(), "%lld", &T ); -+ temp = Utils::regexp_label( output, "free_segment_count\\s+\\[0x\\s+[0-9a-f]+ : ([0-9]+)\\]" ) ; -+ sscanf( temp.c_str(), "%lld", &N ); -+ temp = Utils::regexp_label( output, "sector size = ([0-9]+)" ) ; -+ sscanf( temp.c_str(), "%lld", &S ); -+ -+ T = T * S * 8; -+ N = N * S * 8; -+ partition.sector_size = S; -+ } -+ -+ if ( T > -1 && N > -1 && S > -1 ) -+ { -+ 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; -+ } ++ ++ temp = Utils::regexp_label( output, "valid_block_count\\s+\\[0x\\s+[0-9a-f]+ : ([0-9]+)\\]" ) ; ++ sscanf( temp.c_str(), "%lld", &valid_block_count ); ++ ++ ++ temp = Utils::regexp_label( output, "log_blocksize\\s+\\[0x\\s+[0-9a-f]+ : ([0-9]+)\\]" ) ; ++ sscanf( temp.c_str(), "%lld", &log_blocksize ); ++ ++ ++ temp = Utils::regexp_label( output, "sector size = ([0-9]+)" ) ; ++ sscanf( temp.c_str(), "%lld", &S ); ++ ++ ++ temp = Utils::regexp_label( output, "total FS sectors = ([0-9]+)" ) ; ++ sscanf( temp.c_str(), "%lld", &total_fs_sectors ); ++ ++ ++ blocksize = (1 << log_blocksize); ++ N = (user_block_count - valid_block_count)*blocksize; ++ T = (total_fs_sectors * S); ++ ++ ++ ++ T = Utils::round( T / double(partition.sector_size) ); ++ N = Utils::round( N / double(partition.sector_size) ); ++ ++ ++ partition.set_sector_usage( T, N ); ++ partition.fs_block_size = S; + } + else + { @@ -121,28 +96,25 @@ index 9bb945c3..704bb71e 100644 bool f2fs::create( const Partition & new_partition, OperationDetail & operationdetail ) { return ! execute_command( "mkfs.f2fs -l " + Glib::shell_quote( new_partition.get_filesystem_label() ) + -@@ -51,4 +141,24 @@ bool f2fs::create( const Partition & new_partition, OperationDetail & operationd - operationdetail, EXEC_CHECK_STATUS ); - } +@@ -53,2 +121,21 @@ +bool f2fs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition ) +{ -+ Glib::ustring str_temp = "resize.f2fs " + Glib::shell_quote( partition_new.get_path() ); ++ Glib::ustring args = ""; + + if ( ! fill_partition ) -+ str_temp += " -t " + Utils::num_to_str( floor( Utils::sector_to_unit( -+ partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) ); ++ args += " -t " + Utils::num_to_str( floor( Utils::sector_to_unit( ++ partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) ) + " "; ++ ++ Glib::ustring str_temp = "resize.f2fs " + args + Glib::shell_quote( partition_new.get_path() ); + + return ! execute_command( str_temp, operationdetail, EXEC_CHECK_STATUS ); +} + +bool f2fs::check_repair( const Partition & partition, OperationDetail & operationdetail ) +{ -+ exit_status = execute_command( "fsck.f2fs -f -y -a " + Glib::shell_quote( partition.get_path() ), -+ operationdetail, EXEC_CANCEL_SAFE ); -+ bool success = ( exit_status == 0 || exit_status == 1 || exit_status == 2 ); -+ set_status( operationdetail, success ); -+ return success; ++ return ! execute_command( "fsck.f2fs -f -y -a " + Glib::shell_quote( partition.get_path() ), ++ operationdetail, EXEC_CHECK_STATUS|EXEC_CANCEL_SAFE ); +} + } //GParted |