00001 #ifndef PARTITION_H
00002 #define PARTITION_H
00003
00004 #include "y2storage/StorageInterface.h"
00005 #include "y2storage/Volume.h"
00006 #include "y2storage/Region.h"
00007
00008 class Disk;
00009
00010 class Partition : public Volume
00011 {
00012 public:
00013
00014 typedef enum { ID_DOS16=0x6, ID_DOS=0x0c, ID_NTFS=0x07,
00015 ID_EXTENDED=0x0f,
00016 ID_LINUX=0x83, ID_SWAP=0x82, ID_LVM=0x8e, ID_RAID=0xfd,
00017 ID_APPLE_OTHER=0x101, ID_APPLE_HFS=0x102,
00018 ID_GPT_BOOT=0x103, ID_GPT_SERVICE=0x104 } IdNum;
00019
00020 Partition( const Disk& d, unsigned Pnr, unsigned long long SizeK,
00021 unsigned long Start, unsigned long CSize,
00022 storage::PartitionType Type,
00023 unsigned id=ID_LINUX, bool Boot=false );
00024 Partition( const Disk& d, const string& Data );
00025 Partition( const Disk& d, const Partition& d );
00026 virtual ~Partition();
00027
00028 unsigned long cylStart() const { return reg.start(); }
00029 unsigned long cylSize() const { return reg.len(); }
00030 unsigned long cylEnd() const { return reg.start()+reg.len()-1; }
00031 const Region& region() const { return reg; }
00032 bool intersectArea( const Region& r, unsigned fuzz=0 ) const;
00033 bool contains( const Region& r, unsigned fuzz=0 ) const;
00034 unsigned OrigNr() const { return( orig_num ); }
00035 bool boot() const { return bootflag; }
00036 unsigned id() const { return idt; }
00037 storage::PartitionType type() const { return typ; }
00038 std::ostream& logData( std::ostream& file ) const;
00039 void changeRegion( unsigned long Start, unsigned long CSize,
00040 unsigned long long SizeK );
00041 void changeNumber( unsigned new_num );
00042 void changeId( unsigned id );
00043 void changeIdDone();
00044 void unChangeId();
00045 string removeText( bool doing=true ) const;
00046 string createText( bool doing=true ) const;
00047 string formatText(bool doing=true) const;
00048 string resizeText(bool doing=true) const;
00049 void getCommitActions( std::list<storage::commitAction*>& l ) const;
00050 string setTypeText( bool doing=true ) const;
00051 int setFormat( bool format=true, storage::FsType fs=storage::REISERFS );
00052 int changeMount( const string& val );
00053 const Disk* const disk() const;
00054 bool isWindows() const;
00055 friend std::ostream& operator<< (std::ostream& s, const Partition &p );
00056 static bool notDeleted( const Partition&d ) { return( !d.deleted() ); }
00057 static bool toChangeId( const Partition&d ) { return( !d.deleted() && d.idt!=d.orig_id ); }
00058 virtual void print( std::ostream& s ) const { s << *this; }
00059 void setResizedSize( unsigned long long SizeK );
00060 void forgetResize();
00061 bool canUseDevice() const;
00062
00063 void getInfo( storage::PartitionInfo& info ) const;
00064 bool equalContent( const Partition& rhs ) const;
00065 void logDifference( const Partition& d ) const;
00066
00067 protected:
00068 Partition& operator=( const Partition& );
00069
00070 Region reg;
00071 bool bootflag;
00072 storage::PartitionType typ;
00073 unsigned idt;
00074 unsigned orig_id;
00075 string parted_start;
00076 unsigned orig_num;
00077
00078 static string pt_names[storage::PTYPE_ANY+1];
00079 mutable storage::PartitionInfo info;
00080 };
00081
00082 #endif