00001 #ifndef STORAGE_H
00002 #define STORAGE_H
00003
00004 #include <iostream>
00005 #include <list>
00006 #include <map>
00007
00008 #include "y2storage/StorageInterface.h"
00009 #include "y2storage/StorageTypes.h"
00010 #include "y2storage/StorageTmpl.h"
00011 #include "y2storage/Container.h"
00012 #include "y2storage/Volume.h"
00013 #include "y2storage/Disk.h"
00014 #include "y2storage/Partition.h"
00015 #include "y2storage/LvmVg.h"
00016 #include "y2storage/LvmLv.h"
00017 #include "y2storage/EvmsCo.h"
00018 #include "y2storage/Evms.h"
00019 #include "y2storage/MdCo.h"
00020 #include "y2storage/Md.h"
00021 #include "y2storage/DmCo.h"
00022 #include "y2storage/LoopCo.h"
00023 #include "y2storage/Loop.h"
00024 #include "y2storage/FilterIterator.h"
00025 #include "y2storage/DerefIterator.h"
00026 #include "y2storage/ListListIterator.h"
00027 #include "y2storage/IterPair.h"
00028
00029 template <int Value>
00030 class CheckType
00031 {
00032 public:
00033 bool operator()( const Container& d ) const
00034 {
00035 return( d.type()==Value );
00036 }
00037 };
00038
00039 template< class Iter, int Value, class CastResult >
00040 class CastCheckIterator : public CheckType<Value>,
00041 public FilterIterator< CheckType<Value>, Iter >
00042 {
00043 typedef FilterIterator<CheckType<Value>, Iter> _bclass;
00044 public:
00045 typedef CastResult value_type;
00046 typedef CastResult& reference;
00047 typedef CastResult* pointer;
00048
00049 CastCheckIterator() : _bclass() {}
00050 CastCheckIterator( const Iter& b, const Iter& e, bool atend=false) :
00051 _bclass( b, e, *this, atend ) {}
00052 CastCheckIterator( const IterPair<Iter>& pair, bool atend=false) :
00053 _bclass( pair, *this, atend ) {}
00054 CastCheckIterator( const CastCheckIterator& i) { *this=i;}
00055 CastResult operator*() const
00056 {
00057 return( static_cast<CastResult>(_bclass::operator*()) );
00058 }
00059 CastResult* operator->() const
00060 {
00061 return( static_cast<CastResult*>(_bclass::operator->()) );
00062 }
00063 CastCheckIterator& operator++()
00064 {
00065 _bclass::operator++(); return(*this);
00066 }
00067 CastCheckIterator operator++(int)
00068 {
00069 y2warning( "Expensive ++ CastCheckIterator" );
00070 CastCheckIterator tmp(*this);
00071 _bclass::operator++();
00072 return(tmp);
00073 }
00074 CastCheckIterator& operator--()
00075 {
00076 _bclass::operator--(); return(*this);
00077 }
00078 CastCheckIterator operator--(int)
00079 {
00080 y2warning( "Expensive -- CastCheckIterator" );
00081 CastCheckIterator tmp(*this);
00082 _bclass::operator--();
00083 return(tmp);
00084 }
00085 };
00086
00102 class EtcFstab;
00103
00104 class Storage : public storage::StorageInterface
00105 {
00106 protected:
00107
00108 typedef std::list<Container*> CCont;
00109 typedef CCont::iterator CIter;
00110 typedef CCont::const_iterator CCIter;
00111
00112 static bool isMd( const Container&d )
00113 { return( d.type()==storage::MD ); };
00114 static bool isLoop( const Container&d )
00115 { return( d.type()==storage::LOOP ); };
00116 static bool isDm( const Container&d )
00117 { return( d.type()==storage::DM ); };
00118 struct FreeInfo
00119 {
00120 unsigned long long resize_free;
00121 unsigned long long df_free;
00122 unsigned long long used;
00123 bool win;
00124 FreeInfo() { resize_free=df_free=used=0; win=false; }
00125 FreeInfo( unsigned long long df,
00126 unsigned long long resize,
00127 unsigned long long usd, bool w=false )
00128 { resize_free=resize; df_free=df; used=usd; win=w; }
00129 };
00130
00131 public:
00132 struct SkipDeleted { bool operator()(const Container&d) const {return( !d.deleted());}};
00133 static SkipDeleted SkipDel;
00134 static bool notDeleted( const Container&d ) { return( !d.deleted() ); };
00135
00136 static void initDefaultLogger ();
00137
00138 Storage( bool ronly=false, bool testmode=false, bool autodetect=true );
00139 bool test() const { return( testmode ); }
00140 bool instsys() const { return( inst_sys ); }
00141 void setCacheChanges( bool val=true ) { cache = val; }
00142 bool isCacheChanges() const { return( cache ); }
00143 void assertInit() { if( !initialized ) initialize(); }
00144 void rescanEverything();
00145 int checkCache();
00146 const string& tDir() const { return( testdir ); }
00147 const string& root() const { return( rootprefix ); }
00148 const string& tmpDir() const;
00149 static const string& arch() { return( proc_arch ); }
00150 EtcFstab* getFstab() { return fstab; }
00151 void handleLogFile( const string& name );
00152 static bool testFilesEqual( const string& n1, const string& n2 );
00153 void printInfo( std::ostream& str );
00154 storage::UsedByType usedBy( const string& dev );
00155 bool setUsedBy( const string& dev, storage::UsedByType typ,
00156 const string& name );
00157 bool canUseDevice( const string& dev, bool disks_allowed=false );
00158 bool knownDevice( const string& dev, bool disks_allowed=false );
00159 const Volume* getVolume( const string& dev );
00160 unsigned long long deviceSize( const string& dev );
00161 string deviceByNumber( const string& majmin );
00162 void rootMounted();
00163 bool isRootMounted() const { return( root_mounted ); }
00164
00165 virtual ~Storage();
00166
00167
00168
00169 void getContainers( deque<storage::ContainerInfo>& infos );
00170 int getDiskInfo( const string& disk, storage::DiskInfo& info);
00171 int getLvmVgInfo( const string& name, storage::LvmVgInfo& info);
00172 int getEvmsCoInfo( const string& name, storage::EvmsCoInfo& info);
00173 int getContDiskInfo( const string& disk, storage::ContainerInfo& cinfo,
00174 storage::DiskInfo& info);
00175 int getContLvmVgInfo( const string& name, storage::ContainerInfo& cinfo,
00176 storage::LvmVgInfo& info);
00177 int getContEvmsCoInfo( const string& name,
00178 storage::ContainerInfo& cinfo,
00179 storage::EvmsCoInfo& info );
00180 void getVolumes (deque<storage::VolumeInfo>& vlist);
00181 int getVolume( const string& device, storage::VolumeInfo& info);
00182 int getPartitionInfo( const string& disk,
00183 deque<storage::PartitionInfo>& plist );
00184 int getLvmLvInfo( const string& name,
00185 deque<storage::LvmLvInfo>& plist );
00186 int getEvmsInfo( const string& name,
00187 deque<storage::EvmsInfo>& plist );
00188 int getMdInfo( deque<storage::MdInfo>& plist );
00189 int getDmInfo( deque<storage::DmInfo>& plist );
00190 int getLoopInfo( deque<storage::LoopInfo>& plist );
00191
00192 bool getFsCapabilities( storage::FsType fstype,
00193 storage::FsCapabilities& fscapabilities) const;
00194 void setExtError( const string& txt );
00195 int createPartition( const string& disk, storage::PartitionType type,
00196 unsigned long start, unsigned long size,
00197 string& device );
00198 int resizePartition( const string& device, unsigned long sizeCyl );
00199 int nextFreePartition( const string& disk, storage::PartitionType type,
00200 unsigned &nr, string& device );
00201 int updatePartitionArea( const string& device,
00202 unsigned long start, unsigned long size );
00203 int createPartitionKb( const string& disk, storage::PartitionType type,
00204 unsigned long long start,
00205 unsigned long long sizek, string& device );
00206 int createPartitionAny( const string& disk, unsigned long long size,
00207 string& device );
00208 int createPartitionMax( const string& disk, storage::PartitionType type,
00209 string& device );
00210 unsigned long kbToCylinder( const string& disk, unsigned long long size );
00211 unsigned long long cylinderToKb( const string& disk, unsigned long size );
00212 int removePartition( const string& partition );
00213 int changePartitionId( const string& partition, unsigned id );
00214 int forgetChangePartitionId( const string& partition );
00215 int destroyPartitionTable( const string& disk, const string& label );
00216 string defaultDiskLabel() const;
00217
00218 int changeFormatVolume( const string& device, bool format,
00219 storage::FsType fs );
00220 int changeLabelVolume( const string& device, const string& label );
00221 int changeMkfsOptVolume( const string& device, const string& opts );
00222 int changeMountPoint( const string& device, const string& mount );
00223 int getMountPoint( const string& device, string& mount );
00224 int changeMountBy( const string& device, storage::MountByType mby );
00225 int getMountBy( const string& device, storage::MountByType& mby );
00226 int changeFstabOptions( const string&, const string& options );
00227 int getFstabOptions( const string& device, string& options );
00228 int addFstabOptions( const string&, const string& options );
00229 int removeFstabOptions( const string&, const string& options );
00230 int setCryptPassword( const string& device, const string& pwd );
00231 int forgetCryptPassword( const string& device );
00232 int getCryptPassword( const string& device, string& pwd );
00233 int setCrypt( const string& device, bool val );
00234 int getCrypt( const string& device, bool& val );
00235 int setIgnoreFstab( const string& device, bool val );
00236 int getIgnoreFstab( const string& device, bool& val );
00237 int addFstabEntry( const string& device, const string& mount,
00238 const string& vfs, const string& options,
00239 unsigned freq, unsigned passno );
00240 int resizeVolume( const string& device, unsigned long long newSizeMb );
00241 int forgetResizeVolume( const string& device );
00242 void setRecursiveRemoval( bool val=true );
00243 bool getRecursiveRemoval() const { return recursiveRemove; }
00244 void setZeroNewPartitions( bool val=true );
00245 bool getZeroNewPartitions() const { return zeroNewPartitions; }
00246 void setDetectMountedVolumes( bool val=true );
00247 bool getDetectMountedVolumes() const { return detectMounted; }
00248 void setRootPrefix( const string& root );
00249 int removeVolume( const string& device );
00250 int removeUsing( const string& device, const storage::usedBy& uby );
00251 bool checkDeviceMounted( const string& device, string& mp );
00252 bool umountDevice( const string& device );
00253 bool mountDevice( const string& device, const string& mp );
00254 bool readFstab( const string& dir, deque<storage::VolumeInfo>& infos);
00255 bool getFreeInfo( const string& device, unsigned long long& resize_free,
00256 unsigned long long& df_free,
00257 unsigned long long& used, bool& win, bool use_cache );
00258 int createBackupState( const string& name );
00259 int removeBackupState( const string& name );
00260 int restoreBackupState( const string& name );
00261 bool checkBackupState( const string& name );
00262 bool equalBackupStates( const string& lhs, const string& rhs,
00263 bool verbose_log ) const;
00264
00265 int createLvmVg( const string& name, unsigned long long peSizeK,
00266 bool lvm1, const deque<string>& devs );
00267 int removeLvmVg( const string& name );
00268 int extendLvmVg( const string& name, const deque<string>& devs );
00269 int shrinkLvmVg( const string& name, const deque<string>& devs );
00270 int createLvmLv( const string& vg, const string& name,
00271 unsigned long long sizeM, unsigned stripe,
00272 string& device );
00273 int removeLvmLvByDevice( const string& device );
00274 int removeLvmLv( const string& vg, const string& name );
00275 int changeLvStripeSize( const string& vg, const string& name,
00276 unsigned long long stripeSize );
00277
00278
00279 int createEvmsContainer( const string& name, unsigned long long peSizeK,
00280 bool lvm1, const deque<string>& devs );
00281 int removeEvmsContainer( const string& name );
00282 int extendEvmsContainer( const string& name, const deque<string>& devs );
00283 int shrinkEvmsContainer( const string& name, const deque<string>& devs );
00284 int createEvmsVolume( const string& vg, const string& name,
00285 unsigned long long sizeM, unsigned stripe,
00286 string& device );
00287 int removeEvmsVolumeByDevice( const string& device );
00288 int removeEvmsVolume( const string& vg, const string& name );
00289 int changeEvmsStripeSize( const string& coname, const string& name,
00290 unsigned long long stripeSize );
00291
00292 int createMd( const string& name, storage::MdType rtype,
00293 const deque<string>& devs );
00294 int createMdAny( storage::MdType rtype, const deque<string>& devs,
00295 string& device );
00296 int removeMd( const string& name, bool destroySb=true );
00297 int extendMd( const string& name, const string& dev );
00298 int shrinkMd( const string& name, const string& dev );
00299 int changeMdType( const string& name, storage::MdType rtype );
00300 int changeMdChunk( const string& name, unsigned long chunk );
00301 int changeMdParity( const string& name, storage::MdParity ptype );
00302 int checkMd( const string& name );
00303
00304
00305 int createFileLoop( const string& lname, bool reuseExisting,
00306 unsigned long long sizeK, const string& mp,
00307 const string& pwd, string& device );
00308 int removeFileLoop( const string& lname, bool removeFile );
00309
00310 deque<string> getCommitActions( bool mark_destructive );
00311 const string& getLastAction() const { return lastAction; }
00312 const string& getExtendedErrorMessage() const { return extendedError; }
00313 void eraseFreeInfo( const string& device );
00314 int waitForDevice( const string& device ) const;
00315
00316 int commit();
00317 void activateHld( bool val=true );
00318
00319 void setCallbackProgressBar( storage::CallbackProgressBar pfnc )
00320 { progress_bar_cb=pfnc; }
00321 storage::CallbackProgressBar getCallbackProgressBar() const
00322 { return progress_bar_cb; }
00323 void setCallbackShowInstallInfo( storage::CallbackShowInstallInfo pfnc )
00324 { install_info_cb=pfnc; }
00325 storage::CallbackShowInstallInfo getCallbackShowInstallInfo() const
00326 { return install_info_cb; }
00327 void setCallbackInfoPopup( storage::CallbackInfoPopup pfnc )
00328 { info_popup_cb=pfnc; }
00329 storage::CallbackInfoPopup getCallbackInfoPopup() const
00330 { return info_popup_cb; }
00331 void setCallbackYesNoPopup( storage::CallbackYesNoPopup pfnc )
00332 { yesno_popup_cb=pfnc; }
00333 storage::CallbackYesNoPopup getCallbackYesNoPopup() const
00334 { return yesno_popup_cb; }
00335
00336 static void setCallbackProgressBarYcp( storage::CallbackProgressBar pfnc )
00337 { progress_bar_cb_ycp=pfnc; }
00338 static storage::CallbackProgressBar getCallbackProgressBarYcp()
00339 { return progress_bar_cb_ycp; }
00340 static void setCallbackShowInstallInfoYcp( storage::CallbackShowInstallInfo pfnc )
00341 { install_info_cb_ycp=pfnc; }
00342 static storage::CallbackShowInstallInfo getCallbackShowInstallInfoYcp()
00343 { return install_info_cb_ycp; }
00344 static void setCallbackInfoPopupYcp( storage::CallbackInfoPopup pfnc )
00345 { info_popup_cb_ycp=pfnc; }
00346 static storage::CallbackInfoPopup getCallbackInfoPopupYcp()
00347 { return info_popup_cb_ycp; }
00348 static void setCallbackYesNoPopupYcp( storage::CallbackYesNoPopup pfnc )
00349 { yesno_popup_cb_ycp=pfnc; }
00350 static storage::CallbackYesNoPopup getCallbackYesNoPopupYcp()
00351 { return yesno_popup_cb_ycp; }
00352
00353 storage::CallbackProgressBar getCallbackProgressBarTheOne() const
00354 { return progress_bar_cb ? progress_bar_cb : progress_bar_cb_ycp; }
00355 storage::CallbackShowInstallInfo getCallbackShowInstallInfoTheOne() const
00356 { return install_info_cb ? install_info_cb : install_info_cb_ycp; }
00357 storage::CallbackInfoPopup getCallbackInfoPopupTheOne() const
00358 { return info_popup_cb ? info_popup_cb : info_popup_cb_ycp; }
00359 storage::CallbackYesNoPopup getCallbackYesNoPopupTheOne() const
00360 { return yesno_popup_cb ? yesno_popup_cb : yesno_popup_cb_ycp; }
00361
00362 void progressBarCb( const string& id, unsigned cur, unsigned max );
00363 void showInfoCb( const string& info );
00364 void infoPopupCb( const string& info );
00365 bool yesnoPopupCb( const string& info );
00366
00367
00368 protected:
00369
00370 template< class Pred >
00371 struct ConstContainerPI { typedef ContainerIter<Pred, CCIter> type; };
00372 typedef CheckFnc<const Container> CheckFncCont;
00373 typedef CheckerIterator< CheckFncCont, ConstContainerPI<CheckFncCont>::type,
00374 CCIter, Container > ConstContPIterator;
00375 template< class Pred >
00376 struct ContainerPI { typedef ContainerIter<Pred, CIter> type; };
00377 template< class Pred >
00378 struct ContainerI
00379 { typedef ContainerDerIter<Pred, typename ContainerPI<Pred>::type,
00380 Container> type; };
00381 typedef CheckerIterator< CheckFncCont, ContainerPI<CheckFncCont>::type,
00382 CIter, Container > ContPIterator;
00383 typedef DerefIterator<ContPIterator,Container> ContIterator;
00384 typedef IterPair<ContIterator> CPair;
00385
00386 public:
00387
00388 template< class Pred >
00389 struct ConstContainerI
00390 { typedef ContainerDerIter<Pred, typename ConstContainerPI<Pred>::type,
00391 const Container> type; };
00392 template< class Pred >
00393 struct ContCondIPair { typedef MakeCondIterPair<Pred,
00394 typename ConstContainerI<Pred>::type> type;};
00395 typedef DerefIterator<ConstContPIterator,const Container> ConstContIterator;
00396 typedef IterPair<ConstContIterator> ConstContPair;
00397
00398
00399 ConstContPair contPair( bool (* CheckFnc)( const Container& )=NULL ) const
00400 {
00401 return( ConstContPair( contBegin( CheckFnc ), contEnd( CheckFnc ) ));
00402 }
00403 ConstContIterator contBegin( bool (* CheckFnc)( const Container& )=NULL ) const
00404 {
00405 return( ConstContIterator( ConstContPIterator( cont.begin(), cont.end(), CheckFnc )) );
00406 }
00407 ConstContIterator contEnd( bool (* CheckFnc)( const Container& )=NULL ) const
00408 {
00409 return( ConstContIterator( ConstContPIterator( cont.begin(), cont.end(), CheckFnc, true )) );
00410 }
00411 template< class Pred > typename ContCondIPair<Pred>::type contCondPair( const Pred& p ) const
00412 {
00413 return( typename ContCondIPair<Pred>::type( contCondBegin( p ), contCondEnd( p ) ) );
00414 }
00415 template< class Pred > typename ConstContainerI<Pred>::type contCondBegin( const Pred& p ) const
00416 {
00417 return( typename ConstContainerI<Pred>::type( typename ConstContainerPI<Pred>::type( cont.begin(), cont.end(), p )) );
00418 }
00419 template< class Pred > typename ConstContainerI<Pred>::type contCondEnd( const Pred& p ) const
00420 {
00421 return( typename ConstContainerI<Pred>::type( typename ConstContainerPI<Pred>::type( cont.begin(), cont.end(), p, true )) );
00422 }
00423 protected:
00424
00425 CPair cPair( bool (* CheckFnc)( const Container& )=NULL )
00426 {
00427 return( CPair( cBegin(CheckFnc), cEnd(CheckFnc) ));
00428 }
00429 ContIterator cBegin( bool (* CheckFnc)( const Container& )=NULL )
00430 {
00431 return( ContIterator( ContPIterator( cont.begin(), cont.end(), CheckFnc )) );
00432 }
00433 ContIterator cEnd( bool (* CheckFnc)( const Container& )=NULL )
00434 {
00435 return( ContIterator( ContPIterator( cont.begin(), cont.end(), CheckFnc, true )) );
00436 }
00437
00438
00439 protected:
00440
00441 typedef CastCheckIterator<CCIter, storage::DISK, const Disk *> ContainerCDiskIter;
00442 template< class Pred >
00443 struct ConstDiskPI { typedef ContainerIter<Pred, ContainerCDiskIter> type; };
00444 typedef CastCheckIterator<CIter, storage::DISK, Disk *> ContainerDiskIter;
00445 template< class Pred >
00446 struct DiskPI { typedef ContainerIter<Pred, ContainerDiskIter> type; };
00447 template< class Pred >
00448 struct DiskI { typedef ContainerDerIter<Pred, typename DiskPI<Pred>::type, Disk> type; };
00449 typedef CheckFnc<const Disk> CheckFncDisk;
00450 typedef CheckerIterator< CheckFncDisk, ConstDiskPI<CheckFncDisk>::type,
00451 ContainerCDiskIter, Disk > ConstDiskPIterator;
00452 typedef CheckerIterator< CheckFncDisk, DiskPI<CheckFncDisk>::type,
00453 ContainerDiskIter, Disk > DiskPIterator;
00454 typedef DerefIterator<DiskPIterator,Disk> DiskIterator;
00455 typedef IterPair<DiskIterator> DiskPair;
00456
00457 public:
00458
00459 typedef DerefIterator<ConstDiskPIterator,const Disk> ConstDiskIterator;
00460 template< class Pred >
00461 struct ConstDiskI
00462 { typedef ContainerDerIter<Pred, typename ConstDiskPI<Pred>::type,
00463 const Disk> type; };
00464 template< class Pred >
00465 struct DiskCondIPair { typedef MakeCondIterPair<Pred, typename ConstDiskI<Pred>::type> type; };
00466 typedef IterPair<ConstDiskIterator> ConstDiskPair;
00467
00468
00469 ConstDiskPair diskPair( bool (* CheckFnc)( const Disk& )=NULL ) const
00470 {
00471 return( ConstDiskPair( diskBegin( CheckFnc ), diskEnd( CheckFnc ) ));
00472 }
00473 ConstDiskIterator diskBegin( bool (* CheckFnc)( const Disk& )=NULL ) const
00474 {
00475 IterPair<ContainerCDiskIter> p( ContainerCDiskIter( cont.begin(), cont.end() ),
00476 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00477 return( ConstDiskIterator( ConstDiskPIterator( p, CheckFnc )) );
00478 }
00479 ConstDiskIterator diskEnd( bool (* CheckFnc)( const Disk& )=NULL ) const
00480 {
00481 IterPair<ContainerCDiskIter> p( ContainerCDiskIter( cont.begin(), cont.end() ),
00482 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00483 return( ConstDiskIterator( ConstDiskPIterator( p, CheckFnc, true )) );
00484 }
00485 template< class Pred > typename DiskCondIPair<Pred>::type diskCondPair( const Pred& p ) const
00486 {
00487 return( typename DiskCondIPair<Pred>::type( diskCondBegin( p ), diskCondEnd( p ) ) );
00488 }
00489 template< class Pred > typename ConstDiskI<Pred>::type diskCondBegin( const Pred& p ) const
00490 {
00491 IterPair<ContainerCDiskIter> pair( ContainerCDiskIter( cont.begin(), cont.end() ),
00492 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00493 return( typename ConstDiskI<Pred>::type( typename ConstDiskPI<Pred>::type( pair, p )) );
00494 }
00495 template< class Pred > typename ConstDiskI<Pred>::type diskCondEnd( const Pred& p ) const
00496 {
00497 IterPair<ContainerCDiskIter> pair( ContainerCDiskIter( cont.begin(), cont.end() ),
00498 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00499 return( typename ConstDiskI<Pred>::type( typename ConstDiskPI<Pred>::type( pair, p, true )) );
00500 }
00501 protected:
00502
00503 DiskPair dPair( bool (* CheckFnc)( const Disk& )=NULL )
00504 {
00505 return( DiskPair( dBegin( CheckFnc ), dEnd( CheckFnc ) ));
00506 }
00507 DiskIterator dBegin( bool (* CheckFnc)( const Disk& )=NULL )
00508 {
00509 IterPair<ContainerDiskIter> p( ContainerDiskIter( cont.begin(), cont.end() ),
00510 ContainerDiskIter( cont.begin(), cont.end(), true ));
00511 return( DiskIterator( DiskPIterator( p, CheckFnc )) );
00512 }
00513 DiskIterator dEnd( bool (* CheckFnc)( const Disk& )=NULL )
00514 {
00515 IterPair<ContainerDiskIter> p( ContainerDiskIter( cont.begin(), cont.end() ),
00516 ContainerDiskIter( cont.begin(), cont.end(), true ));
00517 return( DiskIterator( DiskPIterator( p, CheckFnc, true )) );
00518 }
00519
00520
00521
00522 protected:
00523
00524 typedef CastCheckIterator<CCIter, storage::LVM, const LvmVg *> ContainerCLvmVgIter;
00525 template< class Pred >
00526 struct ConstLvmVgPI { typedef ContainerIter<Pred, ContainerCLvmVgIter> type; };
00527 typedef CastCheckIterator<CIter, storage::LVM, LvmVg *> ContainerLvmVgIter;
00528 template< class Pred >
00529 struct LvmVgPI { typedef ContainerIter<Pred, ContainerLvmVgIter> type; };
00530 template< class Pred >
00531 struct LvmVgI { typedef ContainerDerIter<Pred, typename LvmVgPI<Pred>::type, LvmVg> type; };
00532 typedef CheckFnc<const LvmVg> CheckFncLvmVg;
00533 typedef CheckerIterator< CheckFncLvmVg, ConstLvmVgPI<CheckFncLvmVg>::type,
00534 ContainerCLvmVgIter, LvmVg > ConstLvmVgPIterator;
00535 typedef CheckerIterator< CheckFncLvmVg, LvmVgPI<CheckFncLvmVg>::type,
00536 ContainerLvmVgIter, LvmVg > LvmVgPIterator;
00537 typedef DerefIterator<LvmVgPIterator,LvmVg> LvmVgIterator;
00538 typedef IterPair<LvmVgIterator> LvmVgPair;
00539
00540 public:
00541
00542 typedef DerefIterator<ConstLvmVgPIterator,const LvmVg> ConstLvmVgIterator;
00543 template< class Pred >
00544 struct ConstLvmVgI
00545 { typedef ContainerDerIter<Pred, typename ConstLvmVgPI<Pred>::type,
00546 const LvmVg> type; };
00547 template< class Pred >
00548 struct LvmVgCondIPair { typedef MakeCondIterPair<Pred, typename ConstLvmVgI<Pred>::type> type; };
00549 typedef IterPair<ConstLvmVgIterator> ConstLvmVgPair;
00550
00551
00552 ConstLvmVgPair lvmVgPair( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00553 {
00554 return( ConstLvmVgPair( lvmVgBegin( CheckFnc ), lvmVgEnd( CheckFnc ) ));
00555 }
00556 ConstLvmVgIterator lvmVgBegin( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00557 {
00558 IterPair<ContainerCLvmVgIter> p( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00559 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00560 return( ConstLvmVgIterator( ConstLvmVgPIterator( p, CheckFnc )) );
00561 }
00562 ConstLvmVgIterator lvmVgEnd( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00563 {
00564 IterPair<ContainerCLvmVgIter> p( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00565 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00566 return( ConstLvmVgIterator( ConstLvmVgPIterator( p, CheckFnc, true )) );
00567 }
00568 template< class Pred > typename LvmVgCondIPair<Pred>::type lvmVgCondPair( const Pred& p ) const
00569 {
00570 return( typename LvmVgCondIPair<Pred>::type( lvmVgCondBegin( p ), lvmVgCondEnd( p ) ) );
00571 }
00572 template< class Pred > typename ConstLvmVgI<Pred>::type lvmVgCondBegin( const Pred& p ) const
00573 {
00574 IterPair<ContainerCLvmVgIter> pair( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00575 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00576 return( typename ConstLvmVgI<Pred>::type( typename ConstLvmVgPI<Pred>::type( pair, p )) );
00577 }
00578 template< class Pred > typename ConstLvmVgI<Pred>::type lvmVgCondEnd( const Pred& p ) const
00579 {
00580 IterPair<ContainerCLvmVgIter> pair( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00581 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00582 return( typename ConstLvmVgI<Pred>::type( typename ConstLvmVgPI<Pred>::type( pair, p, true )) );
00583 }
00584 protected:
00585
00586 LvmVgPair lvgPair( bool (* CheckFnc)( const LvmVg& )=NULL )
00587 {
00588 return( LvmVgPair( lvgBegin( CheckFnc ), lvgEnd( CheckFnc ) ));
00589 }
00590 LvmVgIterator lvgBegin( bool (* CheckFnc)( const LvmVg& )=NULL )
00591 {
00592 IterPair<ContainerLvmVgIter> p( ContainerLvmVgIter( cont.begin(), cont.end() ),
00593 ContainerLvmVgIter( cont.begin(), cont.end(), true ));
00594 return( LvmVgIterator( LvmVgPIterator( p, CheckFnc )) );
00595 }
00596 LvmVgIterator lvgEnd( bool (* CheckFnc)( const LvmVg& )=NULL )
00597 {
00598 IterPair<ContainerLvmVgIter> p( ContainerLvmVgIter( cont.begin(), cont.end() ),
00599 ContainerLvmVgIter( cont.begin(), cont.end(), true ));
00600 return( LvmVgIterator( LvmVgPIterator( p, CheckFnc, true )) );
00601 }
00602
00603
00604 protected:
00605
00606 typedef CastCheckIterator<CCIter, storage::EVMS, const EvmsCo *> ContainerCEvmsIter;
00607 template< class Pred >
00608 struct ConstEvmsCoPI { typedef ContainerIter<Pred, ContainerCEvmsIter> type; };
00609 typedef CastCheckIterator<CIter, storage::EVMS, EvmsCo *> ContainerEvmsIter;
00610 template< class Pred >
00611 struct EvmsCoPI { typedef ContainerIter<Pred, ContainerEvmsIter> type; };
00612 template< class Pred >
00613 struct EvmsCoI { typedef ContainerDerIter<Pred, typename EvmsCoPI<Pred>::type, EvmsCo> type; };
00614 typedef CheckFnc<const EvmsCo> CheckFncEvmsCo;
00615 typedef CheckerIterator< CheckFncEvmsCo, ConstEvmsCoPI<CheckFncEvmsCo>::type,
00616 ContainerCEvmsIter, EvmsCo > ConstEvmsCoPIterator;
00617 typedef CheckerIterator< CheckFncEvmsCo, EvmsCoPI<CheckFncEvmsCo>::type,
00618 ContainerEvmsIter, EvmsCo > EvmsCoPIterator;
00619 typedef DerefIterator<EvmsCoPIterator,EvmsCo> EvmsCoIterator;
00620 typedef IterPair<EvmsCoIterator> EvmsCoPair;
00621
00622 public:
00623
00624 typedef DerefIterator<ConstEvmsCoPIterator,const EvmsCo> ConstEvmsCoIterator;
00625 template< class Pred >
00626 struct ConstEvmsCoI
00627 { typedef ContainerDerIter<Pred, typename ConstEvmsCoPI<Pred>::type,
00628 const EvmsCo> type; };
00629 template< class Pred >
00630 struct EvmsCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstEvmsCoI<Pred>::type> type; };
00631 typedef IterPair<ConstEvmsCoIterator> ConstEvmsCoPair;
00632
00633
00634 ConstEvmsCoPair evmsCoPair( bool (* CheckFnc)( const EvmsCo& )=NULL ) const
00635 {
00636 return( ConstEvmsCoPair( evmsCoBegin( CheckFnc ), evmsCoEnd( CheckFnc ) ));
00637 }
00638 ConstEvmsCoIterator evmsCoBegin( bool (* CheckFnc)( const EvmsCo& )=NULL ) const
00639 {
00640 IterPair<ContainerCEvmsIter> p( ContainerCEvmsIter( cont.begin(), cont.end() ),
00641 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00642 return( ConstEvmsCoIterator( ConstEvmsCoPIterator( p, CheckFnc )) );
00643 }
00644 ConstEvmsCoIterator evmsCoEnd( bool (* CheckFnc)( const EvmsCo& )=NULL ) const
00645 {
00646 IterPair<ContainerCEvmsIter> p( ContainerCEvmsIter( cont.begin(), cont.end() ),
00647 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00648 return( ConstEvmsCoIterator( ConstEvmsCoPIterator( p, CheckFnc, true )) );
00649 }
00650 template< class Pred > typename EvmsCoCondIPair<Pred>::type evmsCoCondPair( const Pred& p ) const
00651 {
00652 return( typename EvmsCoCondIPair<Pred>::type( evmsCoCondBegin( p ), evmsCoCondEnd( p ) ) );
00653 }
00654 template< class Pred > typename ConstEvmsCoI<Pred>::type evmsCoCondBegin( const Pred& p ) const
00655 {
00656 IterPair<ContainerCEvmsIter> pair( ContainerCEvmsIter( cont.begin(), cont.end() ),
00657 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00658 return( typename ConstEvmsCoI<Pred>::type( typename ConstEvmsCoPI<Pred>::type( pair, p )) );
00659 }
00660 template< class Pred > typename ConstEvmsCoI<Pred>::type evmsCoCondEnd( const Pred& p ) const
00661 {
00662 IterPair<ContainerCEvmsIter> pair( ContainerCEvmsIter( cont.begin(), cont.end() ),
00663 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00664 return( typename ConstEvmsCoI<Pred>::type( typename ConstEvmsCoPI<Pred>::type( pair, p, true )) );
00665 }
00666 protected:
00667
00668 EvmsCoPair evCoPair( bool (* CheckFnc)( const EvmsCo& )=NULL )
00669 {
00670 return( EvmsCoPair( evCoBegin( CheckFnc ), evCoEnd( CheckFnc ) ));
00671 }
00672 EvmsCoIterator evCoBegin( bool (* CheckFnc)( const EvmsCo& )=NULL )
00673 {
00674 IterPair<ContainerEvmsIter> p( ContainerEvmsIter( cont.begin(), cont.end() ),
00675 ContainerEvmsIter( cont.begin(), cont.end(), true ));
00676 return( EvmsCoIterator( EvmsCoPIterator( p, CheckFnc )) );
00677 }
00678 EvmsCoIterator evCoEnd( bool (* CheckFnc)( const EvmsCo& )=NULL )
00679 {
00680 IterPair<ContainerEvmsIter> p( ContainerEvmsIter( cont.begin(), cont.end() ),
00681 ContainerEvmsIter( cont.begin(), cont.end(), true ));
00682 return( EvmsCoIterator( EvmsCoPIterator( p, CheckFnc, true )) );
00683 }
00684
00685
00686 protected:
00687
00688 typedef ListListIterator<Container::ConstPlainIterator, ConstContIterator> ConstVolInter;
00689 template< class Pred >
00690 struct ConstVolumePI { typedef ContainerIter<Pred, ConstVolInter> type; };
00691 typedef CheckFnc<const Volume> CheckFncVol;
00692 typedef CheckerIterator< CheckFncVol, ConstVolumePI<CheckFncVol>::type,
00693 ConstVolInter, Volume > ConstVolPIterator;
00694 typedef ListListIterator<Container::PlainIterator, ContIterator> VolPart;
00695 template< class Pred >
00696 struct VolumeI { typedef ContainerIter<Pred, VolPart> type; };
00697 typedef CheckerIterator< CheckFncVol, VolumeI<CheckFncVol>::type,
00698 VolPart, Volume > VolPIterator;
00699 typedef DerefIterator<VolPIterator,Volume> VolIterator;
00700 typedef IterPair<VolIterator> VPair;
00701
00702 public:
00703
00704 template< class Pred >
00705 struct ConstVolumeI { typedef ContainerDerIter<Pred, typename ConstVolumePI<Pred>::type, const Volume> type; };
00706 template< class Pred >
00707 struct VolCondIPair { typedef MakeCondIterPair<Pred, typename ConstVolumeI<Pred>::type> type;};
00708 typedef DerefIterator<ConstVolPIterator,const Volume> ConstVolIterator;
00709 typedef IterPair<ConstVolIterator> ConstVolPair;
00710
00711
00712 ConstVolPair volPair( bool (* CheckCnt)( const Container& )) const
00713 {
00714 return( ConstVolPair( volBegin( CheckCnt ), volEnd( CheckCnt ) ));
00715 }
00716 ConstVolPair volPair( bool (* CheckVol)( const Volume& )=NULL,
00717 bool (* CheckCnt)( const Container& )=NULL) const
00718 {
00719 return( ConstVolPair( volBegin( CheckVol, CheckCnt ),
00720 volEnd( CheckVol, CheckCnt ) ));
00721 }
00722 ConstVolIterator volBegin( bool (* CheckCnt)( const Container& )) const
00723 {
00724 return( volBegin( NULL, CheckCnt ) );
00725 }
00726 ConstVolIterator volBegin( bool (* CheckVol)( const Volume& )=NULL,
00727 bool (* CheckCnt)( const Container& )=NULL) const
00728 {
00729 IterPair<ConstVolInter> p( (ConstVolInter( contPair( CheckCnt ))),
00730 (ConstVolInter( contPair( CheckCnt ), true )));
00731 return( ConstVolIterator( ConstVolPIterator(p, CheckVol )));
00732 }
00733 ConstVolIterator volEnd( bool (* CheckCnt)( const Container& )) const
00734 {
00735 return( volEnd( NULL, CheckCnt ) );
00736 }
00737 ConstVolIterator volEnd( bool (* CheckVol)( const Volume& )=NULL,
00738 bool (* CheckCnt)( const Container& )=NULL) const
00739 {
00740 IterPair<ConstVolInter> p( (ConstVolInter( contPair( CheckCnt ))),
00741 (ConstVolInter( contPair( CheckCnt ), true )));
00742 return( ConstVolIterator( ConstVolPIterator(p, CheckVol, true )));
00743 }
00744 template< class Pred > typename VolCondIPair<Pred>::type volCondPair( const Pred& p ) const
00745 {
00746 return( typename VolCondIPair<Pred>::type( volCondBegin( p ), volCondEnd( p ) ) );
00747 }
00748 template< class Pred > typename ConstVolumeI<Pred>::type volCondBegin( const Pred& p ) const
00749 {
00750 IterPair<ConstVolInter> pair( (ConstVolInter( contPair())),
00751 (ConstVolInter( contPair(), true )));
00752 return( typename ConstVolumeI<Pred>::type( typename ConstVolumePI<Pred>::type(pair, p) ) );
00753 }
00754 template< class Pred > typename ConstVolumeI<Pred>::type volCondEnd( const Pred& p ) const
00755 {
00756 IterPair<ConstVolInter> pair( (ConstVolInter( contPair())),
00757 (ConstVolInter( contPair(), true )));
00758 return( typename ConstVolumeI<Pred>::type( typename ConstVolumePI<Pred>::type(pair, p, true )) );
00759 }
00760
00761 protected:
00762
00763 VPair vPair( bool (* CheckCnt)( const Container& ))
00764 {
00765 return( VPair( vBegin( CheckCnt ), vEnd( CheckCnt ) ));
00766 }
00767 VPair vPair( bool (* CheckVol)( const Volume& )=NULL,
00768 bool (* CheckCnt)( const Container& )=NULL)
00769 {
00770 return( VPair( vBegin( CheckVol, CheckCnt ),
00771 vEnd( CheckVol, CheckCnt ) ));
00772 }
00773 VolIterator vBegin( bool (* CheckCnt)( const Container& ))
00774 {
00775 return( vBegin( NULL, CheckCnt ) );
00776 }
00777 VolIterator vBegin( bool (* CheckVol)( const Volume& )=NULL,
00778 bool (* CheckCnt)( const Container& )=NULL)
00779 {
00780 IterPair<VolPart> p( (VolPart( cPair( CheckCnt ))),
00781 (VolPart( cPair( CheckCnt ), true )));
00782 return( VolIterator( VolPIterator( p, CheckVol )));
00783 }
00784 VolIterator vEnd( bool (* CheckCnt)( const Container& ))
00785 {
00786 return( vEnd( NULL, CheckCnt ) );
00787 }
00788 VolIterator vEnd( bool (* CheckVol)( const Volume& )=NULL,
00789 bool (* CheckCnt)( const Container& )=NULL)
00790 {
00791 IterPair<VolPart> p( (VolPart( cPair( CheckCnt ))),
00792 (VolPart( cPair( CheckCnt ), true )));
00793 return( VolIterator( VolPIterator( p, CheckVol, true )));
00794 }
00795
00796
00797 protected:
00798
00799 typedef ListListIterator<Container::ConstPlainIterator, ConstDiskIterator> ConstPartInter;
00800 typedef CastIterator<ConstPartInter, Partition *> ConstPartInter2;
00801 template< class Pred >
00802 struct ConstPartitionPI { typedef ContainerIter<Pred, ConstPartInter2> type; };
00803 typedef CheckFnc<const Partition> CheckFncPartition;
00804 typedef CheckerIterator< CheckFncPartition, ConstPartitionPI<CheckFncPartition>::type,
00805 ConstPartInter2, Partition > ConstPartPIterator;
00806 public:
00807
00808 template< class Pred >
00809 struct ConstPartitionI
00810 { typedef ContainerDerIter<Pred, typename ConstPartitionPI<Pred>::type,
00811 const Partition> type; };
00812 template< class Pred >
00813 struct PartCondIPair
00814 { typedef MakeCondIterPair<Pred, typename ConstPartitionI<Pred>::type> type;};
00815 typedef DerefIterator<ConstPartPIterator, const Partition> ConstPartIterator;
00816 typedef IterPair<ConstPartIterator> ConstPartPair;
00817
00818
00819 ConstPartPair partPair( bool (* CheckCnt)( const Disk& )) const
00820 {
00821 return( ConstPartPair( partBegin( CheckCnt ), partEnd( CheckCnt ) ));
00822 }
00823 ConstPartPair partPair( bool (* CheckPart)( const Partition& )=NULL,
00824 bool (* CheckCnt)( const Disk& )=NULL) const
00825 {
00826 return( ConstPartPair( partBegin( CheckPart, CheckCnt ),
00827 partEnd( CheckPart, CheckCnt ) ));
00828 }
00829 ConstPartIterator partBegin( bool (* CheckDisk)( const Disk& )) const
00830 {
00831 return( partBegin( NULL, CheckDisk ) );
00832 }
00833 ConstPartIterator partBegin( bool (* CheckPart)( const Partition& )=NULL,
00834 bool (* CheckDisk)( const Disk& )=NULL) const
00835 {
00836 IterPair<ConstPartInter2> p( (ConstPartInter(diskPair( CheckDisk ))),
00837 (ConstPartInter(diskPair( CheckDisk ), true )));
00838 return( ConstPartIterator( ConstPartPIterator(p, CheckPart )));
00839 }
00840 ConstPartIterator partEnd( bool (* CheckDisk)( const Disk& )) const
00841 {
00842 return( partEnd( NULL, CheckDisk ) );
00843 }
00844 ConstPartIterator partEnd( bool (* CheckPart)( const Partition& )=NULL,
00845 bool (* CheckDisk)( const Disk& )=NULL) const
00846 {
00847 IterPair<ConstPartInter2> p( (ConstPartInter(diskPair( CheckDisk ))),
00848 (ConstPartInter(diskPair( CheckDisk ), true )));
00849 return( ConstPartIterator( ConstPartPIterator(p, CheckPart, true )));
00850 }
00851 template< class Pred > typename PartCondIPair<Pred>::type partCondPair( const Pred& p ) const
00852 {
00853 return( typename PartCondIPair<Pred>::type( partCondBegin( p ), partCondEnd( p ) ) );
00854 }
00855 template< class Pred > typename ConstPartitionI<Pred>::type partCondBegin( const Pred& p ) const
00856 {
00857 IterPair<ConstPartInter2> pair( (ConstPartInter( diskPair())),
00858 (ConstPartInter( diskPair(), true )));
00859 return( typename ConstPartitionI<Pred>::type( typename ConstPartitionPI<Pred>::type(pair, p) ) );
00860 }
00861 template< class Pred > typename ConstPartitionI<Pred>::type partCondEnd( const Pred& p ) const
00862 {
00863 IterPair<ConstPartInter2> pair( (ConstPartInter( diskPair())),
00864 (ConstPartInter( diskPair(), true )));
00865 return( typename ConstPartitionI<Pred>::type( typename ConstPartitionPI<Pred>::type(pair, p, true )) );
00866 }
00867
00868
00869 protected:
00870
00871 typedef ListListIterator<Container::ConstPlainIterator, ConstLvmVgIterator> ConstLvmLvInter;
00872 typedef CastIterator<ConstLvmLvInter, LvmLv *> ConstLvmLvInter2;
00873 template< class Pred >
00874 struct ConstLvmLvPI { typedef ContainerIter<Pred, ConstLvmLvInter2> type; };
00875 typedef CheckFnc<const LvmLv> CheckFncLvmLv;
00876 typedef CheckerIterator< CheckFncLvmLv, ConstLvmLvPI<CheckFncLvmLv>::type,
00877 ConstLvmLvInter2, LvmLv > ConstLvmLvPIterator;
00878 public:
00879
00880 template< class Pred >
00881 struct ConstLvmLvI
00882 { typedef ContainerDerIter<Pred, typename ConstLvmLvPI<Pred>::type,
00883 const LvmLv> type; };
00884 template< class Pred >
00885 struct LvmLvCondIPair
00886 { typedef MakeCondIterPair<Pred, typename ConstLvmLvI<Pred>::type> type;};
00887 typedef DerefIterator<ConstLvmLvPIterator, const LvmLv> ConstLvmLvIterator;
00888 typedef IterPair<ConstLvmLvIterator> ConstLvmLvPair;
00889
00890
00891 ConstLvmLvPair lvmLvPair( bool (* CheckLvmVg)( const LvmVg& )) const
00892 {
00893 return( ConstLvmLvPair( lvmLvBegin( CheckLvmVg ), lvmLvEnd( CheckLvmVg ) ));
00894 }
00895 ConstLvmLvPair lvmLvPair( bool (* CheckLvmLv)( const LvmLv& )=NULL,
00896 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
00897 {
00898 return( ConstLvmLvPair( lvmLvBegin( CheckLvmLv, CheckLvmVg ),
00899 lvmLvEnd( CheckLvmLv, CheckLvmVg ) ));
00900 }
00901 ConstLvmLvIterator lvmLvBegin( bool (* CheckLvmVg)( const LvmVg& )) const
00902 {
00903 return( lvmLvBegin( NULL, CheckLvmVg ) );
00904 }
00905 ConstLvmLvIterator lvmLvBegin( bool (* CheckLvmLv)( const LvmLv& )=NULL,
00906 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
00907 {
00908 IterPair<ConstLvmLvInter2> p( (ConstLvmLvInter(lvmVgPair( CheckLvmVg ))),
00909 (ConstLvmLvInter(lvmVgPair( CheckLvmVg ), true )));
00910 return( ConstLvmLvIterator( ConstLvmLvPIterator(p, CheckLvmLv )));
00911 }
00912 ConstLvmLvIterator lvmLvEnd( bool (* CheckLvmVg)( const LvmVg& )) const
00913 {
00914 return( lvmLvEnd( NULL, CheckLvmVg ) );
00915 }
00916 ConstLvmLvIterator lvmLvEnd( bool (* CheckLvmLv)( const LvmLv& )=NULL,
00917 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
00918 {
00919 IterPair<ConstLvmLvInter2> p( (ConstLvmLvInter(lvmVgPair( CheckLvmVg ))),
00920 (ConstLvmLvInter(lvmVgPair( CheckLvmVg ), true )));
00921 return( ConstLvmLvIterator( ConstLvmLvPIterator(p, CheckLvmLv, true )));
00922 }
00923 template< class Pred > typename LvmLvCondIPair<Pred>::type lvmLvCondPair( const Pred& p ) const
00924 {
00925 return( typename LvmLvCondIPair<Pred>::type( lvmLvCondBegin( p ), lvmLvCondEnd( p ) ) );
00926 }
00927 template< class Pred > typename ConstLvmLvI<Pred>::type lvmLvCondBegin( const Pred& p ) const
00928 {
00929 IterPair<ConstLvmLvInter2> pair( (ConstLvmLvInter( lvmVgPair())),
00930 (ConstLvmLvInter( lvmVgPair(), true )));
00931 return( typename ConstLvmLvI<Pred>::type( typename ConstLvmLvPI<Pred>::type(pair, p) ) );
00932 }
00933 template< class Pred > typename ConstLvmLvI<Pred>::type lvmLvCondEnd( const Pred& p ) const
00934 {
00935 IterPair<ConstLvmLvInter2> pair( (ConstLvmLvInter( lvmVgPair())),
00936 (ConstLvmLvInter( lvmVgPair(), true )));
00937 return( typename ConstLvmLvI<Pred>::type( typename ConstLvmLvPI<Pred>::type(pair, p, true )) );
00938 }
00939
00940
00941 protected:
00942
00943 typedef ListListIterator<Container::ConstPlainIterator, ConstEvmsCoIterator> ConstEvmsInter;
00944 typedef CastIterator<ConstEvmsInter, Evms *> ConstEvmsInter2;
00945 template< class Pred >
00946 struct ConstEvmsPI { typedef ContainerIter<Pred, ConstEvmsInter2> type; };
00947 typedef CheckFnc<const Evms> CheckFncEvms;
00948 typedef CheckerIterator< CheckFncEvms, ConstEvmsPI<CheckFncEvms>::type,
00949 ConstEvmsInter2, Evms > ConstEvmsPIterator;
00950 public:
00951
00952 template< class Pred >
00953 struct ConstEvmsI
00954 { typedef ContainerDerIter<Pred, typename ConstEvmsPI<Pred>::type,
00955 const Evms> type; };
00956 template< class Pred >
00957 struct EvmsCondIPair
00958 { typedef MakeCondIterPair<Pred, typename ConstEvmsI<Pred>::type> type;};
00959 typedef DerefIterator<ConstEvmsPIterator, const Evms> ConstEvmsIterator;
00960 typedef IterPair<ConstEvmsIterator> ConstEvmsPair;
00961
00962
00963 ConstEvmsPair evmsPair( bool (* CheckEvmsCo)( const EvmsCo& )) const
00964 {
00965 return( ConstEvmsPair( evmsBegin( CheckEvmsCo ), evmsEnd( CheckEvmsCo ) ));
00966 }
00967 ConstEvmsPair evmsPair( bool (* CheckEvms)( const Evms& )=NULL,
00968 bool (* CheckEvmsCo)( const EvmsCo& )=NULL) const
00969 {
00970 return( ConstEvmsPair( evmsBegin( CheckEvms, CheckEvmsCo ),
00971 evmsEnd( CheckEvms, CheckEvmsCo ) ));
00972 }
00973 ConstEvmsIterator evmsBegin( bool (* CheckEvmsCo)( const EvmsCo& )) const
00974 {
00975 return( evmsBegin( NULL, CheckEvmsCo ) );
00976 }
00977 ConstEvmsIterator evmsBegin( bool (* CheckEvms)( const Evms& )=NULL,
00978 bool (* CheckEvmsCo)( const EvmsCo& )=NULL) const
00979 {
00980 IterPair<ConstEvmsInter2> p( (ConstEvmsInter(evmsCoPair( CheckEvmsCo ))),
00981 (ConstEvmsInter(evmsCoPair( CheckEvmsCo ), true )));
00982 return( ConstEvmsIterator( ConstEvmsPIterator(p, CheckEvms )));
00983 }
00984 ConstEvmsIterator evmsEnd( bool (* CheckEvmsCo)( const EvmsCo& )) const
00985 {
00986 return( evmsEnd( NULL, CheckEvmsCo ) );
00987 }
00988 ConstEvmsIterator evmsEnd( bool (* CheckEvms)( const Evms& )=NULL,
00989 bool (* CheckEvmsCo)( const EvmsCo& )=NULL) const
00990 {
00991 IterPair<ConstEvmsInter2> p( (ConstEvmsInter(evmsCoPair( CheckEvmsCo ))),
00992 (ConstEvmsInter(evmsCoPair( CheckEvmsCo ), true )));
00993 return( ConstEvmsIterator( ConstEvmsPIterator(p, CheckEvms, true )));
00994 }
00995 template< class Pred > typename EvmsCondIPair<Pred>::type evmsCondPair( const Pred& p ) const
00996 {
00997 return( typename EvmsCondIPair<Pred>::type( evmsCondBegin( p ), evmsCondEnd( p ) ) );
00998 }
00999 template< class Pred > typename ConstEvmsI<Pred>::type evmsCondBegin( const Pred& p ) const
01000 {
01001 IterPair<ConstEvmsInter2> pair( (ConstEvmsInter( evmsCoPair())),
01002 (ConstEvmsInter( evmsCoPair(), true )));
01003 return( typename ConstEvmsI<Pred>::type( typename ConstEvmsPI<Pred>::type(pair, p) ) );
01004 }
01005 template< class Pred > typename ConstEvmsI<Pred>::type evmsCondEnd( const Pred& p ) const
01006 {
01007 IterPair<ConstEvmsInter2> pair( (ConstEvmsInter( evmsCoPair())),
01008 (ConstEvmsInter( evmsCoPair(), true )));
01009 return( typename ConstEvmsI<Pred>::type( typename ConstEvmsPI<Pred>::type(pair, p, true )) );
01010 }
01011
01012
01013 protected:
01014
01015 typedef CastIterator<ConstVolInter, Md *> ConstMdInter;
01016 template< class Pred >
01017 struct ConstMdPI { typedef ContainerIter<Pred,
01018 ConstMdInter> type; };
01019 typedef CheckFnc<const Md> CheckFncMd;
01020 typedef CheckerIterator< CheckFncMd, ConstMdPI<CheckFncMd>::type,
01021 ConstMdInter, Md > ConstMdPIterator;
01022 public:
01023
01024 template< class Pred >
01025 struct ConstMdI
01026 { typedef ContainerDerIter<Pred, typename ConstMdPI<Pred>::type,
01027 const Md> type; };
01028 template< class Pred >
01029 struct MdCondIPair
01030 { typedef MakeCondIterPair<Pred, typename ConstMdI<Pred>::type> type;};
01031 typedef DerefIterator<ConstMdPIterator, const Md> ConstMdIterator;
01032 typedef IterPair<ConstMdIterator> ConstMdPair;
01033
01034
01035 ConstMdPair mdPair( bool (* CheckMd)( const Md& )=NULL ) const
01036 {
01037 return( ConstMdPair( mdBegin( CheckMd ), mdEnd( CheckMd ) ));
01038 }
01039 ConstMdIterator mdBegin( bool (* CheckMd)( const Md& )=NULL ) const
01040 {
01041 ConstVolInter b( contPair( isMd ) );
01042 ConstVolInter e( contPair( isMd ), true );
01043 IterPair<ConstMdInter> p( (ConstMdInter(b)), (ConstMdInter(e)) );
01044 return( ConstMdIterator( ConstMdPIterator(p, CheckMd )));
01045 }
01046 ConstMdIterator mdEnd( bool (* CheckMd)( const Md& )=NULL ) const
01047 {
01048 ConstVolInter b( contPair( isMd ) );
01049 ConstVolInter e( contPair( isMd ), true );
01050 IterPair<ConstMdInter> p( (ConstMdInter(b)), (ConstMdInter(e)) );
01051 return( ConstMdIterator( ConstMdPIterator(p, CheckMd, true )));
01052 }
01053 template< class Pred > typename MdCondIPair<Pred>::type mdCondPair( const Pred& p ) const
01054 {
01055 return( typename MdCondIPair<Pred>::type( mdCondBegin( p ), mdCondEnd( p ) ) );
01056 }
01057 template< class Pred > typename ConstMdI<Pred>::type mdCondBegin( const Pred& p ) const
01058 {
01059 ConstVolInter b( contPair( isMd ) );
01060 ConstVolInter e( contPair( isMd ), true );
01061 IterPair<ConstMdInter> pair( (ConstMdInter(b)), (ConstMdInter(e)) );
01062 return( typename ConstMdI<Pred>::type( typename ConstMdPI<Pred>::type(pair, p) ) );
01063 }
01064 template< class Pred > typename ConstMdI<Pred>::type mdCondEnd( const Pred& p ) const
01065 {
01066 ConstVolInter b( contPair( isMd ) );
01067 ConstVolInter e( contPair( isMd ), true );
01068 IterPair<ConstMdInter> pair( (ConstMdInter(b)), (ConstMdInter(e)) );
01069 return( typename ConstMdI<Pred>::type( typename ConstMdPI<Pred>::type(pair, p, true )) );
01070 }
01071
01072
01073 protected:
01074
01075 typedef CastIterator<ConstVolInter, Loop *> ConstLoopInter;
01076 template< class Pred >
01077 struct ConstLoopPI { typedef ContainerIter<Pred,
01078 ConstLoopInter> type; };
01079 typedef CheckFnc<const Loop> CheckFncLoop;
01080 typedef CheckerIterator< CheckFncLoop, ConstLoopPI<CheckFncLoop>::type,
01081 ConstLoopInter, Loop > ConstLoopPIterator;
01082 public:
01083
01084 template< class Pred >
01085 struct ConstLoopI
01086 { typedef ContainerDerIter<Pred, typename ConstLoopPI<Pred>::type,
01087 const Loop> type; };
01088 template< class Pred >
01089 struct LoopCondIPair
01090 { typedef MakeCondIterPair<Pred, typename ConstLoopI<Pred>::type> type;};
01091 typedef DerefIterator<ConstLoopPIterator, const Loop> ConstLoopIterator;
01092 typedef IterPair<ConstLoopIterator> ConstLoopPair;
01093
01094
01095 ConstLoopPair loopPair( bool (* CheckLoop)( const Loop& )=NULL ) const
01096 {
01097 return( ConstLoopPair( loopBegin( CheckLoop ), loopEnd( CheckLoop ) ));
01098 }
01099 ConstLoopIterator loopBegin( bool (* CheckLoop)( const Loop& )=NULL ) const
01100 {
01101 ConstVolInter b( contPair( isLoop ) );
01102 ConstVolInter e( contPair( isLoop ), true );
01103 IterPair<ConstLoopInter> p( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01104 return( ConstLoopIterator( ConstLoopPIterator(p, CheckLoop )));
01105 }
01106 ConstLoopIterator loopEnd( bool (* CheckLoop)( const Loop& )=NULL ) const
01107 {
01108 ConstVolInter b( contPair( isLoop ) );
01109 ConstVolInter e( contPair( isLoop ), true );
01110 IterPair<ConstLoopInter> p( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01111 return( ConstLoopIterator( ConstLoopPIterator(p, CheckLoop, true )));
01112 }
01113 template< class Pred > typename LoopCondIPair<Pred>::type loopCondPair( const Pred& p ) const
01114 {
01115 return( typename LoopCondIPair<Pred>::type( loopCondBegin( p ), loopCondEnd( p ) ) );
01116 }
01117 template< class Pred > typename ConstLoopI<Pred>::type loopCondBegin( const Pred& p ) const
01118 {
01119 ConstVolInter b( contPair( isLoop ) );
01120 ConstVolInter e( contPair( isLoop ), true );
01121 IterPair<ConstLoopInter> pair( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01122 return( typename ConstLoopI<Pred>::type( typename ConstLoopPI<Pred>::type(pair, p) ) );
01123 }
01124 template< class Pred > typename ConstLoopI<Pred>::type loopCondEnd( const Pred& p ) const
01125 {
01126 ConstVolInter b( contPair( isLoop ) );
01127 ConstVolInter e( contPair( isLoop ), true );
01128 IterPair<ConstLoopInter> pair( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01129 return( typename ConstLoopI<Pred>::type( typename ConstLoopPI<Pred>::type(pair, p, true )) );
01130 }
01131
01132
01133 protected:
01134
01135 typedef CastIterator<ConstVolInter, Dm *> ConstDmInter;
01136 template< class Pred >
01137 struct ConstDmPI { typedef ContainerIter<Pred,
01138 ConstDmInter> type; };
01139 typedef CheckFnc<const Dm> CheckFncDm;
01140 typedef CheckerIterator< CheckFncDm, ConstDmPI<CheckFncDm>::type,
01141 ConstDmInter, Dm > ConstDmPIterator;
01142 public:
01143
01144 template< class Pred >
01145 struct ConstDmI
01146 { typedef ContainerDerIter<Pred, typename ConstDmPI<Pred>::type,
01147 const Dm> type; };
01148 template< class Pred >
01149 struct DmCondIPair
01150 { typedef MakeCondIterPair<Pred, typename ConstDmI<Pred>::type> type;};
01151 typedef DerefIterator<ConstDmPIterator, const Dm> ConstDmIterator;
01152 typedef IterPair<ConstDmIterator> ConstDmPair;
01153
01154
01155 ConstDmPair dmPair( bool (* CheckDm)( const Dm& )=NULL ) const
01156 {
01157 return( ConstDmPair( dmBegin( CheckDm ), dmEnd( CheckDm ) ));
01158 }
01159 ConstDmIterator dmBegin( bool (* CheckDm)( const Dm& )=NULL ) const
01160 {
01161 ConstVolInter b( contPair( isDm ) );
01162 ConstVolInter e( contPair( isDm ), true );
01163 IterPair<ConstDmInter> p( (ConstDmInter(b)), (ConstDmInter(e)) );
01164 return( ConstDmIterator( ConstDmPIterator(p, CheckDm )));
01165 }
01166 ConstDmIterator dmEnd( bool (* CheckDm)( const Dm& )=NULL ) const
01167 {
01168 ConstVolInter b( contPair( isDm ) );
01169 ConstVolInter e( contPair( isDm ), true );
01170 IterPair<ConstDmInter> p( (ConstDmInter(b)), (ConstDmInter(e)) );
01171 return( ConstDmIterator( ConstDmPIterator(p, CheckDm, true )));
01172 }
01173 template< class Pred > typename DmCondIPair<Pred>::type dmCondPair( const Pred& p ) const
01174 {
01175 return( typename DmCondIPair<Pred>::type( dmCondBegin( p ), dmCondEnd( p ) ) );
01176 }
01177 template< class Pred > typename ConstDmI<Pred>::type dmCondBegin( const Pred& p ) const
01178 {
01179 ConstVolInter b( contPair( isDm ) );
01180 ConstVolInter e( contPair( isDm ), true );
01181 IterPair<ConstDmInter> pair( (ConstDmInter(b)), (ConstDmInter(e)) );
01182 return( typename ConstDmI<Pred>::type( typename ConstDmPI<Pred>::type(pair, p) ) );
01183 }
01184 template< class Pred > typename ConstDmI<Pred>::type dmCondEnd( const Pred& p ) const
01185 {
01186 ConstVolInter b( contPair( isDm ) );
01187 ConstVolInter e( contPair( isDm ), true );
01188 IterPair<ConstDmInter> pair( (ConstDmInter(b)), (ConstDmInter(e)) );
01189 return( typename ConstDmI<Pred>::type( typename ConstDmPI<Pred>::type(pair, p, true )) );
01190 }
01191
01192 protected:
01193
01194 void initialize();
01195 void detectDisks();
01196 void detectMds();
01197 void detectLoops();
01198 void detectLvmVgs();
01199 void detectEvms();
01200 void detectDm();
01201 void autodetectDisks();
01202 void detectFsData( const VolIterator& begin, const VolIterator& end );
01203 void detectFsDataTestMode( const string& file,
01204 const VolIterator& begin,
01205 const VolIterator& end );
01206 static void detectArch();
01207 void addToList( Container* e )
01208 { pointerIntoSortedList<Container>( cont, e ); }
01209 DiskIterator findDisk( const string& disk );
01210 LvmVgIterator findLvmVg( const string& name );
01211 EvmsCoIterator findEvmsCo( const string& name );
01212 bool findVolume( const string& device, ContIterator& c,
01213 VolIterator& v );
01214
01215 bool haveMd( MdCo*& md );
01216 bool haveLoop( LoopCo*& loop );
01217 bool findVolume( const string& device, VolIterator& v );
01218
01219 int removeContainer( Container* val );
01220 void logVolumes( const string& Dir );
01221 int commitPair( CPair& p, bool (* fnc)( const Container& ) );
01222 void sortCommitLists( storage::CommitStage stage,
01223 std::list<Container*>& co,
01224 std::list<Volume*>& vl );
01225 int performContChanges( storage::CommitStage stage,
01226 const std::list<Container*>& co,
01227 bool& cont_removed );
01228 string backupStates() const;
01229 void detectObjects();
01230 void deleteClist( CCont& co );
01231 void deleteBackups();
01232 void setFreeInfo( const string& device, unsigned long long df_free,
01233 unsigned long long resize_free,
01234 unsigned long long used, bool win );
01235 bool getFreeInfo( const string& device, unsigned long long& df_free,
01236 unsigned long long& resize_free,
01237 unsigned long long& used, bool& win );
01238
01239
01240 bool readonly;
01241 bool testmode;
01242 bool inst_sys;
01243 bool cache;
01244 bool initialized;
01245 bool autodetect;
01246 bool recursiveRemove;
01247 bool zeroNewPartitions;
01248 bool detectMounted;
01249 bool root_mounted;
01250 string testdir;
01251 string tempdir;
01252 string rootprefix;
01253 string logdir;
01254 static string proc_arch;
01255 CCont cont;
01256 EtcFstab *fstab;
01257
01258 storage::CallbackProgressBar progress_bar_cb;
01259 storage::CallbackShowInstallInfo install_info_cb;
01260 storage::CallbackInfoPopup info_popup_cb;
01261 storage::CallbackYesNoPopup yesno_popup_cb;
01262 static storage::CallbackProgressBar progress_bar_cb_ycp;
01263 static storage::CallbackShowInstallInfo install_info_cb_ycp;
01264 static storage::CallbackInfoPopup info_popup_cb_ycp;
01265 static storage::CallbackYesNoPopup yesno_popup_cb_ycp;
01266
01267 unsigned max_log_num;
01268 string lastAction;
01269 string extendedError;
01270 std::map<string,CCont> backups;
01271 std::map<string,FreeInfo> freeInfo;
01272 };
01273
01274 #endif