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_CO_H
00024 #define MD_CO_H
00025
00026 #include "y2storage/Container.h"
00027 #include "y2storage/Md.h"
00028
00029 namespace storage
00030 {
00031
00032 class EtcRaidtab;
00033
00034 class MdCo : public Container
00035 {
00036 friend class Storage;
00037
00038 public:
00039 MdCo( Storage * const s, bool detect );
00040 MdCo( const MdCo& rhs );
00041
00042 virtual ~MdCo();
00043 static storage::CType staticType() { return storage::MD; }
00044 friend std::ostream& operator<< (std::ostream&, const MdCo& );
00045
00046 int createMd( unsigned num, storage::MdType type,
00047 const std::list<string>& devs );
00048 int removeMd( unsigned num, bool destroySb=true );
00049 int extendMd( unsigned num, const string& dev );
00050 int shrinkMd( unsigned num, const string& dev );
00051 int changeMdType( unsigned num, storage::MdType ptype );
00052 int changeMdChunk( unsigned num, unsigned long chunk );
00053 int changeMdParity( unsigned num, storage::MdParity ptype );
00054 int checkMd( unsigned num );
00055 int getMdState(unsigned num, MdStateInfo& info);
00056 bool equalContent( const Container& rhs ) const;
00057 void logDifference( const Container& d ) const;
00058
00059 void syncRaidtab();
00060 void changeDeviceName( const string& old, const string& nw );
00061
00062 static void activate( bool val, const string& tmpDir );
00063 int removeVolume( Volume* v );
00064
00065
00066 int usedNumbers(list<int>& nums);
00067
00068 protected:
00069
00070
00071 typedef CastIterator<VIter, Md *> MdInter;
00072 typedef CastIterator<CVIter, const Md *> MdCInter;
00073 template< class Pred >
00074 struct MdPI { typedef ContainerIter<Pred, MdInter> type; };
00075 template< class Pred >
00076 struct MdCPI { typedef ContainerIter<Pred, MdCInter> type; };
00077 typedef CheckFnc<const Md> CheckFncMd;
00078 typedef CheckerIterator< CheckFncMd, MdPI<CheckFncMd>::type,
00079 MdInter, Md > MdPIterator;
00080 typedef CheckerIterator< CheckFncMd, MdCPI<CheckFncMd>::type,
00081 MdCInter, const Md > MdCPIterator;
00082 typedef DerefIterator<MdPIterator,Md> MdIter;
00083 typedef DerefIterator<MdCPIterator,const Md> ConstMdIter;
00084 typedef IterPair<MdIter> MdPair;
00085 typedef IterPair<ConstMdIter> ConstMdPair;
00086
00087 MdPair mdPair( bool (* Check)( const Md& )=NULL)
00088 {
00089 return( MdPair( mdBegin( Check ), mdEnd( Check ) ));
00090 }
00091 MdIter mdBegin( bool (* Check)( const Md& )=NULL)
00092 {
00093 IterPair<MdInter> p( (MdInter(begin())), (MdInter(end())) );
00094 return( MdIter( MdPIterator( p, Check )) );
00095 }
00096 MdIter mdEnd( bool (* Check)( const Md& )=NULL)
00097 {
00098 IterPair<MdInter> p( (MdInter(begin())), (MdInter(end())) );
00099 return( MdIter( MdPIterator( p, Check, true )) );
00100 }
00101
00102 ConstMdPair mdPair( bool (* Check)( const Md& )=NULL) const
00103 {
00104 return( ConstMdPair( mdBegin( Check ), mdEnd( Check ) ));
00105 }
00106 ConstMdIter mdBegin( bool (* Check)( const Md& )=NULL) const
00107 {
00108 IterPair<MdCInter> p( (MdCInter(begin())), (MdCInter(end())) );
00109 return( ConstMdIter( MdCPIterator( p, Check )) );
00110 }
00111 ConstMdIter mdEnd( bool (* Check)( const Md& )=NULL) const
00112 {
00113 IterPair<MdCInter> p( (MdCInter(begin())), (MdCInter(end())) );
00114 return( ConstMdIter( MdCPIterator( p, Check, true )) );
00115 }
00116
00117 MdCo( Storage * const s, const string& File );
00118
00119 void getMdData();
00120 void getMdData( unsigned num );
00121 bool findMd( unsigned num, MdIter& i );
00122 bool findMd( unsigned num );
00123 bool findMd( const string& dev, MdIter& i );
00124 bool findMd( const string& dev );
00125 int checkUse( const string& dev );
00126 void addMd( Md* m );
00127 void checkMd( Md* m );
00128 void updateEntry( const Md* m );
00129
00130 void init();
00131
00132 virtual void print( std::ostream& s ) const { s << *this; }
00133 virtual Container* getCopy() const { return( new MdCo( *this ) ); }
00134
00135 int doCreate( Volume* v );
00136 int doRemove( Volume* v );
00137
00138 void logData( const string& Dir );
00139
00140
00141 bool isHandledByMdPart(const string& name);
00142
00143
00144
00145
00146 bool canHandleDev(const string& name, const string& line2);
00147
00148 static bool active;
00149 };
00150
00151 }
00152
00153 #endif