00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef DM_CO_H
00024 #define DM_CO_H
00025
00026 #include "storage/PeContainer.h"
00027 #include "storage/Dm.h"
00028
00029 namespace storage
00030 {
00031 class SystemInfo;
00032
00033
00034 class CmdDmsetup
00035 {
00036
00037 public:
00038
00039 CmdDmsetup();
00040
00041 struct Entry
00042 {
00043 Entry() : name(), mjr(0), mnr(0), segments(0), uuid() {}
00044
00045 string name;
00046 unsigned long mjr;
00047 unsigned long mnr;
00048 unsigned segments;
00049 string uuid;
00050 };
00051
00052 bool getEntry(const string& name, Entry& entry) const;
00053
00054 list<string> getEntries() const;
00055
00056 template<class Pred>
00057 list<string> getMatchingEntries(Pred pred) const
00058 {
00059 list<string> ret;
00060 for (const_iterator i = data.begin(); i != data.end(); ++i)
00061 if (pred(i->first))
00062 ret.push_back(i->first);
00063 return ret;
00064 }
00065
00066 typedef map<string, Entry>::const_iterator const_iterator;
00067
00068 const_iterator begin() const { return data.begin(); }
00069 const_iterator end() const { return data.end(); }
00070
00071 private:
00072
00073 map<string, Entry> data;
00074
00075 };
00076
00077
00078 class DmCo : public PeContainer
00079 {
00080 friend class Storage;
00081
00082 public:
00083
00084 DmCo(Storage * const s);
00085 DmCo(Storage * const s, SystemInfo& systeminfo, bool only_crypt);
00086 DmCo(const DmCo& c);
00087 virtual ~DmCo();
00088
00089 void second(SystemInfo& systeminfo, bool only_crypt);
00090
00091 static storage::CType staticType() { return storage::DM; }
00092 friend std::ostream& operator<< (std::ostream&, const DmCo& );
00093 bool equalContent( const Container& rhs ) const;
00094
00095 virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
00096
00097 void updateDmMaps();
00098
00099 int removeDm( const string& table );
00100 int removeVolume( Volume* v );
00101
00102 protected:
00103
00104 void getDmData(SystemInfo& systeminfo, bool only_crypt);
00105 bool findDm( unsigned num, DmIter& i );
00106 bool findDm( unsigned num );
00107 bool findDm( const string& dev, DmIter& i );
00108 bool findDm( const string& dev );
00109 void addDm( Dm* m );
00110 void checkDm( Dm* m );
00111
00112 virtual Container* getCopy() const { return( new DmCo( *this ) ); }
00113
00114 storage::EncryptType detectEncryption( const string& device ) const;
00115
00116 virtual void print( std::ostream& s ) const { s << *this; }
00117
00118 int doRemove( Volume* v );
00119
00120 private:
00121
00122 DmCo& operator=(const DmCo&);
00123
00124 };
00125
00126 }
00127
00128 #endif