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 "y2storage/Volume.h"
00029
00030 namespace storage
00031 {
00032
00033 class PeContainer;
00034
00035 class Dm : public Volume
00036 {
00037 public:
00038 Dm( const PeContainer& d, const string& tn );
00039 Dm( const PeContainer& d, const string& tn, unsigned mnum );
00040 Dm( const PeContainer& d, const Dm& rhs );
00041 Dm& operator=( const Dm& );
00042
00043 virtual ~Dm();
00044 const string& getTableName() const { return( tname ); }
00045 const string& getTargetName() const { return( target ); }
00046 void setTableName( const string& name ) { tname=name; }
00047 bool inactive() const { return( inactiv ); }
00048 unsigned long long getLe() const { return num_le; }
00049 void setLe( unsigned long long le );
00050 void modifyPeSize( unsigned long long old, unsigned long long neww );
00051 bool removeTable();
00052 virtual void calcSize();
00053 const std::map<string,unsigned long>& getPeMap() const { return( pe_map ); }
00054 void setPeMap( const std::map<string,unsigned long>& m );
00055 unsigned long long usingPe( const string& dev ) const;
00056 bool mapsTo( const string& dev ) const;
00057 void getTableInfo();
00058 virtual bool checkConsistency() const;
00059 unsigned stripes() const { return stripe; }
00060 unsigned setStripes( unsigned long val ) { return stripe=val; }
00061 unsigned long long stripeSize() const { return stripe_size; }
00062 void setStripeSize( unsigned long long val ) { stripe_size=val; }
00063 string sysfsPath() const;
00064 void updateMajorMinor();
00065
00066 virtual const std::list<string> udevId() const { return Volume::udevId(); }
00067 friend std::ostream& operator<< (std::ostream& s, const Dm &p );
00068 virtual void print( std::ostream& s ) const { s << *this; }
00069 virtual string removeText( bool doing ) const;
00070 virtual string formatText( bool doing ) const;
00071 void getInfo( storage::DmInfo& info ) const;
00072 void changeDeviceName( const string& old, const string& nw );
00073
00074 static bool notDeleted( const Dm& l ) { return( !l.deleted() ); }
00075
00076 static void activate( bool val=true );
00077 static bool isActive() { return active; }
00078
00079 static string devToTable( const string& dev );
00080 static string dmName( const string& table );
00081 static int dmNumber( const string& table );
00082 bool equalContent( const Dm& rhs ) const;
00083 void logDifference( const Dm& d ) const;
00084 string stringDifference( const Dm& d ) const;
00085 static unsigned dmMajor();
00086 static string dmDeviceName( unsigned long num );
00087
00088 protected:
00089 void init();
00090 const PeContainer* pec() const;
00091 virtual const string shortPrintedName() const { return( "Dm" ); }
00092 string getDevice( const string& majmin );
00093 static void getDmMajor();
00094
00095 string tname;
00096 string target;
00097 unsigned long long num_le;
00098 unsigned stripe;
00099 unsigned long long stripe_size;
00100 bool inactiv;
00101 std::map<string,unsigned long> pe_map;
00102 static bool active;
00103 static unsigned dm_major;
00104 static std::list<string> known_types;
00105 mutable storage::DmInfo info;
00106 };
00107
00108 }
00109
00110 #endif