hmmz, lots of shimmery internals.. Instead of using a boolean to indicate
* hmmz, lots of shimmery internals.. Instead of using a boolean to indicate support for certain features i now use and enum (NONE, LIBPARTED, EXTENDED). This allowed me to clean up some stuff that annoyed me ;) Still.. the core could use a bit more love...
This commit is contained in:
parent
7cc702dbdf
commit
cc18d11ad5
|
@ -1,3 +1,10 @@
|
|||
2005-11-27 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
* hmmz, lots of shimmery internals..
|
||||
Instead of using a boolean to indicate support for certain
|
||||
features i now use and enum (NONE, LIBPARTED, EXTENDED).
|
||||
This allowed me to clean up some stuff that annoyed me ;)
|
||||
Still.. the core could use a bit more love...
|
||||
|
||||
2005-11-25 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
* include/Makefile.am,
|
||||
include/Win_GParted.h,
|
||||
|
|
|
@ -26,54 +26,6 @@
|
|||
#include <parted/parted.h>
|
||||
#include <fstream>
|
||||
|
||||
//Some functions used by both (sub)Filesystems and GParted_Core-------------------------------------------------
|
||||
inline bool open_device( const Glib::ustring & device_path, PedDevice *& device )
|
||||
{
|
||||
device = ped_device_get( device_path .c_str( ) );
|
||||
|
||||
return device ;
|
||||
}
|
||||
|
||||
inline bool open_device_and_disk( const Glib::ustring & device_path, PedDevice *& device, PedDisk *& disk, bool strict = true )
|
||||
{
|
||||
if ( open_device( device_path, device ) )
|
||||
disk = ped_disk_new( device );
|
||||
|
||||
//if ! disk and writeable it's probably a HD without disklabel.
|
||||
//We return true here and deal with them in GParted_Core::get_devices
|
||||
if ( ! disk && ( strict || device ->read_only ) )
|
||||
{
|
||||
ped_device_destroy( device ) ;
|
||||
device = NULL ;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
inline void close_device_and_disk( PedDevice *& device, PedDisk *& disk )
|
||||
{
|
||||
if ( device )
|
||||
ped_device_destroy( device ) ;
|
||||
|
||||
if ( disk )
|
||||
ped_disk_destroy( disk ) ;
|
||||
|
||||
device = NULL ;
|
||||
disk = NULL ;
|
||||
}
|
||||
|
||||
inline bool Commit( PedDisk *& disk )
|
||||
{
|
||||
bool return_value = ped_disk_commit_to_dev( disk ) ;
|
||||
|
||||
ped_disk_commit_to_os( disk ) ;
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
|
@ -93,14 +45,11 @@ public:
|
|||
|
||||
Glib::RefPtr<Gtk::TextBuffer> textbuffer ;
|
||||
|
||||
PedDisk *disk ; //see GParted_Core::Set_Used_Sectors() ...
|
||||
long cylinder_size ; //see GParted_Core::Resize()
|
||||
|
||||
protected:
|
||||
int Execute_Command( Glib::ustring command ) ;
|
||||
|
||||
PedDevice *device ;
|
||||
|
||||
private:
|
||||
void Update_Textview( ) ;
|
||||
|
||||
|
|
|
@ -70,7 +70,8 @@ private:
|
|||
void Insert_Unallocated( std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended ) ;
|
||||
Glib::ustring get_sym_path( const Glib::ustring & real_path ) ;
|
||||
void Set_Used_Sectors( Partition & partition );
|
||||
Glib::ustring Get_Flags( PedPartition *c_partition ) ;
|
||||
void LP_Set_Used_Sectors( Partition & partition );
|
||||
Glib::ustring Get_Flags( ) ;
|
||||
int Create_Empty_Partition( const Glib::ustring & device_path, Partition & new_partition, bool copy = false ) ;
|
||||
bool Resize_Container_Partition( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new, bool fixed_start ) ;
|
||||
bool Resize_Normal_Using_Libparted( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new ) ;
|
||||
|
@ -79,17 +80,23 @@ private:
|
|||
void set_proper_filesystem( const Glib::ustring & filesystem ) ;
|
||||
void set_partition_type( const Glib::ustring & device_path, const Partition & partition ) ;
|
||||
|
||||
bool open_device( const Glib::ustring & device_path ) ;
|
||||
bool open_device_and_disk( const Glib::ustring & device_path, bool strict = true ) ;
|
||||
void close_device_and_disk( ) ;
|
||||
bool commit( ) ;
|
||||
|
||||
Glib::RefPtr<Gtk::TextBuffer> textbuffer;
|
||||
|
||||
std::vector<FS> FILESYSTEMS ;
|
||||
FileSystem * p_filesystem ;
|
||||
std::vector <PedPartitionFlag> flags;
|
||||
PedDevice *device ;
|
||||
PedDisk *disk ;
|
||||
PedPartition *c_partition ;
|
||||
Glib::ustring temp ;
|
||||
Partition partition_temp ;
|
||||
FS fs ;
|
||||
|
||||
PedDevice *lp_device ;
|
||||
PedDisk *lp_disk ;
|
||||
PedPartition *lp_partition ;
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -41,20 +41,27 @@ typedef long long Sector;
|
|||
//struct to store filesystems
|
||||
struct FS
|
||||
{
|
||||
enum Support
|
||||
{
|
||||
NONE = 0,
|
||||
LIBPARTED = 1,
|
||||
EXTERNAL = 2
|
||||
};
|
||||
|
||||
Glib::ustring filesystem ;
|
||||
bool read ; //can we get the amount of used sectors?
|
||||
bool create ;
|
||||
bool grow ;
|
||||
bool shrink ;
|
||||
bool move ; //startpoint and endpoint
|
||||
bool check ; //some checktool available?
|
||||
bool copy ;
|
||||
Support read ; //can we get the amount of used sectors?
|
||||
Support create ;
|
||||
Support grow ;
|
||||
Support shrink ;
|
||||
Support move ; //startpoint and endpoint
|
||||
Support check ; //some checktool available?
|
||||
Support copy ;
|
||||
int MIN ;
|
||||
int MAX ;
|
||||
|
||||
FS( )
|
||||
{
|
||||
read = create = grow = shrink = move = check = copy = false ;
|
||||
read = create = grow = shrink = move = check = copy = NONE;
|
||||
MIN = MAX = 0 ;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -55,11 +55,21 @@ void Dialog_Filesystems::Show_Filesystem( const FS & fs )
|
|||
{
|
||||
treerow = *( liststore_filesystems ->append( ) );
|
||||
treerow[ treeview_filesystems_columns .filesystem ] = fs .filesystem ;
|
||||
treerow[ treeview_filesystems_columns .create ] = render_icon( fs .create ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU );
|
||||
treerow[ treeview_filesystems_columns .grow ] = render_icon( fs .grow ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU );
|
||||
treerow[ treeview_filesystems_columns .shrink ] = render_icon( fs .shrink ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU );
|
||||
treerow[ treeview_filesystems_columns .move ] = render_icon( fs .move ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU );
|
||||
treerow[ treeview_filesystems_columns .copy ] = render_icon( fs .copy ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU );
|
||||
|
||||
treerow[ treeview_filesystems_columns .create ] =
|
||||
render_icon( fs .create != GParted::FS::NONE ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_LARGE_TOOLBAR);
|
||||
|
||||
treerow[ treeview_filesystems_columns .grow ] =
|
||||
render_icon( fs .grow != GParted::FS::NONE ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_LARGE_TOOLBAR );
|
||||
|
||||
treerow[ treeview_filesystems_columns .shrink ] =
|
||||
render_icon( fs .shrink != GParted::FS::NONE ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_LARGE_TOOLBAR );
|
||||
|
||||
treerow[ treeview_filesystems_columns .move ] =
|
||||
render_icon( fs .move != GParted::FS::NONE ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_LARGE_TOOLBAR );
|
||||
|
||||
treerow[ treeview_filesystems_columns .copy ] =
|
||||
render_icon( fs .copy != GParted::FS::NONE ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_LARGE_TOOLBAR );
|
||||
}
|
||||
|
||||
Dialog_Filesystems::~Dialog_Filesystems( )
|
||||
|
|
|
@ -38,7 +38,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
this ->cylinder_size = cylinder_size ;
|
||||
this ->FILESYSTEMS = FILESYSTEMS ;
|
||||
this ->FILESYSTEMS .back( ) .filesystem = _("Unformatted") ;
|
||||
this ->FILESYSTEMS .back( ) .create = true ;
|
||||
this ->FILESYSTEMS .back( ) .create = GParted::FS::LIBPARTED ;
|
||||
|
||||
FS fs_tmp ; fs_tmp .filesystem = "extended" ;
|
||||
this ->FILESYSTEMS .push_back( fs_tmp ) ;
|
||||
|
|
|
@ -61,7 +61,7 @@ void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partitio
|
|||
void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partition> & partitions )
|
||||
{
|
||||
if ( ! selected_partition .error .empty( ) )
|
||||
fs .shrink = false ;
|
||||
fs .shrink = GParted::FS::NONE ;
|
||||
|
||||
//see if we need a fixed_start
|
||||
if ( fs .move )
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace GParted
|
|||
|
||||
FileSystem::FileSystem( )
|
||||
{
|
||||
disk = NULL;
|
||||
cylinder_size = 0 ;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ namespace GParted
|
|||
|
||||
GParted_Core::GParted_Core( )
|
||||
{
|
||||
device = NULL ;
|
||||
disk = NULL ;
|
||||
c_partition = NULL ;
|
||||
lp_device = NULL ;
|
||||
lp_disk = NULL ;
|
||||
lp_partition = NULL ;
|
||||
p_filesystem = NULL ;
|
||||
textbuffer = Gtk::TextBuffer::create( ) ;
|
||||
|
||||
|
@ -79,32 +79,32 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
Device temp_device ;
|
||||
std::vector <Glib::ustring> device_paths ;
|
||||
|
||||
device = ped_device_get_next( NULL );
|
||||
lp_device = ped_device_get_next( NULL );
|
||||
|
||||
//in certain cases (e.g. when there's a cd in the cdrom-drive) ped_device_probe_all will find a 'ghost' device that has no name or contains
|
||||
//random garbage. Those 2 checks try to prevent such a ghostdevice from being initialized.. (tested over a 1000 times with and without cd)
|
||||
while ( device && strlen( device ->path ) > 6 && static_cast<Glib::ustring>( device ->path ) .is_ascii( ) )
|
||||
while ( lp_device && strlen( lp_device ->path ) > 6 && static_cast<Glib::ustring>( lp_device ->path ) .is_ascii( ) )
|
||||
{
|
||||
if ( open_device( device ->path, device ) )
|
||||
device_paths .push_back( get_sym_path( device ->path ) ) ;
|
||||
if ( open_device( lp_device ->path ) )
|
||||
device_paths .push_back( get_sym_path( lp_device ->path ) ) ;
|
||||
|
||||
device = ped_device_get_next( device ) ;
|
||||
lp_device = ped_device_get_next( lp_device ) ;
|
||||
}
|
||||
close_device_and_disk( device, disk ) ;
|
||||
close_device_and_disk( ) ;
|
||||
|
||||
for ( unsigned int t = 0 ; t < device_paths .size( ) ; t++ )
|
||||
{
|
||||
if ( open_device_and_disk( device_paths[ t ], device, disk, false ) )
|
||||
if ( open_device_and_disk( device_paths[ t ], false ) )
|
||||
{
|
||||
temp_device .Reset( ) ;
|
||||
|
||||
//device info..
|
||||
temp_device .path = device_paths[ t ] ;
|
||||
temp_device .realpath = device ->path ;
|
||||
temp_device .model = device ->model ;
|
||||
temp_device .heads = device ->bios_geom .heads ;
|
||||
temp_device .sectors = device ->bios_geom .sectors ;
|
||||
temp_device .cylinders = device ->bios_geom .cylinders ;
|
||||
temp_device .realpath = lp_device ->path ;
|
||||
temp_device .model = lp_device ->model ;
|
||||
temp_device .heads = lp_device ->bios_geom .heads ;
|
||||
temp_device .sectors = lp_device ->bios_geom .sectors ;
|
||||
temp_device .cylinders = lp_device ->bios_geom .cylinders ;
|
||||
temp_device .length = temp_device .heads * temp_device .sectors * temp_device .cylinders ;
|
||||
temp_device .cylsize = Sector_To_MB( temp_device .heads * temp_device .sectors ) ;
|
||||
|
||||
|
@ -113,15 +113,15 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
temp_device .cylsize = 1 ;
|
||||
|
||||
//normal harddisk
|
||||
if ( disk )
|
||||
if ( lp_disk )
|
||||
{
|
||||
temp_device .disktype = disk ->type ->name ;
|
||||
temp_device .max_prims = ped_disk_get_max_primary_partition_count( disk ) ;
|
||||
temp_device .disktype = lp_disk ->type ->name ;
|
||||
temp_device .max_prims = ped_disk_get_max_primary_partition_count( lp_disk ) ;
|
||||
|
||||
set_device_partitions( temp_device ) ;
|
||||
|
||||
if ( temp_device .highest_busy )
|
||||
temp_device .readonly = ! ped_disk_commit_to_os( disk ) ;
|
||||
temp_device .readonly = ! ped_disk_commit_to_os( lp_disk ) ;
|
||||
}
|
||||
//harddisk without disklabel
|
||||
else
|
||||
|
@ -136,7 +136,7 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
|
||||
devices .push_back( temp_device ) ;
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
close_device_and_disk( ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,18 +144,18 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
Glib::ustring GParted_Core::Get_Filesystem( )
|
||||
{
|
||||
//standard libparted filesystems..
|
||||
if ( c_partition ->fs_type )
|
||||
return c_partition ->fs_type ->name ;
|
||||
if ( lp_partition ->fs_type )
|
||||
return lp_partition ->fs_type ->name ;
|
||||
|
||||
//other filesystems libparted couldn't detect (i've send patches for these filesystems to the parted guys)
|
||||
char buf[512] ;
|
||||
ped_device_open( device );
|
||||
ped_device_open( lp_device );
|
||||
|
||||
//reiser4
|
||||
ped_geometry_read ( & c_partition ->geom, buf, 128, 1) ;
|
||||
ped_geometry_read ( & lp_partition ->geom, buf, 128, 1) ;
|
||||
strcpy( buf, strcmp( buf, "ReIsEr4" ) == 0 ? "reiser4" : "" ) ;
|
||||
|
||||
ped_device_close( device );
|
||||
ped_device_close( lp_device );
|
||||
if ( strlen( buf ) )
|
||||
return buf ;
|
||||
|
||||
|
@ -178,22 +178,22 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
//clear partitions
|
||||
device .device_partitions .clear( ) ;
|
||||
|
||||
c_partition = ped_disk_next_partition( disk, NULL ) ;
|
||||
while ( c_partition )
|
||||
lp_partition = ped_disk_next_partition( lp_disk, NULL ) ;
|
||||
while ( lp_partition )
|
||||
{
|
||||
partition_temp .Reset( ) ;
|
||||
|
||||
switch ( c_partition ->type )
|
||||
switch ( lp_partition ->type )
|
||||
{
|
||||
case PED_PARTITION_NORMAL:
|
||||
case PED_PARTITION_LOGICAL:
|
||||
partition_temp .Set( device .path + num_to_str( c_partition ->num ),
|
||||
c_partition ->num,
|
||||
c_partition ->type == 0 ? GParted::PRIMARY : GParted::LOGICAL ,
|
||||
Get_Filesystem( ), c_partition ->geom .start,
|
||||
c_partition ->geom .end,
|
||||
c_partition ->type,
|
||||
ped_partition_is_busy( c_partition ) );
|
||||
partition_temp .Set( device .path + num_to_str( lp_partition ->num ),
|
||||
lp_partition ->num,
|
||||
lp_partition ->type == 0 ? GParted::PRIMARY : GParted::LOGICAL ,
|
||||
Get_Filesystem( ), lp_partition ->geom .start,
|
||||
lp_partition ->geom .end,
|
||||
lp_partition ->type,
|
||||
ped_partition_is_busy( lp_partition ) );
|
||||
|
||||
if ( partition_temp .filesystem != "linux-swap" )
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
}
|
||||
}
|
||||
|
||||
partition_temp .flags = Get_Flags( c_partition ) ;
|
||||
partition_temp .flags = Get_Flags( ) ;
|
||||
|
||||
if ( partition_temp .busy && partition_temp .partition_number > device .highest_busy )
|
||||
device .highest_busy = partition_temp .partition_number ;
|
||||
|
@ -216,16 +216,16 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
break ;
|
||||
|
||||
case PED_PARTITION_EXTENDED:
|
||||
partition_temp.Set( device .path + num_to_str( c_partition ->num ),
|
||||
c_partition ->num ,
|
||||
partition_temp.Set( device .path + num_to_str( lp_partition ->num ),
|
||||
lp_partition ->num ,
|
||||
GParted::EXTENDED ,
|
||||
"extended" ,
|
||||
c_partition ->geom .start ,
|
||||
c_partition ->geom .end ,
|
||||
lp_partition ->geom .start ,
|
||||
lp_partition ->geom .end ,
|
||||
false ,
|
||||
ped_partition_is_busy( c_partition ) );
|
||||
ped_partition_is_busy( lp_partition ) );
|
||||
|
||||
partition_temp .flags = Get_Flags( c_partition ) ;
|
||||
partition_temp .flags = Get_Flags( ) ;
|
||||
EXT_INDEX = device .device_partitions .size ( ) ;
|
||||
break ;
|
||||
|
||||
|
@ -242,7 +242,7 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
}
|
||||
|
||||
//next partition (if any)
|
||||
c_partition = ped_disk_next_partition ( disk, c_partition ) ;
|
||||
lp_partition = ped_disk_next_partition ( lp_disk, lp_partition ) ;
|
||||
}
|
||||
|
||||
if ( EXT_INDEX > -1 )
|
||||
|
@ -381,14 +381,14 @@ bool GParted_Core::Create( const Device & device, Partition & new_partition )
|
|||
bool GParted_Core::Convert_FS( const Glib::ustring & device_path, const Partition & partition )
|
||||
{
|
||||
//remove all filesystem signatures...
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
if ( open_device_and_disk( device_path ) )
|
||||
{
|
||||
c_partition = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
|
||||
if ( c_partition )
|
||||
ped_file_system_clobber ( & c_partition ->geom ) ;
|
||||
if ( lp_partition )
|
||||
ped_file_system_clobber ( & lp_partition ->geom ) ;
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
close_device_and_disk( ) ;
|
||||
}
|
||||
|
||||
set_partition_type( device_path, partition ) ;
|
||||
|
@ -402,17 +402,17 @@ bool GParted_Core::Delete( const Glib::ustring & device_path, const Partition &
|
|||
{
|
||||
bool return_value = false ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
if ( open_device_and_disk( device_path ) )
|
||||
{
|
||||
if ( partition .type == GParted::EXTENDED )
|
||||
c_partition = ped_disk_extended_partition( disk ) ;
|
||||
lp_partition = ped_disk_extended_partition( lp_disk ) ;
|
||||
else
|
||||
c_partition = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
|
||||
return_value = ( ped_disk_delete_partition( disk, c_partition ) && Commit( disk ) ) ;
|
||||
close_device_and_disk( device, disk ) ;
|
||||
return_value = ( ped_disk_delete_partition( lp_disk, lp_partition ) && commit( ) ) ;
|
||||
close_device_and_disk( ) ;
|
||||
|
||||
sleep( 1 ) ;//paranoia give the OS some time to update nodes in /dev
|
||||
sleep( 1 ) ;//paranoia: give the OS some time to update nodes in /dev
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
|
@ -423,12 +423,10 @@ bool GParted_Core::Resize( const Device & device, const Partition & partition_ol
|
|||
if ( partition_old .type == GParted::EXTENDED )
|
||||
return Resize_Container_Partition( device .path, partition_old, partition_new, false ) ;
|
||||
|
||||
//these 2 still use libparted's resizer.
|
||||
else if ( partition_old .filesystem == "fat16" || partition_old .filesystem == "fat32" )
|
||||
//lazy check (only grow). it's possbile one day this should be separated in checks for grow,shrink,move ..
|
||||
if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED )
|
||||
return Resize_Normal_Using_Libparted( device .path, partition_old, partition_new ) ;
|
||||
|
||||
//use custom resize tools..
|
||||
else
|
||||
else //use custom resize tools..
|
||||
{
|
||||
set_proper_filesystem( partition_new .filesystem ) ;
|
||||
|
||||
|
@ -440,11 +438,11 @@ bool GParted_Core::Resize( const Device & device, const Partition & partition_ol
|
|||
p_filesystem ->cylinder_size = device .cylsize ;
|
||||
|
||||
if ( p_filesystem ->Resize( partition_new ) )
|
||||
Resize_Container_Partition( device .path, partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ;
|
||||
Resize_Container_Partition( device .path, partition_old, partition_new, get_fs( partition_new .filesystem ) .move != GParted::FS::NONE ) ;
|
||||
}
|
||||
//growing/moving
|
||||
else
|
||||
Resize_Container_Partition( device .path, partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ;
|
||||
Resize_Container_Partition( device .path, partition_old, partition_new, get_fs( partition_new .filesystem ) .move != GParted::FS::NONE ) ;
|
||||
|
||||
|
||||
p_filesystem ->Check_Repair( partition_new ) ;
|
||||
|
@ -476,19 +474,19 @@ bool GParted_Core::Set_Disklabel( const Glib::ustring & device_path, const Glib:
|
|||
{
|
||||
bool return_value = false ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk, false ) )
|
||||
if ( open_device_and_disk( device_path, false ) )
|
||||
{
|
||||
PedDiskType *type = NULL ;
|
||||
type = ped_disk_type_get( disklabel .c_str( ) ) ;
|
||||
|
||||
if ( type )
|
||||
{
|
||||
disk = ped_disk_new_fresh ( device, type);
|
||||
lp_disk = ped_disk_new_fresh ( lp_device, type);
|
||||
|
||||
return_value = Commit( disk ) ;
|
||||
return_value = commit( ) ;
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
close_device_and_disk( ) ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
|
@ -513,7 +511,7 @@ Glib::RefPtr<Gtk::TextBuffer> GParted_Core::get_textbuffer( )
|
|||
return textbuffer ;
|
||||
}
|
||||
|
||||
std::vector<Glib::ustring> GParted_Core::get_disklabeltypes( )
|
||||
std::vector<Glib::ustring> GParted_Core::get_disklabeltypes( )
|
||||
{
|
||||
std::vector<Glib::ustring> disklabeltypes ;
|
||||
|
||||
|
@ -577,13 +575,42 @@ void GParted_Core::Set_Used_Sectors( Partition & partition )
|
|||
file_input .close( );
|
||||
system( "rm -f /tmp/.tmp_gparted" );
|
||||
}
|
||||
else
|
||||
switch( get_fs( partition .filesystem ) .read )
|
||||
{
|
||||
case GParted::FS::EXTERNAL : set_proper_filesystem( partition .filesystem ) ;
|
||||
p_filesystem ->Set_Used_Sectors( partition ) ;
|
||||
break ;
|
||||
case GParted::FS::LIBPARTED : LP_Set_Used_Sectors( partition ) ;
|
||||
break ;
|
||||
case GParted::FS::NONE : break ;
|
||||
}
|
||||
}
|
||||
|
||||
void GParted_Core::LP_Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
PedFileSystem *fs = NULL;
|
||||
PedConstraint *constraint = NULL;
|
||||
|
||||
else if ( get_fs( partition .filesystem ) .read )
|
||||
if ( lp_disk )
|
||||
{
|
||||
set_proper_filesystem( partition .filesystem ) ;
|
||||
|
||||
p_filesystem ->disk = disk ;
|
||||
p_filesystem ->Set_Used_Sectors( partition ) ;
|
||||
if ( lp_partition )
|
||||
{
|
||||
fs = ped_file_system_open( & lp_partition ->geom );
|
||||
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs ) ;
|
||||
if ( constraint )
|
||||
{
|
||||
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close( fs ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -591,7 +618,7 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par
|
|||
{
|
||||
new_partition .partition_number = 0 ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
if ( open_device_and_disk( device_path ) )
|
||||
{
|
||||
PedPartitionType type;
|
||||
PedPartition *c_part = NULL ;
|
||||
|
@ -606,17 +633,17 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par
|
|||
default : type = PED_PARTITION_FREESPACE; break ; //will never happen ;)
|
||||
}
|
||||
|
||||
c_part = ped_partition_new( disk, type, NULL, new_partition .sector_start, new_partition .sector_end ) ;
|
||||
c_part = ped_partition_new( lp_disk, type, NULL, new_partition .sector_start, new_partition .sector_end ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
constraint = ped_constraint_any( device );
|
||||
constraint = ped_constraint_any( lp_device );
|
||||
|
||||
if ( constraint )
|
||||
{
|
||||
if ( copy )
|
||||
constraint ->min_size = new_partition .sector_end - new_partition .sector_start ;
|
||||
|
||||
if ( ped_disk_add_partition( disk, c_part, constraint ) && Commit( disk ) )
|
||||
if ( ped_disk_add_partition( lp_disk, c_part, constraint ) && commit( ) )
|
||||
{
|
||||
//remove all filesystem signatures...
|
||||
ped_file_system_clobber ( & c_part ->geom ) ;
|
||||
|
@ -632,7 +659,7 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par
|
|||
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
close_device_and_disk( ) ;
|
||||
}
|
||||
|
||||
return new_partition .partition_number ;
|
||||
|
@ -643,39 +670,39 @@ bool GParted_Core::Resize_Container_Partition( const Glib::ustring & device_path
|
|||
bool return_value = false ;
|
||||
|
||||
PedConstraint *constraint = NULL ;
|
||||
c_partition = NULL ;
|
||||
lp_partition = NULL ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
if ( open_device_and_disk( device_path ) )
|
||||
{
|
||||
if ( partition_old .type == GParted::EXTENDED )
|
||||
c_partition = ped_disk_extended_partition( disk ) ;
|
||||
lp_partition = ped_disk_extended_partition( lp_disk ) ;
|
||||
else
|
||||
c_partition = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
|
||||
if ( c_partition )
|
||||
if ( lp_partition )
|
||||
{
|
||||
constraint = ped_constraint_any( device );
|
||||
constraint = ped_constraint_any( lp_device );
|
||||
|
||||
if ( fixed_start && constraint ) //create a constraint which keeps de startpoint intact and rounds the end to a cylinderboundary
|
||||
{
|
||||
ped_disk_set_partition_geom ( disk, c_partition, constraint, partition_new .sector_start, partition_new .sector_end ) ;
|
||||
ped_disk_set_partition_geom ( lp_disk, lp_partition, constraint, partition_new .sector_start, partition_new .sector_end ) ;
|
||||
ped_constraint_destroy ( constraint );
|
||||
constraint = NULL ;
|
||||
|
||||
ped_geometry_set_start ( & c_partition ->geom, partition_new .sector_start ) ;
|
||||
constraint = ped_constraint_exact ( & c_partition ->geom ) ;
|
||||
ped_geometry_set_start ( & lp_partition ->geom, partition_new .sector_start ) ;
|
||||
constraint = ped_constraint_exact ( & lp_partition ->geom ) ;
|
||||
}
|
||||
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_partition, constraint, partition_new .sector_start, partition_new .sector_end ) )
|
||||
return_value = Commit( disk ) ;
|
||||
if ( ped_disk_set_partition_geom ( lp_disk, lp_partition, constraint, partition_new .sector_start, partition_new .sector_end ) )
|
||||
return_value = commit( ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
close_device_and_disk( ) ;
|
||||
}
|
||||
|
||||
sleep( 1 ) ; //the OS needs time to re-add the devicenode..
|
||||
|
@ -689,23 +716,23 @@ bool GParted_Core::Resize_Normal_Using_Libparted( const Glib::ustring & device_p
|
|||
|
||||
PedFileSystem *fs = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
c_partition = NULL ;
|
||||
lp_partition = NULL ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
if ( open_device_and_disk( device_path ) )
|
||||
{
|
||||
c_partition = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( c_partition )
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( lp_partition )
|
||||
{
|
||||
fs = ped_file_system_open ( & c_partition ->geom );
|
||||
fs = ped_file_system_open ( & lp_partition ->geom );
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs );
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_partition, constraint, partition_new .sector_start, partition_new .sector_end ) &&
|
||||
ped_file_system_resize ( fs, & c_partition ->geom, NULL )
|
||||
if ( ped_disk_set_partition_geom ( lp_disk, lp_partition, constraint, partition_new .sector_start, partition_new .sector_end ) &&
|
||||
ped_file_system_resize ( fs, & lp_partition ->geom, NULL )
|
||||
)
|
||||
return_value = Commit( disk ) ;
|
||||
return_value = commit( ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
@ -714,19 +741,19 @@ bool GParted_Core::Resize_Normal_Using_Libparted( const Glib::ustring & device_p
|
|||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
close_device_and_disk( ) ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
Glib::ustring GParted_Core::Get_Flags( PedPartition *c_partition )
|
||||
Glib::ustring GParted_Core::Get_Flags( )
|
||||
{
|
||||
temp = "";
|
||||
|
||||
for ( unsigned short t = 0; t < flags .size( ) ; t++ )
|
||||
if ( ped_partition_get_flag ( c_partition, flags[ t ] ) )
|
||||
temp += (Glib::ustring) ped_partition_flag_get_name ( flags[ t ] ) + " ";
|
||||
if ( ped_partition_get_flag ( lp_partition, flags[ t ] ) )
|
||||
temp += static_cast<Glib::ustring>( ped_partition_flag_get_name( flags[ t ] ) ) + " ";
|
||||
|
||||
return temp ;
|
||||
}
|
||||
|
@ -783,7 +810,7 @@ void GParted_Core::set_proper_filesystem( const Glib::ustring & filesystem )
|
|||
|
||||
void GParted_Core::set_partition_type( const Glib::ustring & device_path, const Partition & partition )
|
||||
{
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
if ( open_device_and_disk( device_path ) )
|
||||
{
|
||||
PedFileSystemType * fs_type = ped_file_system_type_get( partition .filesystem .c_str() ) ;
|
||||
|
||||
|
@ -793,14 +820,61 @@ void GParted_Core::set_partition_type( const Glib::ustring & device_path, const
|
|||
|
||||
if ( fs_type )
|
||||
{
|
||||
c_partition = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
|
||||
if ( c_partition && ped_partition_set_system( c_partition, fs_type ) && Commit( disk ) )
|
||||
if ( lp_partition && ped_partition_set_system( lp_partition, fs_type ) && commit( ) )
|
||||
sleep( 1 ) ; //the OS needs some time to update nodes in /dev
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
close_device_and_disk( ) ;
|
||||
}
|
||||
}
|
||||
|
||||
bool GParted_Core::open_device( const Glib::ustring & device_path )
|
||||
{
|
||||
lp_device = ped_device_get( device_path .c_str( ) );
|
||||
|
||||
return lp_device ;
|
||||
}
|
||||
|
||||
bool GParted_Core::open_device_and_disk( const Glib::ustring & device_path, bool strict )
|
||||
{
|
||||
if ( open_device( device_path ) )
|
||||
lp_disk = ped_disk_new( lp_device );
|
||||
|
||||
//if ! disk and writeable it's probably a HD without disklabel.
|
||||
//We return true here and deal with them in GParted_Core::get_devices
|
||||
if ( ! lp_disk && ( strict || lp_device ->read_only ) )
|
||||
{
|
||||
ped_device_destroy( lp_device ) ;
|
||||
lp_device = NULL ;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void GParted_Core::close_device_and_disk( )
|
||||
{
|
||||
if ( lp_device )
|
||||
ped_device_destroy( lp_device ) ;
|
||||
|
||||
if ( lp_disk )
|
||||
ped_disk_destroy( lp_disk ) ;
|
||||
|
||||
lp_device = NULL ;
|
||||
lp_disk = NULL ;
|
||||
}
|
||||
|
||||
bool GParted_Core::commit( )
|
||||
{
|
||||
bool return_value = ped_disk_commit_to_dev( lp_disk ) ;
|
||||
|
||||
ped_disk_commit_to_os( lp_disk ) ;
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -618,11 +618,11 @@ void Win_GParted::Set_Valid_Operations( )
|
|||
allow_convert( true ) ;
|
||||
|
||||
//find out if resizing/moving is possible
|
||||
if ( (fs .grow || fs .shrink) && ! devices[ current_device ] .readonly )
|
||||
if ( (fs .grow != GParted::FS::NONE || fs .shrink != GParted::FS::NONE ) && ! devices[ current_device ] .readonly )
|
||||
allow_resize( true ) ;
|
||||
|
||||
//only allow copying of real partitions
|
||||
if ( selected_partition .status == GParted::STAT_REAL && fs .copy )
|
||||
if ( selected_partition .status == GParted::STAT_REAL && fs .copy != GParted::FS::NONE )
|
||||
allow_copy( true ) ;
|
||||
|
||||
return ;
|
||||
|
|
18
src/ext2.cc
18
src/ext2.cc
|
@ -27,25 +27,25 @@ FS ext2::get_filesystem_support( )
|
|||
|
||||
fs .filesystem = "ext2" ;
|
||||
if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .read = true ;
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which mkfs.ext2 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
|
||||
fs .check = true ;
|
||||
fs .check = GParted::FS::EXTERNAL ;
|
||||
|
||||
//resizing is a delicate process ...
|
||||
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .check )
|
||||
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .check != GParted::FS::NONE )
|
||||
{
|
||||
fs .grow = true ;
|
||||
fs .grow = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( fs .read ) //needed to determine a min filesystemsize..
|
||||
fs .shrink = true ;
|
||||
if ( fs .read != GParted::FS::NONE ) //needed to determine a min filesystemsize..
|
||||
fs .shrink = GParted::FS::EXTERNAL ;
|
||||
}
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow )
|
||||
fs .copy = true ;
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow != GParted::FS::NONE )
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
|
20
src/ext3.cc
20
src/ext3.cc
|
@ -27,26 +27,26 @@ FS ext3::get_filesystem_support( )
|
|||
|
||||
fs .filesystem = "ext3" ;
|
||||
if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .read = true ;
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which mkfs.ext3 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
|
||||
fs .check = true ;
|
||||
fs .check = GParted::FS::EXTERNAL ;
|
||||
|
||||
//resizing is a delicate process ...
|
||||
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .check )
|
||||
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .check != GParted::FS::NONE )
|
||||
{
|
||||
fs .grow = true ;
|
||||
fs .grow = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( fs .read ) //needed to determine a min filesystemsize..
|
||||
fs .shrink = true ;
|
||||
if ( fs .read != GParted::FS::NONE ) //needed to determine a min filesystemsize..
|
||||
fs .shrink = GParted::FS::EXTERNAL ;
|
||||
}
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow)
|
||||
fs .copy = true ;
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow != GParted::FS::NONE )
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
|
|
14
src/fat16.cc
14
src/fat16.cc
|
@ -29,21 +29,21 @@ FS fat16::get_filesystem_support( )
|
|||
|
||||
//find out if we can create fat16 filesystems
|
||||
if ( ! system( "which mkdosfs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which dosfsck 1>/dev/null 2>/dev/null" ) )
|
||||
{
|
||||
fs .check = true ;
|
||||
fs .read = true ;
|
||||
fs .check = GParted::FS::EXTERNAL ;
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
}
|
||||
|
||||
//resizing of start and endpoint are provided by libparted
|
||||
fs .grow = true ;
|
||||
fs .shrink = true ;
|
||||
fs .move = true ;
|
||||
fs .grow = GParted::FS::LIBPARTED ;
|
||||
fs .shrink = GParted::FS::LIBPARTED ;
|
||||
fs .move = GParted::FS::LIBPARTED ;
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
fs .MIN = 16 ;
|
||||
fs .MAX = 4096 ;
|
||||
|
|
16
src/fat32.cc
16
src/fat32.cc
|
@ -29,22 +29,22 @@ FS fat32::get_filesystem_support( )
|
|||
|
||||
//find out if we can create fat32 filesystems
|
||||
if ( ! system( "which mkdosfs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which dosfsck 1>/dev/null 2>/dev/null" ) )
|
||||
{
|
||||
fs .check = true ;
|
||||
fs .read = true ;
|
||||
fs .check = GParted::FS::EXTERNAL ;
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
}
|
||||
|
||||
//resizing of start and endpoint are provided by libparted
|
||||
fs .grow = true ;
|
||||
fs .shrink = true ;
|
||||
fs .move = true ;
|
||||
fs .grow = GParted::FS::LIBPARTED ;
|
||||
fs .shrink = GParted::FS::LIBPARTED ;
|
||||
fs .move = GParted::FS::LIBPARTED ;
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
fs .MIN = 32 ; //smaller fs'es will cause windows scandisk to fail..
|
||||
|
||||
return fs ;
|
||||
|
|
31
src/hfs.cc
31
src/hfs.cc
|
@ -27,13 +27,13 @@ FS hfs::get_filesystem_support( )
|
|||
|
||||
fs .filesystem = "hfs" ;
|
||||
|
||||
fs .read = true ; //provided by libparted
|
||||
fs .read = GParted::FS::LIBPARTED; //provided by libparted
|
||||
|
||||
if ( ! system( "which hformat 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
fs .MAX = 2048 ;
|
||||
|
||||
|
@ -42,31 +42,6 @@ FS hfs::get_filesystem_support( )
|
|||
|
||||
void hfs::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
PedFileSystem *fs = NULL;
|
||||
PedConstraint *constraint = NULL;
|
||||
PedPartition *c_part = NULL ;
|
||||
|
||||
if ( disk )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open( & c_part ->geom );
|
||||
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs ) ;
|
||||
if ( constraint )
|
||||
{
|
||||
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close( fs ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hfs::Create( const Partition & new_partition )
|
||||
|
|
|
@ -27,38 +27,13 @@ FS hfsplus::get_filesystem_support( )
|
|||
|
||||
fs .filesystem = "hfs+" ;
|
||||
|
||||
fs .read = true ; //provided by libparted
|
||||
fs .read = GParted::FS::LIBPARTED ; //provided by libparted
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
void hfsplus::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
PedFileSystem *fs = NULL;
|
||||
PedConstraint *constraint = NULL;
|
||||
PedPartition *c_part = NULL ;
|
||||
|
||||
if ( disk )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open( & c_part ->geom );
|
||||
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs ) ;
|
||||
if ( constraint )
|
||||
{
|
||||
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close( fs ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hfsplus::Create( const Partition & new_partition )
|
||||
|
|
12
src/jfs.cc
12
src/jfs.cc
|
@ -28,13 +28,13 @@ FS jfs::get_filesystem_support( )
|
|||
fs .filesystem = "jfs" ;
|
||||
|
||||
if ( ! system( "which jfs_debugfs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .read = true ;
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which mkfs.jfs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which jfs_fsck 1>/dev/null 2>/dev/null" ) )
|
||||
fs .check = true ;
|
||||
fs .check = GParted::FS::EXTERNAL ;
|
||||
|
||||
//resizing of jfs requires mount, umount and jfs support in the kernel
|
||||
if ( ! system( "which mount umount 1>/dev/null 2>/dev/null" ) )
|
||||
|
@ -44,15 +44,15 @@ FS jfs::get_filesystem_support( )
|
|||
while ( input >> line )
|
||||
if ( line == "jfs" )
|
||||
{
|
||||
fs .grow = true ;
|
||||
fs .grow = GParted::FS::EXTERNAL ;
|
||||
break ;
|
||||
}
|
||||
|
||||
input .close( ) ;
|
||||
}
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow)
|
||||
fs .copy = true ;
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow != GParted::FS::NONE )
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
fs .MIN = 16 ;
|
||||
|
||||
|
|
|
@ -26,18 +26,17 @@ FS linux_swap::get_filesystem_support( )
|
|||
FS fs ;
|
||||
|
||||
fs .filesystem = "linux-swap" ;
|
||||
fs .read = false ; //used/unused isn't relevant for swapspace
|
||||
|
||||
if ( ! system( "which mkswap 1>/dev/null 2>/dev/null" ) )
|
||||
{
|
||||
fs .create = true ;
|
||||
fs .grow = true ;
|
||||
fs .shrink = true ;
|
||||
fs .move = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
fs .grow = GParted::FS::EXTERNAL ;
|
||||
fs .shrink = GParted::FS::EXTERNAL ;
|
||||
fs .move = GParted::FS::EXTERNAL ;
|
||||
}
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
|
18
src/ntfs.cc
18
src/ntfs.cc
|
@ -27,26 +27,26 @@ FS ntfs::get_filesystem_support( )
|
|||
|
||||
fs .filesystem = "ntfs" ;
|
||||
if ( ! system( "which ntfscluster 1>/dev/null 2>/dev/null" ) )
|
||||
fs .read = true ;
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which mkntfs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which ntfsfix 1>/dev/null 2>/dev/null" ) )
|
||||
fs .check = true ;
|
||||
fs .check = GParted::FS::EXTERNAL ;
|
||||
|
||||
//resizing is a delicate process ...
|
||||
if ( ! system( "which ntfsresize 1>/dev/null 2>/dev/null" ) && fs .check )
|
||||
if ( ! system( "which ntfsresize 1>/dev/null 2>/dev/null" ) && fs .check != GParted::FS::NONE )
|
||||
{
|
||||
fs .grow = true ;
|
||||
fs .grow = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( fs .read ) //needed to determine a min filesystemsize..
|
||||
fs .shrink = true ;
|
||||
if ( fs .read != GParted::FS::NONE ) //needed to determine a min filesystemsize..
|
||||
fs .shrink = GParted::FS::EXTERNAL ;
|
||||
}
|
||||
|
||||
//we need ntfsresize to set correct used/unused after cloning
|
||||
if ( ! system( "which ntfsclone 1>/dev/null 2>/dev/null" ) && fs .grow )
|
||||
fs .copy = true ;
|
||||
if ( ! system( "which ntfsclone 1>/dev/null 2>/dev/null" ) && fs .grow != GParted::FS::NONE )
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
|
|
@ -28,29 +28,19 @@ FS reiser4::get_filesystem_support( )
|
|||
fs .filesystem = "reiser4" ;
|
||||
|
||||
if ( ! system( "which debugfs.reiser4 1>/dev/null 2>/dev/null" ) )
|
||||
fs .read = true ;
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which mkfs.reiser4 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which fsck.reiser4 1>/dev/null 2>/dev/null" ) )
|
||||
fs .check = true ;
|
||||
fs .check = GParted::FS::EXTERNAL ;
|
||||
|
||||
/*IT SEEMS RESIZE AND COPY AREN'T IMPLEMENTED YET IN THE TOOLS...
|
||||
SEE http://marc.theaimsgroup.com/?t=109883161600003&r=1&w=2 for more information.. (it seems NameSys is getting commercial? :| )
|
||||
//resizing is a delicate process ...
|
||||
if ( ! system( "which resizefs.reiser4 1>/dev/null 2>/dev/null" ) && fs .check )
|
||||
{
|
||||
fs .grow = true ;
|
||||
|
||||
if ( fs .read ) //needed to determine a min filesystemsize..
|
||||
fs .shrink = true ;
|
||||
}
|
||||
|
||||
//we need to call resize_reiserfs after a copy to get proper used/unused
|
||||
if ( ! system( "which cpfs.reiser4 1>/dev/null 2>/dev/null" ) && fs .grow )
|
||||
fs .copy = true ;
|
||||
/*
|
||||
* IT SEEMS RESIZE AND COPY AREN'T IMPLEMENTED YET IN THE TOOLS...
|
||||
* SEE http://marc.theaimsgroup.com/?t=109883161600003&r=1&w=2 for more information.. (it seems NameSys is getting commercial? :| )
|
||||
*/
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
|
@ -88,27 +78,12 @@ bool reiser4::Create( const Partition & new_partition )
|
|||
}
|
||||
|
||||
bool reiser4::Resize( const Partition & partition_new, bool fill_partition )
|
||||
{/*
|
||||
Glib::ustring str_temp = "LC_NUMERIC=C echo y | resize_reiserfs " + partition_new .partition ;
|
||||
|
||||
if ( ! fill_partition )
|
||||
str_temp += " -s " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
|
||||
|
||||
return ! Execute_Command( str_temp ) ; */
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool reiser4::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
|
||||
{
|
||||
/* if ( ! Execute_Command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path ) )
|
||||
{
|
||||
Partition partition ;
|
||||
partition .partition = dest_part_path ;
|
||||
return Resize( partition, true ) ;
|
||||
}
|
||||
|
||||
return false ;*/
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,26 +28,26 @@ FS reiserfs::get_filesystem_support( )
|
|||
fs .filesystem = "reiserfs" ;
|
||||
|
||||
if ( ! system( "which debugreiserfs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .read = true ;
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which mkreiserfs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which reiserfsck 1>/dev/null 2>/dev/null" ) )
|
||||
fs .check = true ;
|
||||
fs .check = GParted::FS::EXTERNAL ;
|
||||
|
||||
//resizing is a delicate process ...
|
||||
if ( ! system( "which resize_reiserfs 1>/dev/null 2>/dev/null" ) && fs .check )
|
||||
if ( ! system( "which resize_reiserfs 1>/dev/null 2>/dev/null" ) && fs .check != GParted::FS::NONE )
|
||||
{
|
||||
fs .grow = true ;
|
||||
fs .grow = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( fs .read ) //needed to determine a min filesystemsize..
|
||||
fs .shrink = true ;
|
||||
if ( fs .read != GParted::FS::NONE ) //needed to determine a min filesystemsize..
|
||||
fs .shrink = GParted::FS::EXTERNAL ;
|
||||
}
|
||||
|
||||
//we need to call resize_reiserfs after a copy to get proper used/unused
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow )
|
||||
fs .copy = true ;
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow != GParted::FS::NONE )
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
fs .MIN = 32 ;
|
||||
|
||||
|
|
14
src/xfs.cc
14
src/xfs.cc
|
@ -28,31 +28,31 @@ FS xfs::get_filesystem_support( )
|
|||
fs .filesystem = "xfs" ;
|
||||
|
||||
if ( ! system( "which xfs_db 1>/dev/null 2>/dev/null" ) )
|
||||
fs .read = true ;
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which mkfs.xfs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
|
||||
if ( ! system( "which xfs_repair 1>/dev/null 2>/dev/null" ) )
|
||||
fs .check = true ;
|
||||
fs .check = GParted::FS::EXTERNAL ;
|
||||
|
||||
//resizing of xfs requires xfs_growfs, xfs_repair, mount, umount and xfs support in the kernel
|
||||
if ( ! system( "which xfs_growfs mount umount 1>/dev/null 2>/dev/null" ) && fs .check )
|
||||
if ( ! system( "which xfs_growfs mount umount 1>/dev/null 2>/dev/null" ) && fs .check != GParted::FS::NONE )
|
||||
{
|
||||
Glib::ustring line ;
|
||||
std::ifstream input( "/proc/filesystems" ) ;
|
||||
while ( input >> line )
|
||||
if ( line == "xfs" )
|
||||
{
|
||||
fs .grow = true ;
|
||||
fs .grow = GParted::FS::EXTERNAL ;
|
||||
break ;
|
||||
}
|
||||
|
||||
input .close( ) ;
|
||||
}
|
||||
|
||||
if ( ! system( "which xfsdump xfsrestore mount umount 1>/dev/null 2>/dev/null" ) && fs .check && fs .create )
|
||||
fs .copy = true ;
|
||||
if ( ! system( "which xfsdump xfsrestore mount umount 1>/dev/null 2>/dev/null" ) && fs .check != GParted::FS::NONE && fs .create != GParted::FS::NONE )
|
||||
fs .copy = GParted::FS::EXTERNAL ;
|
||||
|
||||
fs .MIN = 32 ;//official minsize = 16MB, but the smallest xfs_repair can handle is 32MB...
|
||||
|
||||
|
|
Loading…
Reference in New Issue