yast2-storage

Dm.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) [2004-2009] Novell, Inc.
00003  *
00004  * All Rights Reserved.
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of version 2 of the GNU General Public License as published
00008  * by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful, but WITHOUT
00011  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00013  * more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, contact Novell, Inc.
00017  *
00018  * To contact Novell about this file by physical or electronic mail, you may
00019  * find current contact information at www.novell.com.
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         typedef std::map<string,unsigned long> PeMap;
00047 
00048         void saveData(xmlNode* node) const;
00049 
00050         const string& getTableName() const { return( tname ); }
00051         void setTableName( const string& name ) { tname=name; }
00052         const string& getTargetName() const { return( target ); }
00053         void setTargetName( const string& name ) { target=name; }
00054         bool inactive() const { return( inactiv ); }
00055         unsigned long long getLe() const { return num_le; }
00056         void setLe( unsigned long long le );
00057         void modifyPeSize( unsigned long long old, unsigned long long neww );
00058         bool removeTable();
00059         virtual void calcSize();
00060         const PeMap& getPeMap() const { return( pe_map ); }
00061         void setPeMap( const PeMap& m );
00062         unsigned long long usingPe( const string& dev ) const;
00063         bool mapsTo( const string& dev ) const;
00064         void getTableInfo();
00065         virtual bool checkConsistency() const;
00066         unsigned stripes() const { return stripe; }
00067         unsigned setStripes( unsigned long val ) { return stripe=val; }
00068         unsigned long long stripeSize() const { return stripe_size; }
00069         void setStripeSize( unsigned long long val ) { stripe_size=val; }
00070 
00071         virtual string procName() const { return "dm-" + decString(mnr); }
00072         virtual string sysfsPath() const;
00073         void setUdevData(SystemInfo& systeminfo);
00074 
00075         void updateMajorMinor();
00076 
00077         friend std::ostream& operator<< (std::ostream& s, const Dm &p );
00078         virtual void print( std::ostream& s ) const { s << *this; }
00079         virtual Text removeText( bool doing ) const;
00080         virtual Text formatText( bool doing ) const;
00081         void getInfo( storage::DmInfo& info ) const;
00082         void changeDeviceName( const string& old, const string& nw );
00083 
00084         static bool notDeleted( const Dm& l ) { return( !l.deleted() ); }
00085         static bool isDeleted(const Dm& l) { return l.deleted(); }
00086 
00087         static void activate(bool val);
00088         static bool isActive() { return active; }
00089 
00090         static string devToTable( const string& dev );
00091         static string lvmTableToDev( const string& table );
00092 
00093         virtual list<string> getUsing() const;
00094 
00095         bool equalContent(const Dm& rhs) const;
00096 
00097         void logDifference(std::ostream& log, const Dm& rhs) const;
00098 
00099         static unsigned dmMajor();
00100         static string dmDeviceName( unsigned long num );
00101 
00102     protected:
00103         void init();
00104         const PeContainer* pec() const;
00105         virtual const string shortPrintedName() const { return( "Dm" ); }
00106         unsigned long computeLe( const string& lestr );
00107         void computePe( const SystemCmd& cmd, PeMap& pe );
00108         void accumulatePe( const string& majmin, unsigned long le, PeMap& pe );
00109         void getMapRecursive( unsigned long mi, PeMap& pe );
00110         static list<string> extractMajMin( const string& s );
00111 
00112         string tname;
00113         string target;
00114         unsigned long long num_le;
00115         unsigned stripe;
00116         unsigned long long stripe_size;
00117         bool inactiv;
00118         bool pe_larger;   // true for table like e.g. thin-pool where sum of used pe´s is larger than device size
00119         PeMap pe_map;
00120         static bool active;
00121         static unsigned dm_major;
00122 
00123         static const list<string> known_types;
00124 
00125         mutable storage::DmInfo info; // workaround for broken ycp bindings
00126 
00127     private:
00128 
00129         Dm(const Dm&);            // disallow
00130         Dm& operator=(const Dm&); // disallow
00131 
00132     };
00133 
00134 }
00135 
00136 #endif