|
yast2-storage
|
00001 /* 00002 * Copyright (c) [2004-2011] 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 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 void detectSubvol(); 00048 list<string> getDevices( bool add_del=false ) const; 00049 void getDevices( list<string>& devs, bool add_del=false ) const; 00050 void getSubvolumes( list<Subvolume>& sv ) const { sv = subvol; } 00051 00052 bool existSubvolume( const string& name ); 00053 int createSubvolume( const string& name ); 00054 int deleteSubvolume( const string& name ); 00055 int extendVolume( const string& dev ); 00056 int extendVolume( const list<string>& devs ); 00057 int shrinkVolume( const string& dev ); 00058 int shrinkVolume( const list<string>& devs ); 00059 00060 void getCommitActions(list<commitAction>& l) const; 00061 int doDeleteSubvol(); 00062 int doCreateSubvol(); 00063 int doReduce(); 00064 int doExtend(); 00065 Text createSubvolText(bool doing, const string& name) const; 00066 Text deleteSubvolText(bool doing, const string& name) const; 00067 Text extendText(bool doing, const string& device) const; 00068 Text reduceText(bool doing, const string& device) const; 00069 Text removeText( bool doing ) const; 00070 Text formatText( bool doing ) const; 00071 int setFormat( bool format, storage::FsType fs ); 00072 00073 virtual string udevPath() const; 00074 virtual list<string> udevId() const; 00075 virtual string sysfsPath() const; 00076 00077 void countSubvolAddDel( unsigned& add, unsigned& rem ) const; 00078 list<string> getSubvolAddDel( bool ) const; 00079 00080 void saveData(xmlNode* node) const; 00081 friend std::ostream& operator<< (std::ostream& s, const Btrfs& l ); 00082 virtual void print( std::ostream& s ) const { s << *this; } 00083 void getInfo( storage::BtrfsInfo& info ) const; 00084 bool equalContent( const Btrfs& rhs ) const; 00085 void logDifference(std::ostream& log, const Btrfs& rhs) const; 00086 void unuseDev() const; 00087 int clearSignature(); 00088 00089 void changeDeviceName( const string& old, const string& nw ); 00090 00091 static bool notDeleted( const Btrfs& l ) { return( !l.deleted() ); } 00092 static bool needCreateSubvol( const Btrfs& v ); 00093 static bool needDeleteSubvol( const Btrfs& v ); 00094 static bool needReduce( const Btrfs& v ); 00095 static bool needExtend( const Btrfs& v ); 00096 00097 protected: 00098 BtrfsCo* co(); 00099 string subvolNames( bool added ) const; 00100 list<string> devices; 00101 list<string> dev_add; 00102 list<string> dev_rem; 00103 list<Subvolume> subvol; 00104 Volume const * findRealVolume() const; 00105 00106 mutable storage::BtrfsInfo info; // workaround for broken ycp bindings 00107 00108 private: 00109 00110 Btrfs& operator=(const Btrfs& v); // disallow 00111 Btrfs(const Btrfs&); // disallow 00112 00113 }; 00114 00115 } 00116 00117 #endif
1.7.3