[gparted] Set dynamic UDF file system size limits (#787204)



commit ae2a8723b5b457eb628953dd19e5368ea2f63c2e
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Wed Jan 17 19:36:48 2018 +0000

    Set dynamic UDF file system size limits (#787204)
    
    UDF file system minimum and maximum size limits are defined in terms of
    numbers of file system blocks.  So when resizing an existing file system
    compute the byte size limits from the existing UDF file system's block
    size.  Alternatively when creating a new UDF file system use the
    device's sector size as the multiplier instead.
    
    Bug 787204 - Minimum and maximum size of the UDF partition/disk

 include/udf.h |    1 +
 src/udf.cc    |   16 ++++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/include/udf.h b/include/udf.h
index c34a8a4..acfe54e 100644
--- a/include/udf.h
+++ b/include/udf.h
@@ -33,6 +33,7 @@ public:
        udf() : old_mkudffs( false ) {};
 
        FS get_filesystem_support();
+       FS_Limits get_filesystem_limits( const Partition & partition ) const;
        void set_used_sectors( Partition & partition );
        void read_label( Partition & partition );
        bool write_label( const Partition & partition, OperationDetail & operationdetail );
diff --git a/src/udf.cc b/src/udf.cc
index 204496c..7a0baa3 100644
--- a/src/udf.cc
+++ b/src/udf.cc
@@ -28,9 +28,6 @@ namespace GParted
 const Byte_Value MIN_UDF_BLOCKS = 300;
 const Byte_Value MAX_UDF_BLOCKS = (1LL << 32) - 1;
 
-const Byte_Value MIN_UDF_BLOCKSIZE = 512;
-const Byte_Value MAX_UDF_BLOCKSIZE = 4096;
-
 FS udf::get_filesystem_support()
 {
        FS fs( FS_UDF );
@@ -64,12 +61,19 @@ FS udf::get_filesystem_support()
                fs.write_uuid = FS::EXTERNAL;
        }
 
-       fs_limits.min_size = MIN_UDF_BLOCKS * MIN_UDF_BLOCKSIZE;
-       fs_limits.max_size = MAX_UDF_BLOCKS * MAX_UDF_BLOCKSIZE;
-
        return fs;
 }
 
+FS_Limits udf::get_filesystem_limits( const Partition & partition ) const
+{
+       if ( partition.filesystem == FS_UDF && partition.fs_block_size > 0 )
+               // Resizing existing UDF file system
+               return FS_Limits( MIN_UDF_BLOCKS * partition.fs_block_size, MAX_UDF_BLOCKS * 
partition.fs_block_size );
+       else
+               // Creating new UDF file system
+               return FS_Limits( MIN_UDF_BLOCKS * partition.sector_size  , MAX_UDF_BLOCKS * 
partition.sector_size );
+}
+
 void udf::set_used_sectors( Partition & partition )
 {
        exit_status = Utils::execute_command( "udfinfo --utf8 " + Glib::shell_quote( partition.get_path() ),


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