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_H
00024 #define DM_H
00025
00026 #include <map>
00027
00028 #include "storage/Volume.h"
00029
00030 namespace storage
00031 {
00032
00033 class PeContainer;
00034
00035 class Dm : public Volume
00036 {
00037 public:
00038
00039 Dm(const PeContainer& c, const string& name, const string& device, const string& tname);
00040 Dm(const PeContainer& c, const string& name, const string& device, const string& tname,
00041 SystemInfo& systeminfo);
00042 Dm(const PeContainer& c, const xmlNode* node);
00043 Dm(const PeContainer& c, const Dm& v);
00044 virtual ~Dm();
00045
00046 void saveData(xmlNode* node) const;
00047
00048 const string& getTableName() const { return( tname ); }
00049 const string& getTargetName() const { return( target ); }
00050 void setTableName( const string& name ) { tname=name; }
00051 bool inactive() const { return( inactiv ); }
00052 unsigned long long getLe() const { return num_le; }
00053 void setLe( unsigned long long le );
00054 void modifyPeSize( unsigned long long old, unsigned long long neww );
00055 bool removeTable();
00056 virtual void calcSize();
00057 const std::map<string,unsigned long>& getPeMap() const { return( pe_map ); }
00058 void setPeMap( const std::map<string,unsigned long>& m );
00059 unsigned long long usingPe( const string& dev ) const;
00060 bool mapsTo( const string& dev ) const;
00061 void getTableInfo();
00062 virtual bool checkConsistency() const;
00063 unsigned stripes() const { return stripe; }
00064 unsigned setStripes( unsigned long val ) { return stripe=val; }
00065 unsigned long long stripeSize() const { return stripe_size; }
00066 void setStripeSize( unsigned long long val ) { stripe_size=val; }
00067
00068 virtual string procName() const { return "dm-" + decString(mnr); }
00069 virtual string sysfsPath() const;
00070
00071 void updateMajorMinor();
00072
00073 friend std::ostream& operator<< (std::ostream& s, const Dm &p );
00074 virtual void print( std::ostream& s ) const { s << *this; }
00075 virtual Text removeText( bool doing ) const;
00076 virtual Text formatText( bool doing ) const;
00077 void getInfo( storage::DmInfo& info ) const;
00078 void changeDeviceName( const string& old, const string& nw );
00079
00080 static bool notDeleted( const Dm& l ) { return( !l.deleted() ); }
00081 static bool isDeleted(const Dm& l) { return l.deleted(); }
00082
00083 static void activate(bool val);
00084 static bool isActive() { return active; }
00085
00086 static string devToTable( const string& dev );
00087
00088 virtual list<string> getUsing() const;
00089
00090 bool equalContent(const Dm& rhs) const;
00091
00092 void logDifference(std::ostream& log, const Dm& rhs) const;
00093
00094 static unsigned dmMajor();
00095 static string dmDeviceName( unsigned long num );
00096
00097 protected:
00098 void init();
00099 const PeContainer* pec() const;
00100 virtual const string shortPrintedName() const { return( "Dm" ); }
00101
00102 string tname;
00103 string target;
00104 unsigned long long num_le;
00105 unsigned stripe;
00106 unsigned long long stripe_size;
00107 bool inactiv;
00108 std::map<string,unsigned long> pe_map;
00109 static bool active;
00110 static unsigned dm_major;
00111
00112 static const list<string> known_types;
00113
00114 mutable storage::DmInfo info;
00115
00116 private:
00117
00118 Dm(const Dm&);
00119 Dm& operator=(const Dm&);
00120
00121 };
00122
00123 }
00124
00125 #endif