00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef MD_H
00024 #define MD_H
00025
00026 #include "y2storage/StorageInterface.h"
00027 #include "y2storage/Volume.h"
00028
00029 namespace storage
00030 {
00031 class EtcRaidtab;
00032 class MdCo;
00033
00034 class Md : public Volume
00035 {
00036 public:
00037 Md( const MdCo& d, unsigned Pnr, storage::MdType Type,
00038 const std::list<string>& devs );
00039 Md( const MdCo& d, const string& line, const string& line2 );
00040 Md( const MdCo& d, const Md& m );
00041
00042 virtual ~Md();
00043 storage::MdType personality() const { return md_type; }
00044 void setPersonality( storage::MdType val );
00045 storage::MdParity parity() const { return md_parity; }
00046 void setParity( storage::MdParity val ) { md_parity=val; }
00047 unsigned long chunkSize() const { return chunk; }
00048 void setChunkSize( unsigned long val ) { chunk=val; }
00049 void setMdUuid( const string&val ) { md_uuid=val; }
00050 bool destroySb() const { return( destrSb ); }
00051 void setDestroySb( bool val=true ) { destrSb=val; }
00052 const string& getMdUuid() const { return(md_uuid); }
00053 const string& pName() const { return md_names[md_type]; }
00054 const string& ptName() const { return par_names[md_parity]; }
00055 void getDevs( std::list<string>& devices, bool all=true, bool spare=false ) const;
00056 void addSpareDevice( const string& dev );
00057 int checkDevices();
00058 int addDevice( const string& dev, bool spare=false );
00059 int removeDevice( const string& dev );
00060 void raidtabLines( std::list<string>& ) const ;
00061 string mdadmLine() const;
00062 string createCmd() const;
00063 static bool matchRegex( const string& dev );
00064 static unsigned mdMajor();
00065
00066 static const string& pName( storage::MdType t ) { return md_names[t]; }
00067 static bool mdStringNum( const string& name, unsigned& num );
00068 static string mdDevice( unsigned num );
00069
00070 friend std::ostream& operator<< (std::ostream& s, const Md& m );
00071 virtual void print( std::ostream& s ) const { s << *this; }
00072 string removeText( bool doing ) const;
00073 string createText( bool doing ) const;
00074 string formatText( bool doing ) const;
00075 static bool notDeleted( const Md& l ) { return( !l.deleted() ); }
00076 void changeDeviceName( const string& old, const string& nw );
00077
00078 void getInfo( storage::MdInfo& info ) const;
00079 bool equalContent( const Md& rhs ) const;
00080 void logDifference( const Md& d ) const;
00081 void getState(MdStateInfo& info) const;
00082
00083 int updateEntry(EtcRaidtab* tab);
00084
00085 protected:
00086 void init();
00087 void computeSize();
00088 Md& operator=( const Md& );
00089
00090 static void getMdMajor();
00091 static storage::MdType toMdType( const string& val );
00092 static storage::MdParity toMdParity( const string& val );
00093
00094 void getParent();
00095 void setMetadata();
00096
00097 storage::MdType md_type;
00098 storage::MdParity md_parity;
00099 unsigned long chunk;
00100 string md_uuid;
00101 string sb_ver;
00102 bool destrSb;
00103 std::list<string> devs;
00104 std::list<string> spare;
00105 string md_name;
00106
00107
00108 bool has_container;
00109 string md_metadata;
00110 string parent_container;
00111 string parent_uuid;
00112 string parent_md_name;
00113 string parent_metadata;
00114 int md_member;
00115 static string md_names[storage::MULTIPATH+1];
00116 static string par_names[storage::RIGHT_SYMMETRIC+1];
00117 static unsigned md_major;
00118 mutable storage::MdInfo info;
00119 };
00120
00121 }
00122
00123 #endif