00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef NFS_CO_H
00024 #define NFS_CO_H
00025
00026 #include "y2storage/Container.h"
00027 #include "y2storage/Nfs.h"
00028
00029 namespace storage
00030 {
00031 class NfsCo : public Container
00032 {
00033 friend class Storage;
00034
00035 public:
00036 NfsCo( Storage * const s, ProcMounts& mounts );
00037 NfsCo( Storage * const s );
00038 NfsCo( const NfsCo& rhs );
00039
00040 virtual ~NfsCo();
00041 static storage::CType staticType() { return storage::NFSC; }
00042 friend std::ostream& operator<< ( std::ostream&, const NfsCo& );
00043 int addNfs( const string& nfsDev, unsigned long long sizeK,
00044 const string& mp );
00045
00046 static bool isNfsDev( const string& dev );
00047 int removeVolume( Volume* v );
00048 int doRemove( Volume* );
00049
00050 bool equalContent( const Container& rhs ) const;
00051 void logDifference( const Container& d ) const;
00052
00053 protected:
00054
00055
00056 typedef CastIterator<VIter, Nfs *> NfsInter;
00057 typedef CastIterator<CVIter, const Nfs *> NfsCInter;
00058 template< class Pred >
00059 struct NfsPI { typedef ContainerIter<Pred, NfsInter> type; };
00060 template< class Pred >
00061 struct NfsCPI { typedef ContainerIter<Pred, NfsCInter> type; };
00062 typedef CheckFnc<const Nfs> CheckFncNfs;
00063 typedef CheckerIterator< CheckFncNfs, NfsPI<CheckFncNfs>::type,
00064 NfsInter, Nfs > NfsPIterator;
00065 typedef CheckerIterator< CheckFncNfs, NfsCPI<CheckFncNfs>::type,
00066 NfsCInter, const Nfs > NfsCPIterator;
00067 typedef DerefIterator<NfsPIterator,Nfs> NfsIter;
00068 typedef DerefIterator<NfsCPIterator,const Nfs> ConstNfsIter;
00069 typedef IterPair<NfsIter> NfsPair;
00070 typedef IterPair<ConstNfsIter> ConstNfsPair;
00071
00072 NfsPair nfsPair( bool (* Check)( const Nfs& )=NULL)
00073 {
00074 return( NfsPair( nfsBegin( Check ), nfsEnd( Check ) ));
00075 }
00076 NfsIter nfsBegin( bool (* Check)( const Nfs& )=NULL)
00077 {
00078 IterPair<NfsInter> p( (NfsInter(begin())), (NfsInter(end())) );
00079 return( NfsIter( NfsPIterator( p, Check )) );
00080 }
00081 NfsIter nfsEnd( bool (* Check)( const Nfs& )=NULL)
00082 {
00083 IterPair<NfsInter> p( (NfsInter(begin())), (NfsInter(end())) );
00084 return( NfsIter( NfsPIterator( p, Check, true )) );
00085 }
00086
00087 ConstNfsPair nfsPair( bool (* Check)( const Nfs& )=NULL) const
00088 {
00089 return( ConstNfsPair( nfsBegin( Check ), nfsEnd( Check ) ));
00090 }
00091 ConstNfsIter nfsBegin( bool (* Check)( const Nfs& )=NULL) const
00092 {
00093 IterPair<NfsCInter> p( (NfsCInter(begin())), (NfsCInter(end())) );
00094 return( ConstNfsIter( NfsCPIterator( p, Check )) );
00095 }
00096 ConstNfsIter nfsEnd( bool (* Check)( const Nfs& )=NULL) const
00097 {
00098 IterPair<NfsCInter> p( (NfsCInter(begin())), (NfsCInter(end())) );
00099 return( ConstNfsIter( NfsCPIterator( p, Check, true )) );
00100 }
00101
00102 NfsCo( Storage * const s, const string& File );
00103
00104 bool findNfs( const string& dev, NfsIter& i );
00105 bool findNfs( const string& dev );
00106 void getNfsData( ProcMounts& mounts );
00107 void init();
00108
00109 virtual void print( std::ostream& s ) const { s << *this; }
00110 virtual Container* getCopy() const { return( new NfsCo( *this ) ); }
00111
00112 void logData( const string& Dir );
00113 };
00114
00115 }
00116
00117 #endif