Removed bool Get_Any_Busy() in favor of public bool busy which is set in
* include/Device.h, src/Device.cc: Removed bool Get_Any_Busy() in favor of public bool busy which is set in gparted_core. This also fixed a small bug with incorrect mountdetection of logical partitions. Also added a Reset() function to properly reset the contents of a device. to zero/empty . * include/GParted_Core.h, src/GParted_Core.cc: 'busyness' of a device is now determined in get_devices(). Renamed get_partitions() to set_device_partitions to reflect its proper function. When a new partition is created to contain a copied filesystem the size is now properly set. This fixes a very annoying bug which no one knew about except for me =) . * src/Win_GParted.cc: use boolean busy from device instead of Get_Any_Busy() .
This commit is contained in:
parent
7a3fb89e81
commit
4438e3264e
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2004-11-19 Bart Hakvoort <gparted@users.sf.net>
|
||||||
|
|
||||||
|
* include/Device.h,
|
||||||
|
src/Device.cc: Removed bool Get_Any_Busy() in favor of public bool busy which is set in gparted_core.
|
||||||
|
This also fixed a small bug with incorrect mountdetection of logical partitions.
|
||||||
|
Also added a Reset() function to properly reset the contents of a device. to zero/empty .
|
||||||
|
* include/GParted_Core.h,
|
||||||
|
src/GParted_Core.cc: 'busyness' of a device is now determined in get_devices().
|
||||||
|
Renamed get_partitions() to set_device_partitions to reflect its proper function.
|
||||||
|
When a new partition is created to contain a copied filesystem the size is now properly set. This fixes
|
||||||
|
a very annoying bug which no one knew about except for me =) .
|
||||||
|
* src/Win_GParted.cc: use boolean busy from device instead of Get_Any_Busy() .
|
||||||
|
|
||||||
2004-11-17 Bart Hakvoort <gparted@users.sf.net>
|
2004-11-17 Bart Hakvoort <gparted@users.sf.net>
|
||||||
|
|
||||||
* src/ext3.cc: availability of 'tune2fs' command wasn't detected correctly. fixed
|
* src/ext3.cc: availability of 'tune2fs' command wasn't detected correctly. fixed
|
||||||
|
|
|
@ -27,10 +27,10 @@ class Device
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Device() ;
|
Device( ) ;
|
||||||
~Device() ;
|
~Device( ) ;
|
||||||
|
|
||||||
bool Get_any_busy( ) ;
|
void Reset( ) ;
|
||||||
int Get_Highest_Logical_Busy( ) ;
|
int Get_Highest_Logical_Busy( ) ;
|
||||||
|
|
||||||
std::vector<Partition> device_partitions ;
|
std::vector<Partition> device_partitions ;
|
||||||
|
@ -43,6 +43,7 @@ public:
|
||||||
Glib::ustring realpath;
|
Glib::ustring realpath;
|
||||||
Glib::ustring disktype;
|
Glib::ustring disktype;
|
||||||
int max_prims ;
|
int max_prims ;
|
||||||
|
bool busy ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
GParted_Core( ) ;
|
GParted_Core( ) ;
|
||||||
void find_supported_filesystems( ) ;
|
void find_supported_filesystems( ) ;
|
||||||
void get_devices( std::vector<Device> & devices, bool deep_scan ) ;
|
void get_devices( std::vector<Device> & devices, bool deep_scan ) ;
|
||||||
void get_partitions( std::vector<Partition> & partitions, const Glib::ustring & device_path, bool deep_scan = true ) ;
|
|
||||||
int get_estimated_time( Operation & operation ) ;
|
int get_estimated_time( Operation & operation ) ;
|
||||||
|
|
||||||
void Apply_Operation_To_Disk( Operation & operation );
|
void Apply_Operation_To_Disk( Operation & operation );
|
||||||
|
@ -55,10 +55,11 @@ public:
|
||||||
Glib::RefPtr<Gtk::TextBuffer> get_textbuffer( ) ;
|
Glib::RefPtr<Gtk::TextBuffer> get_textbuffer( ) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void set_device_partitions( Device & device, bool deep_scan = true ) ;
|
||||||
Glib::ustring get_sym_path( const Glib::ustring & real_path ) ;
|
Glib::ustring get_sym_path( const Glib::ustring & real_path ) ;
|
||||||
Sector Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring & sym_path );
|
Sector Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring & sym_path );
|
||||||
Glib::ustring Get_Flags( PedPartition *c_partition ) ;
|
Glib::ustring Get_Flags( PedPartition *c_partition ) ;
|
||||||
int Create_Empty_Partition( const Glib::ustring & device_path, Partition & new_partition ) ;
|
int Create_Empty_Partition( const Glib::ustring & device_path, Partition & new_partition, bool copy = false ) ;
|
||||||
bool Resize_Extended( const Glib::ustring & device_path, const Partition & extended ) ;
|
bool Resize_Extended( const Glib::ustring & device_path, const Partition & extended ) ;
|
||||||
|
|
||||||
void Show_Error( Glib::ustring message ) ;
|
void Show_Error( Glib::ustring message ) ;
|
||||||
|
|
|
@ -22,15 +22,17 @@ namespace GParted
|
||||||
|
|
||||||
Device::Device( )
|
Device::Device( )
|
||||||
{
|
{
|
||||||
|
Reset( ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::Get_any_busy( )
|
void Device::Reset( )
|
||||||
{
|
{
|
||||||
for ( unsigned int t=0;t<device_partitions.size(); t++ )
|
device_partitions .clear( ) ;
|
||||||
if ( device_partitions[t].busy )
|
length = 0 ;
|
||||||
return true;
|
heads = sectors = cylinders = 0 ;
|
||||||
|
model = path = realpath = disktype ;
|
||||||
return false;
|
max_prims = 0 ;
|
||||||
|
busy = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Device::Get_Highest_Logical_Busy( )
|
int Device::Get_Highest_Logical_Busy( )
|
||||||
|
@ -50,7 +52,7 @@ int Device::Get_Highest_Logical_Busy( )
|
||||||
return highest_logic_busy ;
|
return highest_logic_busy ;
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::~Device()
|
Device::~Device( )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,8 @@ void GParted_Core::get_devices( std::vector<Device> & devices, bool deep_scan )
|
||||||
{
|
{
|
||||||
if ( open_device_and_disk( device_paths[ t ], device, disk ) )
|
if ( open_device_and_disk( device_paths[ t ], device, disk ) )
|
||||||
{
|
{
|
||||||
|
temp_device .Reset( ) ;
|
||||||
|
|
||||||
temp_device .path = device_paths[ t ] ;
|
temp_device .path = device_paths[ t ] ;
|
||||||
temp_device .realpath = device ->path ;
|
temp_device .realpath = device ->path ;
|
||||||
temp_device .model = device ->model ;
|
temp_device .model = device ->model ;
|
||||||
|
@ -95,7 +97,7 @@ void GParted_Core::get_devices( std::vector<Device> & devices, bool deep_scan )
|
||||||
temp_device .length = temp_device .heads * temp_device .sectors * temp_device .cylinders ;
|
temp_device .length = temp_device .heads * temp_device .sectors * temp_device .cylinders ;
|
||||||
temp_device .max_prims = ped_disk_get_max_primary_partition_count( disk ) ;
|
temp_device .max_prims = ped_disk_get_max_primary_partition_count( disk ) ;
|
||||||
|
|
||||||
get_partitions( temp_device .device_partitions, temp_device .path, deep_scan ) ;
|
set_device_partitions( temp_device, deep_scan ) ;
|
||||||
|
|
||||||
devices .push_back( temp_device ) ;
|
devices .push_back( temp_device ) ;
|
||||||
|
|
||||||
|
@ -105,20 +107,20 @@ void GParted_Core::get_devices( std::vector<Device> & devices, bool deep_scan )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GParted_Core::get_partitions( std::vector<Partition> & partitions, const Glib::ustring & device_path, bool deep_scan )
|
void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
|
||||||
{
|
{
|
||||||
Partition partition_temp ;
|
Partition partition_temp ;
|
||||||
Glib::ustring part_path, error ;
|
Glib::ustring part_path, error ;
|
||||||
int EXT_INDEX = -1 ;
|
int EXT_INDEX = -1 ;
|
||||||
|
|
||||||
//clear partitions
|
//clear partitions
|
||||||
partitions .clear( ) ;
|
device .device_partitions .clear( ) ;
|
||||||
|
|
||||||
c_partition = ped_disk_next_partition( disk, NULL ) ;
|
c_partition = ped_disk_next_partition( disk, NULL ) ;
|
||||||
while ( c_partition )
|
while ( c_partition )
|
||||||
{
|
{
|
||||||
partition_temp .Reset( ) ;
|
partition_temp .Reset( ) ;
|
||||||
part_path = device_path + num_to_str( c_partition ->num ) ;
|
part_path = device .path + num_to_str( c_partition ->num ) ;
|
||||||
|
|
||||||
switch ( c_partition ->type )
|
switch ( c_partition ->type )
|
||||||
{
|
{
|
||||||
|
@ -138,7 +140,7 @@ void GParted_Core::get_partitions( std::vector<Partition> & partitions, const Gl
|
||||||
error += _( "There is no filesystem available (unformatted)" ) ;
|
error += _( "There is no filesystem available (unformatted)" ) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
partition_temp.Set( part_path,
|
partition_temp .Set( part_path,
|
||||||
c_partition ->num,
|
c_partition ->num,
|
||||||
c_partition ->type == 0 ? GParted::PRIMARY : GParted::LOGICAL ,
|
c_partition ->type == 0 ? GParted::PRIMARY : GParted::LOGICAL ,
|
||||||
temp, c_partition ->geom .start,
|
temp, c_partition ->geom .start,
|
||||||
|
@ -152,8 +154,10 @@ void GParted_Core::get_partitions( std::vector<Partition> & partitions, const Gl
|
||||||
partition_temp .flags = Get_Flags( c_partition ) ;
|
partition_temp .flags = Get_Flags( c_partition ) ;
|
||||||
partition_temp .error = error .empty( ) ? error_message : error ;
|
partition_temp .error = error .empty( ) ? error_message : error ;
|
||||||
|
|
||||||
break ;
|
if ( partition_temp .busy )
|
||||||
|
device .busy = true ;
|
||||||
|
|
||||||
|
break ;
|
||||||
|
|
||||||
case PED_PARTITION_EXTENDED:
|
case PED_PARTITION_EXTENDED:
|
||||||
partition_temp.Set( part_path ,
|
partition_temp.Set( part_path ,
|
||||||
|
@ -166,24 +170,25 @@ void GParted_Core::get_partitions( std::vector<Partition> & partitions, const Gl
|
||||||
ped_partition_is_busy( c_partition ) );
|
ped_partition_is_busy( c_partition ) );
|
||||||
|
|
||||||
partition_temp .flags = Get_Flags( c_partition ) ;
|
partition_temp .flags = Get_Flags( c_partition ) ;
|
||||||
EXT_INDEX = partitions .size ( ) ;
|
EXT_INDEX = device .device_partitions .size ( ) ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
|
|
||||||
case PED_PARTITION_FREESPACE:
|
case PED_PARTITION_FREESPACE:
|
||||||
case 5: //freespace inside extended (there's no enumvalue for that..)
|
case 5: //freespace inside extended (there's no enumvalue for that..)
|
||||||
partition_temp.Set_Unallocated( c_partition ->geom .start, c_partition ->geom .end, c_partition ->type == 4 ? false : true );
|
partition_temp .Set_Unallocated( c_partition ->geom .start, c_partition ->geom .end, c_partition ->type == 4 ? false : true );
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case PED_PARTITION_METADATA:
|
case PED_PARTITION_METADATA:
|
||||||
if ( partitions .size( ) && partitions .back( ) .type == GParted::UNALLOCATED )
|
if ( device .device_partitions .size( ) && device .device_partitions .back( ) .type == GParted::UNALLOCATED )
|
||||||
partitions .back( ) .sector_end = c_partition ->geom .end ;
|
device .device_partitions .back( ) .sector_end = c_partition ->geom .end ;
|
||||||
|
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case 9: //metadata inside extended (there's no enumvalue for that..)
|
case 9: //metadata inside extended (there's no enumvalue for that..)
|
||||||
if ( partitions[ EXT_INDEX ] .logicals .size( ) && partitions[ EXT_INDEX ] .logicals .back( ) .type == GParted::UNALLOCATED )
|
if ( device .device_partitions[ EXT_INDEX ] .logicals .size( ) &&
|
||||||
partitions[ EXT_INDEX ] .logicals .back( ) .sector_end = c_partition ->geom .end ;
|
device .device_partitions[ EXT_INDEX ] .logicals .back( ) .type == GParted::UNALLOCATED
|
||||||
|
)
|
||||||
|
device .device_partitions[ EXT_INDEX ] .logicals .back( ) .sector_end = c_partition ->geom .end ;
|
||||||
|
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
|
@ -193,9 +198,9 @@ void GParted_Core::get_partitions( std::vector<Partition> & partitions, const Gl
|
||||||
if ( partition_temp .Get_Length_MB( ) >= 1 ) // check for unallocated < 1MB, and metadatasituations (see PED_PARTITION_METADATA and 9 )
|
if ( partition_temp .Get_Length_MB( ) >= 1 ) // check for unallocated < 1MB, and metadatasituations (see PED_PARTITION_METADATA and 9 )
|
||||||
{
|
{
|
||||||
if ( ! partition_temp .inside_extended )
|
if ( ! partition_temp .inside_extended )
|
||||||
partitions.push_back( partition_temp );
|
device .device_partitions .push_back( partition_temp );
|
||||||
else
|
else
|
||||||
partitions[ EXT_INDEX ] .logicals .push_back( partition_temp ) ;
|
device .device_partitions[ EXT_INDEX ] .logicals .push_back( partition_temp ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//reset stuff..
|
//reset stuff..
|
||||||
|
@ -328,7 +333,7 @@ bool GParted_Core::Resize(const Glib::ustring & device_path, const Partition & p
|
||||||
|
|
||||||
bool GParted_Core::Copy( const Glib::ustring & dest_device_path, const Glib::ustring & src_part_path, Partition & partition_dest )
|
bool GParted_Core::Copy( const Glib::ustring & dest_device_path, const Glib::ustring & src_part_path, Partition & partition_dest )
|
||||||
{
|
{
|
||||||
if ( Create_Empty_Partition( dest_device_path, partition_dest ) > 0 )
|
if ( Create_Empty_Partition( dest_device_path, partition_dest, true ) > 0 )
|
||||||
{
|
{
|
||||||
set_proper_filesystem( partition_dest .filesystem ) ;
|
set_proper_filesystem( partition_dest .filesystem ) ;
|
||||||
|
|
||||||
|
@ -438,7 +443,7 @@ Sector GParted_Core::Get_Used_Sectors( PedPartition *c_partition, const Glib::us
|
||||||
return -1 ; //all methods were unsuccesfull
|
return -1 ; //all methods were unsuccesfull
|
||||||
}
|
}
|
||||||
|
|
||||||
int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Partition & new_partition )
|
int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Partition & new_partition, bool copy )
|
||||||
{
|
{
|
||||||
new_partition .partition_number = 0 ;
|
new_partition .partition_number = 0 ;
|
||||||
|
|
||||||
|
@ -461,17 +466,23 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par
|
||||||
if ( c_part )
|
if ( c_part )
|
||||||
{
|
{
|
||||||
constraint = ped_constraint_any ( device );
|
constraint = ped_constraint_any ( device );
|
||||||
|
|
||||||
if ( constraint )
|
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 ( disk, c_part, constraint ) && Commit( disk ) )
|
||||||
{
|
{
|
||||||
sleep( 1 ) ;//the OS needs some time to create the devicenode in /dev
|
sleep( 1 ) ;//the OS needs some time to create the devicenode in /dev
|
||||||
|
|
||||||
new_partition .partition = ped_partition_get_path( c_part ) ;
|
new_partition .partition = ped_partition_get_path( c_part ) ;
|
||||||
new_partition .partition_number = c_part ->num ;
|
new_partition .partition_number = c_part ->num ;
|
||||||
}
|
}
|
||||||
|
|
||||||
ped_constraint_destroy ( constraint );
|
ped_constraint_destroy ( constraint );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close_device_and_disk( device, disk ) ;
|
close_device_and_disk( device, disk ) ;
|
||||||
|
|
|
@ -1141,7 +1141,7 @@ void Win_GParted::activate_apply()
|
||||||
//make list of involved devices which have at least one busy partition..
|
//make list of involved devices which have at least one busy partition..
|
||||||
std::vector <Glib::ustring> devicenames ;
|
std::vector <Glib::ustring> devicenames ;
|
||||||
for ( unsigned int t = 0; t < devices .size( ); t++ )
|
for ( unsigned int t = 0; t < devices .size( ); t++ )
|
||||||
if ( devices[ t ] .Get_any_busy( ) )
|
if ( devices[ t ] .busy )
|
||||||
for (unsigned int i = 0; i < operations .size( ); i++ )
|
for (unsigned int i = 0; i < operations .size( ); i++ )
|
||||||
if ( operations[ i ] .device_path == devices[ t ] .path )
|
if ( operations[ i ] .device_path == devices[ t ] .path )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue