fixed some issues with linux-swap. From now on you need 'mkswap' to
* include/GParted_Core.h, src/GParted_Core.cc, src/linux_swap.cc: fixed some issues with linux-swap. From now on you need 'mkswap' to create/resize/move linux-swap.
This commit is contained in:
parent
e5d2cb0eb7
commit
67cd381a03
|
@ -1,3 +1,9 @@
|
|||
2004-12-28 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/GParted_Core.h,
|
||||
src/GParted_Core.cc,
|
||||
src/linux_swap.cc: fixed some issues with linux-swap. From now on you need 'mkswap' to create/resize/move linux-swap.
|
||||
|
||||
2004-12-27 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Device.h,
|
||||
|
|
|
@ -68,7 +68,7 @@ private:
|
|||
void Set_Used_Sectors( Partition & partition );
|
||||
Glib::ustring Get_Flags( PedPartition *c_partition ) ;
|
||||
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 = true ) ;
|
||||
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 ) ;
|
||||
|
||||
void Show_Error( Glib::ustring message ) ;
|
||||
|
|
|
@ -392,14 +392,11 @@ 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 3 still use libparted's resizer.
|
||||
else if ( partition_old .filesystem == "linux-swap" ||
|
||||
partition_old .filesystem == "fat16" ||
|
||||
partition_old .filesystem == "fat32"
|
||||
)
|
||||
//these 2 still use libparted's resizer.
|
||||
else if ( partition_old .filesystem == "fat16" || partition_old .filesystem == "fat32" )
|
||||
return Resize_Normal_Using_Libparted( device .path, partition_old, partition_new ) ;
|
||||
|
||||
//use custom resize tools..(afaik only resize, no moves)
|
||||
//use custom resize tools..
|
||||
else
|
||||
{
|
||||
set_proper_filesystem( partition_new .filesystem ) ;
|
||||
|
@ -407,17 +404,16 @@ bool GParted_Core::Resize( const Device & device, const Partition & partition_ol
|
|||
if ( p_filesystem ->Check_Repair( partition_new ) )
|
||||
{
|
||||
//shrinking
|
||||
if ( partition_new .sector_end < partition_old .sector_end )
|
||||
if ( partition_new .Get_Length_MB( ) < partition_old .Get_Length_MB( ) )
|
||||
{
|
||||
p_filesystem ->cylinder_size = device .cylsize ;
|
||||
|
||||
if ( p_filesystem ->Resize( partition_new ) )
|
||||
Resize_Container_Partition( device .path, partition_old, partition_new ) ;
|
||||
Resize_Container_Partition( device .path, partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ;
|
||||
}
|
||||
|
||||
//growing
|
||||
if ( partition_new .sector_end > partition_old .sector_end )
|
||||
Resize_Container_Partition( device .path, partition_old, partition_new ) ;
|
||||
//growing/moving
|
||||
else
|
||||
Resize_Container_Partition( device .path, partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ;
|
||||
|
||||
|
||||
p_filesystem ->Check_Repair( partition_new ) ;
|
||||
|
@ -567,7 +563,7 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par
|
|||
c_part = ped_partition_new ( disk, type, NULL, new_partition .sector_start, new_partition .sector_end ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
constraint = ped_constraint_any ( device );
|
||||
constraint = ped_constraint_any( device );
|
||||
|
||||
if ( constraint )
|
||||
{
|
||||
|
|
|
@ -27,10 +27,14 @@ FS linux_swap::get_filesystem_support( )
|
|||
|
||||
fs .filesystem = "linux-swap" ;
|
||||
fs .read = false ; //used/unused isn't relevant for swapspace
|
||||
fs .create = true ;
|
||||
fs .grow = true ;
|
||||
fs .shrink = true ;
|
||||
fs .move = true ;
|
||||
|
||||
if ( ! system( "which mkswap 1>/dev/null 2>/dev/null" ) )
|
||||
{
|
||||
fs .create = true ;
|
||||
fs .grow = true ;
|
||||
fs .shrink = true ;
|
||||
fs .move = true ;
|
||||
}
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
|
@ -44,41 +48,12 @@ void linux_swap::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool linux_swap::Create( const Glib::ustring device_path, const Partition & new_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
{
|
||||
PedPartition *c_part = NULL ;
|
||||
PedFileSystemType *fs_type = NULL ;
|
||||
PedFileSystem *fs = NULL ;
|
||||
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (new_partition .sector_end + new_partition .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs_type = ped_file_system_type_get( "linux-swap" ) ;
|
||||
if ( fs_type )
|
||||
{
|
||||
fs = ped_file_system_create( & c_part ->geom, fs_type, NULL );
|
||||
if ( fs )
|
||||
{
|
||||
if ( ped_partition_set_system(c_part, fs_type ) )
|
||||
return_value = Commit( disk ) ;
|
||||
|
||||
ped_file_system_close( fs );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
return ! Execute_Command( "mkswap " + new_partition .partition ) ;
|
||||
}
|
||||
|
||||
bool linux_swap::Resize( const Partition & partition_new, bool fill_partition )
|
||||
{
|
||||
//handled in GParted_Core::Resize_Normal_Using_Libparted
|
||||
return false ;
|
||||
return Create( "", partition_new ) ;
|
||||
}
|
||||
|
||||
bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
|
||||
|
@ -88,7 +63,7 @@ bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring
|
|||
|
||||
bool linux_swap::Check_Repair( const Partition & partition )
|
||||
{
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
int linux_swap::get_estimated_time( long MB_to_Consider )
|
||||
|
|
Loading…
Reference in New Issue