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