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 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 friend std::ostream& operator<< (std::ostream& s, const Dm &p );
00045 virtual void print( std::ostream& s ) const { s << *this; }
00046 virtual string removeText( bool doing ) const;
00047 virtual string formatText( bool doing ) const;
00048 void getInfo( storage::DmInfo& info ) const;
00049 void changeDeviceName( const string& old, const string& nw );
00050
00051 static bool notDeleted( const Dm& l ) { return( !l.deleted() ); }
00052
00053 static void activate( bool val=true );
00054 static string devToTable( const string& dev );
00055 static string dmName( const string& table );
00056 static int dmNumber( const string& table );
00057 bool equalContent( const Dm& rhs ) const;
00058 void logDifference( const Dm& d ) const;
00059 string stringDifference( const Dm& d ) const;
00060 static unsigned dmMajor();
00061 static string dmDeviceName( unsigned long num );
00062
00063 protected:
00064 void init();
00065 const PeContainer* pec() const;
00066 virtual const string shortPrintedName() const { return( "Dm" ); }
00067 string getDevice( const string& majmin );
00068 static void getDmMajor();
00069
00070 string tname;
00071 string target;
00072 unsigned long long num_le;
00073 unsigned stripe;
00074 unsigned long long stripe_size;
00075 bool inactiv;
00076 std::map<string,unsigned long> pe_map;
00077 static bool active;
00078 static unsigned dm_major;
00079 static std::list<string> known_types;
00080 mutable storage::DmInfo info;
00081 };
00082
00083 }
00084
00085 #endif