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
This commit is contained in:
Mike Fleetwood 2018-01-17 19:36:48 +00:00 committed by Curtis Gedak
parent 668957c0a4
commit ae2a8723b5
2 changed files with 11 additions and 6 deletions

View File

@ -33,6 +33,7 @@ public:
udf() : old_mkudffs( false ) {}; udf() : old_mkudffs( false ) {};
FS get_filesystem_support(); FS get_filesystem_support();
FS_Limits get_filesystem_limits( const Partition & partition ) const;
void set_used_sectors( Partition & partition ); void set_used_sectors( Partition & partition );
void read_label( Partition & partition ); void read_label( Partition & partition );
bool write_label( const Partition & partition, OperationDetail & operationdetail ); bool write_label( const Partition & partition, OperationDetail & operationdetail );

View File

@ -28,9 +28,6 @@ namespace GParted
const Byte_Value MIN_UDF_BLOCKS = 300; const Byte_Value MIN_UDF_BLOCKS = 300;
const Byte_Value MAX_UDF_BLOCKS = (1LL << 32) - 1; 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 udf::get_filesystem_support()
{ {
FS fs( FS_UDF ); FS fs( FS_UDF );
@ -64,12 +61,19 @@ FS udf::get_filesystem_support()
fs.write_uuid = FS::EXTERNAL; 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; 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 ) void udf::set_used_sectors( Partition & partition )
{ {
exit_status = Utils::execute_command( "udfinfo --utf8 " + Glib::shell_quote( partition.get_path() ), exit_status = Utils::execute_command( "udfinfo --utf8 " + Glib::shell_quote( partition.get_path() ),