00001 #ifndef MD_H
00002 #define MD_H
00003
00004 #include "y2storage/StorageInterface.h"
00005 #include "y2storage/Volume.h"
00006
00007 namespace storage
00008 {
00009
00010 class MdCo;
00011
00012 class Md : public Volume
00013 {
00014 public:
00015 Md( const MdCo& d, unsigned Pnr, storage::MdType Type,
00016 const std::list<string>& devs );
00017 Md( const MdCo& d, const string& line, const string& line2 );
00018 Md( const MdCo& d, const Md& m );
00019
00020 virtual ~Md();
00021 storage::MdType personality() const { return md_type; }
00022 void setPersonality( storage::MdType val );
00023 storage::MdParity parity() const { return md_parity; }
00024 void setParity( storage::MdParity val ) { md_parity=val; }
00025 unsigned long chunkSize() const { return chunk; }
00026 void setChunkSize( unsigned long val ) { chunk=val; }
00027 void setMdUuid( const string&val ) { md_uuid=val; }
00028 bool destroySb() const { return( destrSb ); }
00029 void setDestroySb( bool val=true ) { destrSb=val; }
00030 const string& getMdUuid() const { return(md_uuid); }
00031 const string& pName() const { return md_names[md_type]; }
00032 const string& ptName() const { return par_names[md_parity]; }
00033 void getDevs( std::list<string>& devices, bool all=true, bool spare=false ) const;
00034 void addSpareDevice( const string& dev );
00035 int checkDevices();
00036 int addDevice( const string& dev, bool spare=false );
00037 int removeDevice( const string& dev );
00038 void raidtabLines( std::list<string>& ) const ;
00039 string mdadmLine() const;
00040 string createCmd() const;
00041 static bool matchRegex( const string& dev );
00042 static unsigned mdMajor();
00043
00044 static const string& pName( storage::MdType t ) { return md_names[t]; }
00045 static bool mdStringNum( const string& name, unsigned& num );
00046 friend std::ostream& operator<< (std::ostream& s, const Md& m );
00047 virtual void print( std::ostream& s ) const { s << *this; }
00048 string removeText( bool doing ) const;
00049 string createText( bool doing ) const;
00050 string formatText( bool doing ) const;
00051 static bool notDeleted( const Md& l ) { return( !l.deleted() ); }
00052 void changeDeviceName( const string& old, const string& nw );
00053
00054 void getInfo( storage::MdInfo& info ) const;
00055 bool equalContent( const Md& rhs ) const;
00056 void logDifference( const Md& d ) const;
00057
00058 protected:
00059 void init();
00060 void computeSize();
00061 Md& operator=( const Md& );
00062
00063 static void getMdMajor();
00064 static storage::MdType toMdType( const string& val );
00065 static storage::MdParity toMdParity( const string& val );
00066
00067 storage::MdType md_type;
00068 storage::MdParity md_parity;
00069 unsigned long chunk;
00070 string md_uuid;
00071 string sb_ver;
00072 bool destrSb;
00073 std::list<string> devs;
00074 std::list<string> spare;
00075 static string md_names[storage::MULTIPATH+1];
00076 static string par_names[storage::RIGHT_SYMMETRIC+1];
00077 static unsigned md_major;
00078 mutable storage::MdInfo info;
00079 };
00080
00081 }
00082
00083 #endif