00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef BTRFS_H
00024 #define BTRFS_H
00025
00026 #include "storage/Volume.h"
00027
00028 namespace storage
00029 {
00030 class BtrfsCo;
00031 class SystemInfo;
00032
00033
00034 class Btrfs : public Volume
00035 {
00036 public:
00037
00038 Btrfs( const BtrfsCo& d, const Volume& v, unsigned long long sz,
00039 const list<string>& devices );
00040 Btrfs( const BtrfsCo& d, const Volume& v );
00041 Btrfs( const BtrfsCo& d, const xmlNode* node );
00042 Btrfs( const BtrfsCo& c, const Btrfs& v);
00043 virtual ~Btrfs();
00044
00045 void clearSubvol() { subvol.clear(); }
00046 void addSubvol( const string& path );
00047 list<string> getDevices( bool add_del=false ) const;
00048 void getDevices( list<string>& devs, bool add_del=false ) const;
00049 void getSubvolumes( list<Subvolume>& sv ) const { sv = subvol; }
00050
00051 bool existSubvolume( const string& name );
00052 int createSubvolume( const string& name );
00053 int deleteSubvolume( const string& name );
00054 int extendVolume( const string& dev );
00055 int extendVolume( const list<string>& devs );
00056 int shrinkVolume( const string& dev );
00057 int shrinkVolume( const list<string>& devs );
00058
00059 void getCommitActions(list<commitAction>& l) const;
00060 int doDeleteSubvol();
00061 int doCreateSubvol();
00062 int doReduce();
00063 int doExtend();
00064 Text createSubvolText(bool doing, const string& name) const;
00065 Text deleteSubvolText(bool doing, const string& name) const;
00066 Text extendText(bool doing, const string& device) const;
00067 Text reduceText(bool doing, const string& device) const;
00068 Text removeText( bool doing ) const;
00069 Text formatText( bool doing ) const;
00070 int setFormat( bool format, storage::FsType fs );
00071
00072 virtual string udevPath() const;
00073 virtual list<string> udevId() const;
00074 virtual string sysfsPath() const;
00075
00076 void countSubvolAddDel( unsigned& add, unsigned& rem ) const;
00077 list<string> getSubvolAddDel( bool ) const;
00078
00079 void saveData(xmlNode* node) const;
00080 friend std::ostream& operator<< (std::ostream& s, const Btrfs& l );
00081 virtual void print( std::ostream& s ) const { s << *this; }
00082 void getInfo( storage::BtrfsInfo& info ) const;
00083 bool equalContent( const Btrfs& rhs ) const;
00084 void logDifference(std::ostream& log, const Btrfs& rhs) const;
00085 void unuseDev() const;
00086 int clearSignature();
00087
00088 void changeDeviceName( const string& old, const string& nw );
00089
00090 static bool notDeleted( const Btrfs& l ) { return( !l.deleted() ); }
00091 static bool needCreateSubvol( const Btrfs& v );
00092 static bool needDeleteSubvol( const Btrfs& v );
00093 static bool needReduce( const Btrfs& v );
00094 static bool needExtend( const Btrfs& v );
00095
00096 protected:
00097 BtrfsCo* co();
00098 string subvolNames( bool added ) const;
00099 list<string> devices;
00100 list<string> dev_add;
00101 list<string> dev_rem;
00102 list<Subvolume> subvol;
00103 Volume const * findRealVolume() const;
00104
00105 mutable storage::BtrfsInfo info;
00106
00107 private:
00108
00109 Btrfs& operator=(const Btrfs& v);
00110 Btrfs(const Btrfs&);
00111
00112 };
00113
00114 }
00115
00116 #endif