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 string table;
00051 };
00052
00053 bool getEntry(const string& name, Entry& entry) const;
00054
00055 list<string> getEntries() const;
00056
00057 template<class Pred>
00058 list<string> getMatchingEntries(Pred pred) const
00059 {
00060 list<string> ret;
00061 for (const_iterator i = data.begin(); i != data.end(); ++i)
00062 if (pred(i->first))
00063 ret.push_back(i->first);
00064 return ret;
00065 }
00066
00067 typedef map<string, Entry>::const_iterator const_iterator;
00068
00069 const_iterator begin() const { return data.begin(); }
00070 const_iterator end() const { return data.end(); }
00071
00072 private:
00073
00074 map<string, Entry> data;
00075
00076 };
00077
00078
00079 class DmCo : public PeContainer
00080 {
00081 friend class Storage;
00082
00083 public:
00084
00085 DmCo(Storage * const s);
00086 DmCo(Storage * const s, SystemInfo& systeminfo, bool only_crypt);
00087 DmCo(const DmCo& c);
00088 virtual ~DmCo();
00089
00090 void second(SystemInfo& systeminfo, bool only_crypt);
00091
00092 static storage::CType staticType() { return storage::DM; }
00093 friend std::ostream& operator<< (std::ostream&, const DmCo& );
00094 bool equalContent( const Container& rhs ) const;
00095
00096 virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
00097
00098 void updateDmMaps();
00099
00100 int removeDm( const string& table );
00101 int removeVolume( Volume* v );
00102
00103 protected:
00104
00105 void getDmData(SystemInfo& systeminfo);
00106 void getDmDataCrypt(SystemInfo& systeminfo);
00107 bool getProcSize(SystemInfo& systeminfo, unsigned nr, unsigned long long& s);
00108 bool findDm( unsigned num, DmIter& i );
00109 bool findDm( unsigned num );
00110 bool findDm( const string& dev, DmIter& i );
00111 bool findDm( const string& dev );
00112 void addDm( Dm* m );
00113 void checkDm( Dm* m );
00114
00115 virtual Container* getCopy() const { return( new DmCo( *this ) ); }
00116
00117 storage::EncryptType detectEncryption( const string& device ) const;
00118
00119 virtual void print( std::ostream& s ) const { s << *this; }
00120
00121 int doRemove( Volume* v );
00122
00123 private:
00124
00125 DmCo& operator=(const DmCo&);
00126
00127 };
00128
00129 }
00130
00131 #endif