00001 #ifndef DM_H
00002 #define DM_H
00003
00004 #include <map>
00005
00006 #include "y2storage/Volume.h"
00007
00008 namespace storage
00009 {
00010
00011 class PeContainer;
00012
00013 class Dm : public Volume
00014 {
00015 public:
00016 Dm( const PeContainer& d, const string& tn );
00017 Dm( const PeContainer& d, const string& tn, unsigned mnum );
00018 Dm( const PeContainer& d, const Dm& rhs );
00019 Dm& operator=( const Dm& );
00020
00021 virtual ~Dm();
00022 const string& getTableName() const { return( tname ); }
00023 const string& getTargetName() const { return( target ); }
00024 void setTableName( const string& name ) { tname=name; }
00025 bool inactive() const { return( inactiv ); }
00026 unsigned long long getLe() const { return num_le; }
00027 void setLe( unsigned long long le );
00028 void modifyPeSize( unsigned long long old, unsigned long long neww );
00029 bool removeTable();
00030 virtual void calcSize();
00031 const std::map<string,unsigned long>& getPeMap() const { return( pe_map ); }
00032 void setPeMap( const std::map<string,unsigned long>& m );
00033 unsigned long long usingPe( const string& dev ) const;
00034 bool mapsTo( const string& dev ) const;
00035 void getTableInfo();
00036 virtual bool checkConsistency() const;
00037 unsigned stripes() const { return stripe; }
00038 unsigned setStripes( unsigned long val ) { return stripe=val; }
00039 unsigned long long stripeSize() const { return stripe_size; }
00040 void setStripeSize( unsigned long long val ) { stripe_size=val; }
00041 string sysfsPath() const;
00042 void updateMajorMinor();
00043
00044 virtual const std::list<string> udevId() const { return Volume::udevId(); }
00045 friend std::ostream& operator<< (std::ostream& s, const Dm &p );
00046 virtual void print( std::ostream& s ) const { s << *this; }
00047 virtual string removeText( bool doing ) const;
00048 virtual string formatText( bool doing ) const;
00049 void getInfo( storage::DmInfo& info ) const;
00050 void changeDeviceName( const string& old, const string& nw );
00051
00052 static bool notDeleted( const Dm& l ) { return( !l.deleted() ); }
00053
00054 static void activate( bool val=true );
00055 static bool isActive() { return active; }
00056
00057 static string devToTable( const string& dev );
00058 static string dmName( const string& table );
00059 static int dmNumber( const string& table );
00060 bool equalContent( const Dm& rhs ) const;
00061 void logDifference( const Dm& d ) const;
00062 string stringDifference( const Dm& d ) const;
00063 static unsigned dmMajor();
00064 static string dmDeviceName( unsigned long num );
00065
00066 protected:
00067 void init();
00068 const PeContainer* pec() const;
00069 virtual const string shortPrintedName() const { return( "Dm" ); }
00070 string getDevice( const string& majmin );
00071 static void getDmMajor();
00072
00073 string tname;
00074 string target;
00075 unsigned long long num_le;
00076 unsigned stripe;
00077 unsigned long long stripe_size;
00078 bool inactiv;
00079 std::map<string,unsigned long> pe_map;
00080 static bool active;
00081 static unsigned dm_major;
00082 static std::list<string> known_types;
00083 mutable storage::DmInfo info;
00084 };
00085
00086 }
00087
00088 #endif