Create separate file system limits structure and getter method (#787204)

PATCH SET OVERVIEW:

Currently the supported actions of each file system and their size
limits are stored in struct FS objects.  These are created by calling
file system specific derived implementations of
FileSystem::get_filesystem_support().  This happens when GParted is
started or when a when a rescan for supported actions is performed.  The
file system size limits are expressed as a fixed number of bytes.

The maximum UDF file system size is specified in terms of file system
block size units.  Also the file system block size must match the sector
size of the underlying device.  Typically 2K for optical media and 512
bytes or 4K for hard drives.

Therefore GParted can't properly express the true UDF file system size
limits because they depend on the block size of an existing UDF file
system or the sector size of the device for new UDF file systems.  In
fact other file systems such as EXT2/3/4 and XFS actually express their
maximum file system size in terms of numbers of file system blocks but
these tend to always be 4K and don't have to match the sector size of
the underlying device, so fixed byte values tend to suffice.

To update GParted for this, first separate file system size limits from
struct FS into struct FS_Limits and provide new
FileSystem::get_filesystem_limits() method to allow the limits to be
queried independently of the calls to get_filesystem_support().
Second, pass Partition objects and allow derived get_filesystem_limits()
implementations.

THIS PATCH:

Just creates a separate structure storing fixed value file system
minimum and maximum size limits along with getter method
get_filesystem_limits().

Bug 787204 - Minimum and maximum size of the UDF partition/disk
This commit is contained in:
Mike Fleetwood 2018-01-11 12:30:48 +00:00 committed by Curtis Gedak
parent c67e069b3a
commit 04535c48b3
2 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include "Operation.h"
#include "Partition.h"
#include "PipeCapture.h"
#include "Utils.h"
#include <fstream>
#include <sys/stat.h>
@ -61,6 +62,7 @@ public:
static const Glib::ustring get_generic_text( CUSTOM_TEXT ttype, int index = 0 ) ;
virtual FS get_filesystem_support() = 0 ;
virtual FS_Limits get_filesystem_limits() const { return fs_limits; };
virtual bool is_busy( const Glib::ustring & path ) { return false ; } ;
virtual void set_used_sectors( Partition & partition ) {};
virtual void read_label( Partition & partition ) {};
@ -98,6 +100,8 @@ protected:
Glib::ustring mk_temp_dir( const Glib::ustring & infix, OperationDetail & operationdetail ) ;
void rm_temp_dir( const Glib::ustring dir_name, OperationDetail & operationdetail ) ;
FS_Limits fs_limits; // File system minimum and maximum size limits
//those are used in several places..
Glib::ustring output, error ;
Sector T, N, S ; //File system [T]otal num of blocks, [N]um of free (or used) blocks, block [S]ize

View File

@ -123,6 +123,16 @@ enum CUSTOM_TEXT
CTEXT_RESIZE_DISALLOWED_WARNING // File system resizing currently disallowed reason
} ;
// Minimum and maximum file system size limits
struct FS_Limits
{
Byte_Value min_size; // 0 => no limit, +ve => limit defined. (As implemented by)
Byte_Value max_size; // -----------------"----------------- (code using these.)
FS_Limits() : min_size( 0 ) , max_size( 0 ) {};
FS_Limits( Byte_Value min, Byte_Value max ) : min_size( min ), max_size( max ) {};
};
//struct to store file system information
struct FS
{