00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PARTITION_H
00024 #define PARTITION_H
00025
00026 #include "y2storage/StorageInterface.h"
00027 #include "y2storage/Volume.h"
00028 #include "y2storage/Region.h"
00029
00030 namespace storage
00031 {
00032
00033 class Disk;
00034
00035 class Partition : public Volume
00036 {
00037 public:
00038
00039 typedef enum { ID_DOS16=0x6, ID_DOS=0x0c, ID_NTFS=0x07,
00040 ID_EXTENDED=0x0f,
00041 ID_LINUX=0x83, ID_SWAP=0x82, ID_LVM=0x8e, ID_RAID=0xfd,
00042 ID_APPLE_OTHER=0x101, ID_APPLE_HFS=0x102,
00043 ID_GPT_BOOT=0x103, ID_GPT_SERVICE=0x104,
00044 ID_GPT_MSFTRES=0x105, ID_APPLE_UFS=0x106 } IdNum;
00045
00046 Partition( const Disk& d, unsigned Pnr, unsigned long long SizeK,
00047 unsigned long Start, unsigned long CSize,
00048 storage::PartitionType Type,
00049 unsigned id=ID_LINUX, bool Boot=false );
00050 Partition( const Disk& d, const string& Data );
00051 Partition( const Disk& d, const Partition& p );
00052 virtual ~Partition();
00053
00054 unsigned long cylStart() const { return reg.start(); }
00055 unsigned long cylSize() const { return reg.len(); }
00056 unsigned long cylEnd() const { return reg.end(); }
00057 const Region& region() const { return reg; }
00058 const std::list<string> udevId() const;
00059 const string& udevPath() const;
00060 string sysfsPath() const;
00061 bool intersectArea( const Region& r, unsigned fuzz=0 ) const;
00062 bool contains( const Region& r, unsigned fuzz=0 ) const;
00063 unsigned OrigNr() const { return( orig_num ); }
00064 bool boot() const { return bootflag; }
00065 unsigned id() const { return idt; }
00066 storage::PartitionType type() const { return typ; }
00067 std::ostream& logData( std::ostream& file ) const;
00068 void changeRegion( unsigned long Start, unsigned long CSize,
00069 unsigned long long SizeK );
00070 void changeNumber( unsigned new_num );
00071 int changeId(unsigned id);
00072 void changeIdDone();
00073 void unChangeId();
00074 string removeText( bool doing=true ) const;
00075 string createText( bool doing=true ) const;
00076 string formatText(bool doing=true) const;
00077 string resizeText(bool doing=true) const;
00078 void getCommitActions( std::list<storage::commitAction*>& l ) const;
00079 string setTypeText( bool doing=true ) const;
00080 int setFormat( bool format=true, storage::FsType fs=storage::REISERFS );
00081 int changeMount( const string& val );
00082 const Disk* disk() const;
00083 bool isWindows() const;
00084 friend std::ostream& operator<< (std::ostream& s, const Partition &p );
00085 static bool notDeleted( const Partition&d ) { return( !d.deleted() ); }
00086 static bool toChangeId( const Partition&d ) { return( !d.deleted() && d.idt!=d.orig_id ); }
00087 virtual void print( std::ostream& s ) const { s << *this; }
00088 void setResizedSize( unsigned long long SizeK );
00089 void forgetResize();
00090 bool canUseDevice() const;
00091
00092 void getInfo( storage::PartitionInfo& info ) const;
00093 void getInfo( storage::PartitionAddInfo& info ) const;
00094 bool equalContent( const Partition& rhs ) const;
00095 void logDifference( const Partition& d ) const;
00096 void addUdevData();
00097
00098 int zeroIfNeeded() const;
00099
00100 bool operator== ( const Partition& rhs ) const;
00101 bool operator!= ( const Partition& rhs ) const
00102 { return( !(*this==rhs) ); }
00103 bool operator< ( const Partition& rhs ) const;
00104 bool operator<= ( const Partition& rhs ) const
00105 { return( *this<rhs || *this==rhs ); }
00106 bool operator>= ( const Partition& rhs ) const
00107 { return( !(*this<rhs) ); }
00108 bool operator> ( const Partition& rhs ) const
00109 { return( !(*this<=rhs) ); }
00110
00111 protected:
00112 Partition& operator=( const Partition& );
00113
00114 Region reg;
00115 bool bootflag;
00116 storage::PartitionType typ;
00117 unsigned idt;
00118 unsigned orig_id;
00119 string parted_start;
00120 unsigned orig_num;
00121
00122 void addAltUdevId( unsigned num );
00123 void addAltUdevPath( unsigned num );
00124 static string pt_names[storage::PTYPE_ANY+1];
00125 mutable storage::PartitionInfo info;
00126 };
00127
00128 }
00129
00130 #endif