2004-11-17 06:00:25 -07:00
|
|
|
/* Copyright (C) 2004 Bart
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GPARTED_CORE
|
|
|
|
#define GPARTED_CORE
|
|
|
|
|
2006-04-02 08:35:21 -06:00
|
|
|
#include "../include/FileSystem.h"
|
2004-11-17 06:00:25 -07:00
|
|
|
#include "../include/Operation.h"
|
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
#include <parted/parted.h>
|
2004-11-17 06:00:25 -07:00
|
|
|
#include <vector>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
class GParted_Core
|
|
|
|
{
|
|
|
|
public:
|
2006-02-25 09:30:43 -07:00
|
|
|
GParted_Core() ;
|
2006-03-28 12:01:20 -07:00
|
|
|
~GParted_Core() ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
2006-02-25 09:30:43 -07:00
|
|
|
void find_supported_filesystems() ;
|
2006-02-02 06:50:37 -07:00
|
|
|
void set_user_devices( const std::vector<Glib::ustring> & user_devices ) ;
|
2006-06-18 02:50:17 -06:00
|
|
|
void set_devices( std::vector<Device> & devices ) ;
|
2004-11-19 04:55:38 -07:00
|
|
|
|
2006-07-20 13:14:44 -06:00
|
|
|
bool snap_to_cylinder( const Device & device, Partition & partition, Glib::ustring & error ) ;
|
2006-03-24 12:08:41 -07:00
|
|
|
bool apply_operation_to_disk( Operation * operation );
|
2004-11-17 06:00:25 -07:00
|
|
|
|
2006-06-18 02:50:17 -06:00
|
|
|
bool set_disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
|
|
|
bool toggle_flag( const Partition & partition, const Glib::ustring & flag, bool state ) ;
|
2006-05-31 14:03:49 -06:00
|
|
|
|
|
|
|
const std::vector<FS> & get_filesystems() const ;
|
|
|
|
const FS & get_fs( GParted::FILESYSTEM filesystem ) const ;
|
|
|
|
std::vector<Glib::ustring> get_disklabeltypes() ;
|
|
|
|
std::vector<Glib::ustring> get_all_mountpoints() ;
|
|
|
|
std::map<Glib::ustring, bool> get_available_flags( const Partition & partition ) ;
|
|
|
|
|
|
|
|
private:
|
2006-06-17 14:52:25 -06:00
|
|
|
//detectionstuff..
|
2006-06-18 02:50:17 -06:00
|
|
|
void init_maps() ;
|
2006-03-07 04:55:27 -07:00
|
|
|
void read_mountpoints_from_file( const Glib::ustring & filename,
|
|
|
|
std::map< Glib::ustring, std::vector<Glib::ustring> > & map ) ;
|
2006-06-18 02:50:17 -06:00
|
|
|
bool check_device_path( const Glib::ustring & device_path ) ;
|
|
|
|
std::vector<Glib::ustring> get_alternate_paths( const Glib::ustring & path ) ;
|
|
|
|
void set_device_partitions( Device & device ) ;
|
|
|
|
GParted::FILESYSTEM get_filesystem() ;
|
2006-02-17 16:20:28 -07:00
|
|
|
void insert_unallocated( const Glib::ustring & device_path,
|
|
|
|
std::vector<Partition> & partitions,
|
|
|
|
Sector start,
|
|
|
|
Sector end,
|
|
|
|
bool inside_extended ) ;
|
2006-06-18 02:50:17 -06:00
|
|
|
void set_mountpoints( std::vector<Partition> & partitions ) ;
|
|
|
|
void set_used_sectors( std::vector<Partition> & partitions ) ;
|
|
|
|
void LP_set_used_sectors( Partition & partition );
|
2006-02-17 16:20:28 -07:00
|
|
|
void set_flags( Partition & partition ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
|
|
|
//operationstuff...
|
|
|
|
bool create( const Device & device,
|
|
|
|
Partition & new_partition,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 02:56:24 -06:00
|
|
|
bool create_partition( Partition & new_partition,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details,
|
2006-06-17 02:56:24 -06:00
|
|
|
Sector min_size = 0 ) ;
|
2006-07-29 02:27:28 -06:00
|
|
|
bool create_filesystem( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
2006-07-29 02:27:28 -06:00
|
|
|
bool format( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
2006-07-29 02:27:28 -06:00
|
|
|
bool Delete( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
|
|
|
bool resize_move( const Device & device,
|
|
|
|
const Partition & partition_old,
|
|
|
|
Partition & partition_new,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
bool move( const Device & device,
|
|
|
|
const Partition & partition_old,
|
2006-07-23 10:51:38 -06:00
|
|
|
const Partition & partition_new,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-06-18 13:27:52 -06:00
|
|
|
bool move_filesystem( const Partition & partition_old,
|
2006-07-23 03:58:45 -06:00
|
|
|
const Partition & partition_new,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-07-23 03:58:45 -06:00
|
|
|
bool move_filesystem_using_gparted( const Partition & partition_old,
|
|
|
|
const Partition & partition_new,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-07-23 03:58:45 -06:00
|
|
|
bool resize_move_filesystem_using_libparted( const Partition & partition_old,
|
|
|
|
const Partition & partition_new,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-07-23 12:43:15 -06:00
|
|
|
bool resize( const Partition & partition_old,
|
2006-07-23 10:51:38 -06:00
|
|
|
const Partition & partition_new,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_detail ) ;
|
2006-06-18 13:38:29 -06:00
|
|
|
bool resize_move_partition( const Partition & partition_old,
|
2006-07-23 03:58:45 -06:00
|
|
|
const Partition & partition_new,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
bool resize_filesystem( const Partition & partition_old,
|
|
|
|
const Partition & partition_new,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details,
|
2006-06-17 14:52:25 -06:00
|
|
|
bool fill_partition = false ) ;
|
|
|
|
bool maximize_filesystem( const Partition & partition,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
|
|
|
bool copy( const Partition & partition_src,
|
|
|
|
Partition & partition_dest,
|
|
|
|
Sector min_size,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-05-23 15:17:34 -06:00
|
|
|
bool copy_filesystem( const Partition & partition_src,
|
|
|
|
const Partition & partition_dest,
|
2006-08-08 13:04:29 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
2006-08-13 07:31:57 -06:00
|
|
|
bool check_repair_filesystem( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
bool set_partition_type( const Partition & partition,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
2006-08-15 12:33:56 -06:00
|
|
|
void set_progress_info( Sector total, Sector done, std::time_t time_start, OperationDetail & operationdetail ) ;
|
|
|
|
|
2006-08-08 13:04:29 -06:00
|
|
|
enum CopyType
|
|
|
|
{
|
|
|
|
START_TO_END = 0,
|
|
|
|
END_TO_START = 1
|
|
|
|
} ;
|
|
|
|
bool find_optimal_blocksize( const Partition & partition_old,
|
|
|
|
const Partition & partition_new,
|
|
|
|
CopyType copytype,
|
|
|
|
Sector & optimal_blocksize,
|
|
|
|
Sector & offset,
|
|
|
|
std::vector<OperationDetail> & operation_details ) ;
|
|
|
|
|
|
|
|
bool copy_blocks( const Glib::ustring & src_device,
|
|
|
|
const Glib::ustring & dst_device,
|
|
|
|
Sector src_start,
|
|
|
|
Sector dst_start,
|
|
|
|
Sector blocksize,
|
|
|
|
Sector sectors,
|
|
|
|
std::vector<OperationDetail> & operation_details,
|
|
|
|
CopyType copytype,
|
|
|
|
bool show_progress = true ) ;
|
|
|
|
|
2006-06-18 13:27:52 -06:00
|
|
|
bool copy_block( PedDevice * lp_device_src,
|
|
|
|
PedDevice * lp_device_dst,
|
|
|
|
Sector offset_src,
|
|
|
|
Sector offset_dst,
|
|
|
|
Sector blocksize,
|
|
|
|
Glib::ustring & error_message ) ;
|
2006-07-23 03:58:45 -06:00
|
|
|
bool calculate_exact_geom( const Partition & partition_old,
|
|
|
|
Partition & partition_new,
|
2006-07-29 02:27:28 -06:00
|
|
|
std::vector<OperationDetail> & operation_details,
|
2006-07-23 10:51:38 -06:00
|
|
|
Sector min_size = -1 ) ;
|
2006-08-13 07:31:57 -06:00
|
|
|
bool set_proper_filesystem( const FILESYSTEM & filesystem ) ;
|
2006-04-03 12:48:53 -06:00
|
|
|
bool wait_for_node( const Glib::ustring & node ) ;
|
2005-12-07 15:44:40 -07:00
|
|
|
bool erase_filesystem_signatures( const Partition & partition ) ;
|
2006-06-17 14:52:25 -06:00
|
|
|
|
|
|
|
//general..
|
2005-11-26 17:57:11 -07:00
|
|
|
bool open_device( const Glib::ustring & device_path ) ;
|
|
|
|
bool open_device_and_disk( const Glib::ustring & device_path, bool strict = true ) ;
|
2006-05-31 14:03:49 -06:00
|
|
|
void close_disk() ;
|
2006-02-15 15:32:54 -07:00
|
|
|
void close_device_and_disk() ;
|
|
|
|
bool commit() ;
|
2005-11-26 17:57:11 -07:00
|
|
|
|
2006-02-25 09:30:43 -07:00
|
|
|
static PedExceptionOption ped_exception_handler( PedException * e ) ;
|
|
|
|
|
2004-11-17 06:00:25 -07:00
|
|
|
std::vector<FS> FILESYSTEMS ;
|
|
|
|
FileSystem * p_filesystem ;
|
2006-02-15 15:32:54 -07:00
|
|
|
std::vector<PedPartitionFlag> flags;
|
2004-11-17 06:00:25 -07:00
|
|
|
Glib::ustring temp ;
|
2004-12-13 04:17:40 -07:00
|
|
|
Partition partition_temp ;
|
2004-12-14 15:49:44 -07:00
|
|
|
FS fs ;
|
2006-02-02 06:50:37 -07:00
|
|
|
std::vector<Glib::ustring> device_paths ;
|
|
|
|
bool probe_devices ;
|
2005-11-26 17:57:11 -07:00
|
|
|
|
2006-02-15 15:32:54 -07:00
|
|
|
std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ;
|
2006-03-07 04:55:27 -07:00
|
|
|
std::map< Glib::ustring, std::vector<Glib::ustring> > fstab_info ;
|
2006-03-14 14:37:47 -07:00
|
|
|
std::map< Glib::ustring, Glib::ustring > alternate_paths ;
|
2006-02-15 15:32:54 -07:00
|
|
|
std::map< Glib::ustring, Glib::ustring >::iterator iter ;
|
|
|
|
std::map< Glib::ustring, std::vector<Glib::ustring> >::iterator iter_mp ;
|
2006-08-08 13:04:29 -06:00
|
|
|
|
2005-11-26 17:57:11 -07:00
|
|
|
PedDevice *lp_device ;
|
|
|
|
PedDisk *lp_disk ;
|
|
|
|
PedPartition *lp_partition ;
|
2004-11-17 06:00:25 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} //GParted
|
|
|
|
|
|
|
|
|
|
|
|
#endif //GPARTED_CORE
|