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
|
|
|
|
|
|
|
|
#include "../include/Operation.h"
|
|
|
|
#include "../include/ext2.h"
|
|
|
|
#include "../include/ext3.h"
|
|
|
|
#include "../include/fat16.h"
|
|
|
|
#include "../include/fat32.h"
|
|
|
|
#include "../include/linux_swap.h"
|
|
|
|
#include "../include/reiserfs.h"
|
2004-11-23 09:20:59 -07:00
|
|
|
#include "../include/ntfs.h"
|
2004-12-13 14:24:12 -07:00
|
|
|
#include "../include/xfs.h"
|
2004-12-14 15:49:44 -07:00
|
|
|
#include "../include/jfs.h"
|
|
|
|
#include "../include/hfs.h"
|
2005-09-13 08:56:00 -06:00
|
|
|
#include "../include/hfsplus.h"
|
2004-12-28 17:09:58 -07:00
|
|
|
#include "../include/reiser4.h"
|
2004-11-17 06:00:25 -07:00
|
|
|
|
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() ;
|
|
|
|
void find_supported_filesystems() ;
|
2006-02-02 06:50:37 -07:00
|
|
|
void set_user_devices( const std::vector<Glib::ustring> & user_devices ) ;
|
2004-12-17 12:45:04 -07:00
|
|
|
void get_devices( std::vector<Device> & devices ) ;
|
2004-11-19 04:55:38 -07:00
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
bool apply_operation_to_disk( Operation & operation );
|
2004-11-17 06:00:25 -07:00
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
bool create( const Device & device,
|
|
|
|
Partition & new_partition,
|
|
|
|
std::vector<OperationDetails> & operation_details ) ;
|
|
|
|
bool format( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
|
|
|
|
bool Delete( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
|
|
|
|
bool resize( const Device & device,
|
|
|
|
const Partition & partition_old,
|
|
|
|
const Partition & partition_new,
|
|
|
|
std::vector<OperationDetails> & operation_detail ) ;
|
|
|
|
bool copy( const Glib::ustring & src_part_path,
|
|
|
|
Partition & partition_dest,
|
|
|
|
std::vector<OperationDetails> & operation_details ) ;
|
2004-11-17 06:00:25 -07:00
|
|
|
|
2004-11-27 16:31:19 -07:00
|
|
|
bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
|
2006-02-25 09:30:43 -07:00
|
|
|
const std::vector<FS> & get_filesystems() const ;
|
2005-12-07 04:21:27 -07:00
|
|
|
const FS & get_fs( GParted::FILESYSTEM filesystem ) const ;
|
2006-02-25 09:30:43 -07:00
|
|
|
std::vector<Glib::ustring> get_disklabeltypes() ;
|
2006-02-20 07:41:05 -07:00
|
|
|
std::vector<Glib::ustring> get_all_mountpoints() ;
|
2004-11-17 06:00:25 -07:00
|
|
|
|
|
|
|
private:
|
2006-01-05 13:01:34 -07:00
|
|
|
GParted::FILESYSTEM get_filesystem() ;
|
2006-02-02 06:50:37 -07:00
|
|
|
bool check_device_path( const Glib::ustring & device_path ) ;
|
2004-12-17 12:45:04 -07:00
|
|
|
void set_device_partitions( Device & device ) ;
|
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-01-05 13:01:34 -07:00
|
|
|
void init_maps() ;
|
|
|
|
void set_mountpoints( std::vector<Partition> & partitions ) ;
|
|
|
|
void set_short_paths( std::vector<Partition> & partitions ) ;
|
2005-12-10 17:05:28 -07:00
|
|
|
void set_used_sectors( std::vector<Partition> & partitions ) ;
|
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 ) ;
|
2005-12-11 11:46:43 -07:00
|
|
|
Glib::ustring get_short_path( const Glib::ustring & real_path ) ;
|
2005-11-26 17:57:11 -07:00
|
|
|
void LP_Set_Used_Sectors( Partition & partition );
|
2006-02-17 16:20:28 -07:00
|
|
|
void set_flags( Partition & partition ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
int create_empty_partition( Partition & new_partition,
|
|
|
|
std::vector<OperationDetails> & operation_details,
|
|
|
|
bool copy = false ) ;
|
|
|
|
bool resize_container_partition( const Partition & partition_old,
|
|
|
|
const Partition & partition_new,
|
|
|
|
bool fixed_start,
|
|
|
|
std::vector<OperationDetails> & operation_details ) ;
|
|
|
|
bool resize_normal_using_libparted( const Partition & partition_old,
|
|
|
|
const Partition & partition_new,
|
|
|
|
std::vector<OperationDetails> & operation_detail ) ;
|
2004-11-17 06:00:25 -07:00
|
|
|
|
2005-12-07 04:21:27 -07:00
|
|
|
void set_proper_filesystem( const FILESYSTEM & filesystem ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
bool set_partition_type( const Partition & partition,
|
|
|
|
std::vector<OperationDetails> & operation_details ) ;
|
2005-11-29 07:50:20 -07:00
|
|
|
bool wait_for_node( const Glib::ustring & node ) ;
|
2005-12-07 15:44:40 -07:00
|
|
|
bool erase_filesystem_signatures( const Partition & partition ) ;
|
2004-12-27 05:08:01 -07:00
|
|
|
|
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-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-02-15 15:32:54 -07:00
|
|
|
std::map< Glib::ustring, Glib::ustring > short_paths ;
|
|
|
|
std::map< Glib::ustring, Glib::ustring >::iterator iter ;
|
|
|
|
std::map< Glib::ustring, std::vector<Glib::ustring> >::iterator iter_mp ;
|
2005-12-08 10:03:29 -07: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
|