00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef STORAGE_H
00024 #define STORAGE_H
00025
00026 #include <ostream>
00027 #include <list>
00028 #include <map>
00029
00030 #include "storage/StorageInterface.h"
00031 #include "storage/StorageTypes.h"
00032 #include "storage/StorageTmpl.h"
00033 #include "storage/Container.h"
00034 #include "storage/Volume.h"
00035 #include "storage/Disk.h"
00036 #include "storage/Partition.h"
00037 #include "storage/LvmVg.h"
00038 #include "storage/LvmLv.h"
00039 #include "storage/DmraidCo.h"
00040 #include "storage/Dmraid.h"
00041 #include "storage/DmmultipathCo.h"
00042 #include "storage/Dmmultipath.h"
00043 #include "storage/MdCo.h"
00044 #include "storage/Md.h"
00045 #include "storage/MdPartCo.h"
00046 #include "storage/MdPart.h"
00047 #include "storage/DmCo.h"
00048 #include "storage/LoopCo.h"
00049 #include "storage/Loop.h"
00050 #include "storage/BtrfsCo.h"
00051 #include "storage/Btrfs.h"
00052 #include "storage/TmpfsCo.h"
00053 #include "storage/Tmpfs.h"
00054 #include "storage/NfsCo.h"
00055 #include "storage/Nfs.h"
00056 #include "storage/FilterIterator.h"
00057 #include "storage/DerefIterator.h"
00058 #include "storage/ListListIterator.h"
00059 #include "storage/IterPair.h"
00060 #include "storage/Lock.h"
00061 #include "storage/FreeInfo.h"
00062 #include "storage/ArchInfo.h"
00063
00064
00065 namespace storage
00066 {
00067
00068 extern CallbackProgressBar progress_bar_cb_ycp;
00069 extern CallbackShowInstallInfo install_info_cb_ycp;
00070 extern CallbackInfoPopup info_popup_cb_ycp;
00071 extern CallbackYesNoPopup yesno_popup_cb_ycp;
00072 extern CallbackCommitErrorPopup commit_error_popup_cb_ycp;
00073 extern CallbackPasswordPopup password_popup_cb_ycp;
00074
00075
00076 template <CType Value>
00077 class CheckType
00078 {
00079 public:
00080 bool operator()( const Container& d ) const
00081 {
00082 return( d.type()==Value );
00083 }
00084 };
00085
00086 template< class Iter, CType Value, class CastResult >
00087 class CastCheckIterator : public FilterIterator< CheckType<Value>, Iter >
00088 {
00089 typedef FilterIterator<CheckType<Value>, Iter> _bclass;
00090 public:
00091 typedef CastResult value_type;
00092 typedef CastResult& reference;
00093 typedef CastResult* pointer;
00094
00095 CastCheckIterator() : _bclass() {}
00096 CastCheckIterator( const Iter& b, const Iter& e, bool atend=false) :
00097 _bclass( b, e, CheckType<Value>(), atend ) {}
00098 CastCheckIterator( const IterPair<Iter>& pair, bool atend=false) :
00099 _bclass( pair, CheckType<Value>(), atend ) {}
00100 template< class It >
00101 CastCheckIterator( const It& i) : _bclass( i.begin(), i.end(), CheckType<Value>() )
00102 { this->m_cur=i.cur();}
00103 CastResult operator*() const
00104 {
00105 return( static_cast<CastResult>(_bclass::operator*()) );
00106 }
00107 CastResult* operator->() const
00108 {
00109 return( static_cast<CastResult*>(_bclass::operator->()) );
00110 }
00111 CastCheckIterator& operator++()
00112 {
00113 _bclass::operator++(); return(*this);
00114 }
00115 CastCheckIterator operator++(int)
00116 {
00117 y2war( "Expensive ++ CastCheckIterator" );
00118 CastCheckIterator tmp(*this);
00119 _bclass::operator++();
00120 return(tmp);
00121 }
00122 CastCheckIterator& operator--()
00123 {
00124 _bclass::operator--(); return(*this);
00125 }
00126 CastCheckIterator operator--(int)
00127 {
00128 y2war( "Expensive -- CastCheckIterator" );
00129 CastCheckIterator tmp(*this);
00130 _bclass::operator--();
00131 return(tmp);
00132 }
00133 };
00134
00135 template < bool (* FncP)( const Container& c ) >
00136 class CheckByFnc
00137 {
00138 public:
00139 bool operator()( const Container& d ) const
00140 {
00141 return( (*FncP)(d) );
00142 }
00143 };
00144
00145 template< class Iter, bool (* FncP)( const Container& c ), class CastResult >
00146 class CastCheckFncIterator : public FilterIterator< CheckByFnc<FncP>, Iter >
00147 {
00148 typedef FilterIterator<CheckByFnc<FncP>, Iter> _bclass;
00149 public:
00150 typedef CastResult value_type;
00151 typedef CastResult& reference;
00152 typedef CastResult* pointer;
00153
00154 CastCheckFncIterator() : _bclass() {}
00155 CastCheckFncIterator( const Iter& b, const Iter& e, bool atend=false) :
00156 _bclass( b, e, CheckByFnc<FncP>(), atend ) {}
00157 CastCheckFncIterator( const IterPair<Iter>& pair, bool atend=false) :
00158 _bclass( pair, CheckByFnc<FncP>(), atend ) {}
00159 template< class It >
00160 CastCheckFncIterator( const It& i) : _bclass( i.begin(), i.end(), i.pred() )
00161 { this->m_cur=i.cur();}
00162 CastResult operator*() const
00163 {
00164 return( static_cast<CastResult>(_bclass::operator*()) );
00165 }
00166 CastResult* operator->() const
00167 {
00168 return( static_cast<CastResult*>(_bclass::operator->()) );
00169 }
00170 CastCheckFncIterator& operator++()
00171 {
00172 _bclass::operator++(); return(*this);
00173 }
00174 CastCheckFncIterator operator++(int)
00175 {
00176 y2war( "Expensive ++ CastCheckFncIterator" );
00177 CastCheckFncIterator tmp(*this);
00178 _bclass::operator++();
00179 return(tmp);
00180 }
00181 CastCheckFncIterator& operator--()
00182 {
00183 _bclass::operator--(); return(*this);
00184 }
00185 CastCheckFncIterator operator--(int)
00186 {
00187 y2war( "Expensive -- CastCheckFncIterator" );
00188 CastCheckFncIterator tmp(*this);
00189 _bclass::operator--();
00190 return(tmp);
00191 }
00192 };
00193
00194
00195 class EtcFstab;
00196 class EtcMdadm;
00197 class DiskData;
00198
00199
00213 class Storage : public storage::StorageInterface, boost::noncopyable
00214 {
00215 protected:
00216
00217 typedef std::list<Container*> CCont;
00218 typedef CCont::iterator CIter;
00219 typedef CCont::const_iterator CCIter;
00220
00221 static bool isMd( const Container&d )
00222 { return( d.type()==storage::MD ); }
00223 static bool isLoop( const Container&d )
00224 { return( d.type()==storage::LOOP ); }
00225 static bool isNfs( const Container&d )
00226 { return( d.type()==storage::NFSC ); }
00227 static bool isDm( const Container&d )
00228 { return( d.type()==storage::DM ); }
00229 static bool isBtrfs( const Container&d )
00230 { return( d.type()==storage::BTRFSC ); }
00231 static bool isNotBtrfs( const Container&d )
00232 { return( d.type()!=storage::BTRFSC ); }
00233 static bool isTmpfs( const Container&d )
00234 { return( d.type()==storage::TMPFSC ); }
00235
00236 public:
00237
00238 static bool isDmPart( const Container&d )
00239 { return d.type() == storage::DMRAID || d.type() == storage::DMMULTIPATH; }
00240 static bool isMdPart( const Container&d )
00241 { return d.type() == storage::MDPART; }
00242 static bool isDmContainer( const Container&d )
00243 { return d.type()==DM || d.type()==LVM || d.type()==DMRAID || d.type()==DMMULTIPATH; }
00244
00245 Storage(const Environment& env);
00246
00247 bool readonly() const { return env.readonly; }
00248 bool testmode() const { return env.testmode; }
00249 bool autodetect() const { return env.autodetect; }
00250 bool instsys() const { return env.instsys; }
00251 string logdir() const { return env.logdir; }
00252 string testdir() const { return env.testdir; }
00253
00254 void setCacheChanges( bool val=true ) { cache = val; }
00255 bool isCacheChanges() const { return( cache ); }
00256 void assertInit() { if( !initialized ) initialize(); }
00257 void rescanEverything();
00258 bool rescanCryptedObjects();
00259 int checkCache();
00260 const string& root() const { return( rootprefix ); }
00261 string prependRoot(const string& mp) const;
00262 const string& tmpDir() const { return tempdir; }
00263 bool hasIScsiDisks() const;
00264 string bootMount() const;
00265
00266 const ArchInfo& getArchInfo() const { return archinfo; }
00267
00268 EtcFstab* getFstab() { return fstab; }
00269 EtcMdadm* getMdadm() { return mdadm; }
00270 void handleLogFile(const string& name) const;
00271 static bool testFilesEqual( const string& n1, const string& n2 );
00272 void printInfo(std::ostream& str) const;
00273 void logCo(const Container* c) const;
00274 void logProcData(const string& str = "") const;
00275
00276 void clearUsedBy(const string& dev);
00277 void clearUsedBy(const list<string>& devs);
00278 void setUsedBy(const string& dev, UsedByType type, const string& device);
00279 void setUsedBy(const list<string>& devs, UsedByType type, const string& device);
00280 void setUsedByBtrfs( const string& dev, const string& uuid );
00281 void addUsedBy(const string& dev, UsedByType type, const string& device);
00282 void addUsedBy(const list<string>& devs, UsedByType type, const string& device);
00283 void removeUsedBy(const string& dev, UsedByType type, const string& device);
00284 void removeUsedBy(const list<string>& devs, UsedByType type, const string& device);
00285 bool isUsedBy(const string& dev);
00286 bool isUsedBy(const string& dev, UsedByType type);
00287 bool isUsedBySingleBtrfs( const Volume& vol ) const;
00288 bool isUsedBySingleBtrfs( const Volume& vol, const Volume** btrfs ) const;
00289 bool canRemove( const Volume& vol ) const;
00290
00291 void fetchDanglingUsedBy(const string& dev, list<UsedBy>& uby);
00292
00293 bool canUseDevice( const string& dev, bool disks_allowed=false );
00294 bool knownDevice( const string& dev, bool disks_allowed=false );
00295 bool setDmcryptData( const string& dev, const string& dm,
00296 unsigned dmnum, unsigned long long siz,
00297 storage::EncryptType typ );
00298 bool deletedDevice(const string& dev) const;
00299 bool isDisk( const string& dev );
00300 const Volume* getVolume( const string& dev );
00301 unsigned long long deviceSize( const string& dev );
00302 const Device* deviceByNumber( unsigned long maj, unsigned long min ) const;
00303
00304 void syncMdadm();
00305 void rootMounted();
00306 bool isRootMounted() const { return( root_mounted ); }
00307
00308 string findNormalDevice( const string& device );
00309 bool findVolume( const string& device, Volume const* &vol,
00310 bool no_btrfsc=false );
00311 bool findUuid( const string& uuid, Volume const* &vol );
00312 bool findDm( const string& device, const Dm*& dm );
00313 bool findDmUsing( const string& device, const Dm*& dm );
00314 bool findDevice( const string& dev, const Device* &vol,
00315 bool search_by_minor=false );
00316 bool removeDm( const string& device );
00317 int unaccessDev( const string& device );
00318
00319 virtual ~Storage();
00320
00321
00322
00323 void getContainers( deque<storage::ContainerInfo>& infos );
00324 int getDiskInfo( const string& disk, storage::DiskInfo& info);
00325 int getLvmVgInfo( const string& name, storage::LvmVgInfo& info);
00326 int getDmraidCoInfo( const string& name, storage::DmraidCoInfo& info);
00327 int getDmmultipathCoInfo( const string& name, storage::DmmultipathCoInfo& info);
00328 int getContDiskInfo( const string& disk, storage::ContainerInfo& cinfo,
00329 storage::DiskInfo& info);
00330 int getContLvmVgInfo( const string& name, storage::ContainerInfo& cinfo,
00331 storage::LvmVgInfo& info);
00332 int getContDmraidCoInfo( const string& name,
00333 storage::ContainerInfo& cinfo,
00334 storage::DmraidCoInfo& info );
00335 int getContDmmultipathCoInfo( const string& name,
00336 storage::ContainerInfo& cinfo,
00337 storage::DmmultipathCoInfo& info );
00338 void getVolumes (deque<storage::VolumeInfo>& vlist);
00339 int getVolume( const string& device, storage::VolumeInfo& info);
00340 int getPartitionInfo( const string& disk,
00341 deque<storage::PartitionInfo>& plist );
00342 int getLvmLvInfo( const string& name,
00343 deque<storage::LvmLvInfo>& plist );
00344 int getMdInfo( deque<storage::MdInfo>& plist );
00345 int getMdPartInfo( const string& device, deque<storage::MdPartInfo>& plist );
00346 int getDmInfo( deque<storage::DmInfo>& plist );
00347 int getNfsInfo( deque<storage::NfsInfo>& plist );
00348 int getLoopInfo( deque<storage::LoopInfo>& plist );
00349 int getBtrfsInfo( deque<storage::BtrfsInfo>& plist );
00350 int getTmpfsInfo( deque<storage::TmpfsInfo>& plist );
00351 int getDmraidInfo( const string& name,
00352 deque<storage::DmraidInfo>& plist );
00353 int getDmmultipathInfo( const string& name,
00354 deque<storage::DmmultipathInfo>& plist );
00355 int getContVolInfo( const string& dev, ContVolInfo& info);
00356
00357 bool getFsCapabilities( storage::FsType fstype,
00358 storage::FsCapabilities& fscapabilities) const;
00359 bool getDlabelCapabilities(const string& dlabel,
00360 storage::DlabelCapabilities& dlabelcapabilities) const;
00361
00362 list<string> getAllUsedFs() const;
00363 void setExtError( const string& txt );
00364 int createPartition( const string& disk, storage::PartitionType type,
00365 unsigned long start, unsigned long size,
00366 string& device );
00367 int resizePartition( const string& device, unsigned long sizeCyl );
00368 int resizePartitionNoFs( const string& device, unsigned long sizeCyl );
00369 int nextFreePartition( const string& disk, storage::PartitionType type,
00370 unsigned &nr, string& device );
00371 int updatePartitionArea( const string& device,
00372 unsigned long start, unsigned long size );
00373 int freeCylindersAroundPartition(const string& device, unsigned long& freeCylsBefore,
00374 unsigned long& freeCylsAfter);
00375 int createPartitionKb( const string& disk, storage::PartitionType type,
00376 unsigned long long start,
00377 unsigned long long sizek, string& device );
00378 int createPartitionAny( const string& disk, unsigned long long size,
00379 string& device );
00380 int createPartitionMax( const string& disk, storage::PartitionType type,
00381 string& device );
00382 unsigned long kbToCylinder( const string& disk, unsigned long long size );
00383 unsigned long long cylinderToKb( const string& disk, unsigned long size );
00384 int removePartition( const string& partition );
00385 int changePartitionId( const string& partition, unsigned id );
00386 int forgetChangePartitionId( const string& partition );
00387
00388 string getPartitionPrefix(const string& disk);
00389 string getPartitionName(const string& disk, int partition_no);
00390
00391 int getUnusedPartitionSlots(const string& disk, list<PartitionSlotInfo>& slots);
00392 int destroyPartitionTable( const string& disk, const string& label );
00393 int initializeDisk( const string& disk, bool value );
00394 string defaultDiskLabel(const string& device);
00395
00396 int changeFormatVolume( const string& device, bool format,
00397 storage::FsType fs );
00398 int changeLabelVolume( const string& device, const string& label );
00399 int eraseLabelVolume( const string& device );
00400 int changeMkfsOptVolume( const string& device, const string& opts );
00401 int changeTunefsOptVolume( const string& device, const string& opts );
00402 int changeDescText( const string& device, const string& txt );
00403 int changeMountPoint( const string& device, const string& mount );
00404 int getMountPoint( const string& device, string& mount );
00405 int changeMountBy( const string& device, storage::MountByType mby );
00406 int getMountBy( const string& device, storage::MountByType& mby );
00407 int changeFstabOptions( const string&, const string& options );
00408 int getFstabOptions( const string& device, string& options );
00409 int addFstabOptions( const string&, const string& options );
00410 int removeFstabOptions( const string&, const string& options );
00411 int setCryptPassword( const string& device, const string& pwd );
00412 int verifyCryptPassword( const string& device, const string& pwd,
00413 bool erase );
00414 int verifyCryptFilePassword( const string& file, const string& pwd );
00415 bool needCryptPassword( const string& device );
00416 int forgetCryptPassword( const string& device );
00417 int getCryptPassword( const string& device, string& pwd );
00418 int setCrypt( const string& device, bool val );
00419 int setCryptType( const string& device, bool val, EncryptType typ );
00420 int getCrypt( const string& device, bool& val );
00421 int setIgnoreFstab( const string& device, bool val );
00422 int getIgnoreFstab( const string& device, bool& val );
00423 int addFstabEntry( const string& device, const string& mount,
00424 const string& vfs, const string& options,
00425 unsigned freq, unsigned passno );
00426 int resizeVolume(const string& device, unsigned long long newSizeK);
00427 int resizeVolumeNoFs(const string& device, unsigned long long newSizeK);
00428 int forgetResizeVolume( const string& device );
00429 void setRecursiveRemoval( bool val=true );
00430 bool getRecursiveRemoval() const { return recursiveRemove; }
00431
00432 int getRecursiveUsing(const string& device, list<string>& devices);
00433 int getRecursiveUsingHelper(const string& device, list<string>& devices);
00434
00435 int getRecursiveUsedBy(const list<string>& device, bool itself, list<string>& usedby_devices);
00436 int getRecursiveUsedByHelper(const string& device, bool itself, list<string>& usedby_devices);
00437
00438 void setZeroNewPartitions( bool val=true );
00439 bool getZeroNewPartitions() const { return zeroNewPartitions; }
00440
00441 void setPartitionAlignment( PartAlign val );
00442 PartAlign getPartitionAlignment() const { return partAlignment; }
00443
00444 void setDefaultMountBy(MountByType mby);
00445 MountByType getDefaultMountBy() const { return defaultMountBy; }
00446
00447 void setDefaultFs (FsType fs);
00448 FsType getDefaultFs() const { return defaultFs; }
00449
00450 void setDefaultSubvolName( const string& val);
00451 string getDefaultSubvolName() const { return defaultSubvolName; }
00452
00453 void setDetectMountedVolumes( bool val=true );
00454 bool getDetectMountedVolumes() const { return detectMounted; }
00455 bool getEfiBoot();
00456 void setRootPrefix( const string& root );
00457 string getRootPrefix() const { return rootprefix; }
00458 int removeVolume( const string& device );
00459 int removeUsing(const string& device, const list<UsedBy>& uby);
00460 bool checkDeviceMounted(const string& device, list<string>& mps);
00461 bool umountDevice( const string& device )
00462 { return( umountDev( device, true )); }
00463 bool umountDeviceUns( const string& device, bool unsetup )
00464 { return( umountDev( device, unsetup )); }
00465 bool umountDev( const string& device, bool dounsetup=false );
00466 bool mountDev( const string& device, const string& mp, bool ro=true,
00467 const string& opts="" );
00468 bool mountDevice( const string& device, const string& mp )
00469 { return( mountDev( device, mp, false )); }
00470 bool mountDeviceOpts( const string& device, const string& mp,
00471 const string& opts )
00472 { return( mountDev( device, mp, false, opts )); }
00473 bool mountDeviceRo( const string& device, const string& mp,
00474 const string& opts )
00475 { return( mountDev( device, mp, true, opts )); }
00476 int activateEncryption( const string& device, bool on );
00477 bool readFstab( const string& dir, deque<storage::VolumeInfo>& infos);
00478
00479 bool getFreeInfo(const string& device, bool get_resize, ResizeInfo& resize_info,
00480 bool get_content, ContentInfo& content_info, bool use_cache);
00481
00482 int createBackupState( const string& name );
00483 int removeBackupState( const string& name );
00484 int restoreBackupState( const string& name );
00485 bool checkBackupState( const string& name ) const;
00486 bool equalBackupStates( const string& lhs, const string& rhs,
00487 bool verbose_log ) const;
00488
00489 int createLvmVg( const string& name, unsigned long long peSizeK,
00490 bool lvm1, const deque<string>& devs );
00491 int removeLvmVg( const string& name );
00492 int extendLvmVg( const string& name, const deque<string>& devs );
00493 int shrinkLvmVg( const string& name, const deque<string>& devs );
00494 int createLvmLv( const string& vg, const string& name,
00495 unsigned long long sizeK, unsigned stripes,
00496 string& device );
00497 int removeLvmLvByDevice( const string& device );
00498 int removeLvmLv( const string& vg, const string& name );
00499 int changeLvStripeCount( const string& vg, const string& name,
00500 unsigned long stripes );
00501 int changeLvStripeSize( const string& vg, const string& name,
00502 unsigned long long stripeSize );
00503
00504 int createLvmLvSnapshot(const string& vg, const string& origin,
00505 const string& name, unsigned long long cowSizeK,
00506 string& device);
00507 int removeLvmLvSnapshot(const string& vg, const string& name);
00508 int getLvmLvSnapshotStateInfo(const string& vg, const string& name,
00509 LvmLvSnapshotStateInfo& info);
00510 int createLvmLvPool( const string& vg, const string& name,
00511 unsigned long long sizeK, string& device );
00512 int createLvmLvThin( const string& vg, const string& name,
00513 const string& pool, unsigned long long sizeK,
00514 string& device );
00515 int changeLvChunkSize( const string& vg, const string& name,
00516 unsigned long long chunkSizeK );
00517
00518 int nextFreeMd(unsigned& nr, string &device);
00519 bool checkMdNumber(unsigned num);
00520 int createMd(const string& name, MdType rtype, const list<string>& devs,
00521 const list<string>& spares);
00522 int createMdAny(MdType rtype, const list<string>& devs, const list<string>& spares,
00523 string& device);
00524 int removeMd( const string& name, bool destroySb=true );
00525 int extendMd(const string& name, const list<string>& devs, const list<string>& spares);
00526 int updateMd(const string& name, const list<string>& devs, const list<string>& spares);
00527 int shrinkMd(const string& name, const list<string>& devs, const list<string>& spares);
00528 int changeMdType( const string& name, storage::MdType rtype );
00529 int changeMdChunk( const string& name, unsigned long chunk );
00530 int changeMdParity( const string& name, storage::MdParity ptype );
00531 int checkMd( const string& name );
00532 int getMdStateInfo(const string& name, MdStateInfo& info);
00533 int computeMdSize(MdType md_type, const list<string>& devices, const list<string>& spares,
00534 unsigned long long& sizeK);
00535 list<int> getMdAllowedParity(MdType md_type, unsigned devices );
00536 void setImsmDriver(ImsmDriver val) { imsm_driver = val; }
00537 ImsmDriver getImsmDriver() const { return imsm_driver; }
00538 void setMultipathAutostart(MultipathAutostart val) { multipath_autostart = val; }
00539 MultipathAutostart getMultipathAutostart() const { return multipath_autostart; }
00540
00541 int getMdPartCoInfo( const string& name, MdPartCoInfo& info);
00542 int getContMdPartCoInfo( const string& name, ContainerInfo& cinfo,
00543 MdPartCoInfo& info);
00544 int getMdPartCoStateInfo(const string& name, MdPartCoStateInfo& info);
00545 int removeMdPartCo(const string& devName, bool destroySb);
00546
00547 int addNfsDevice(const string& nfsDev, const string& opts,
00548 unsigned long long sizeK, const string& mp, bool nfs4);
00549 int checkNfsDevice(const string& nfsDev, const string& opts, bool nfs4,
00550 unsigned long long& sizeK);
00551
00552 int createFileLoop( const string& lname, bool reuseExisting,
00553 unsigned long long sizeK, const string& mp,
00554 const string& pwd, string& device );
00555 int modifyFileLoop( const string& device, const string& lname,
00556 bool reuseExisting, unsigned long long sizeK );
00557 int removeFileLoop( const string& lname, bool removeFile );
00558
00559 int removeDmraid( const string& name );
00560
00561 bool existSubvolume( const string& device, const string& name );
00562 int createSubvolume( const string& device, const string& name );
00563 int removeSubvolume( const string& device, const string& name );
00564 int extendBtrfsVolume( const string& device, const string& dev );
00565 int extendBtrfsVolume( const string& device, const deque<string>& devs );
00566 int shrinkBtrfsVolume( const string& device, const string& dev );
00567 int shrinkBtrfsVolume( const string& device, const deque<string>& devs );
00568 void setBtrfsUsedBy( const Btrfs* bt );
00569
00570 int addTmpfsMount( const string& mp, const string& opts );
00571 int removeTmpfsMount( const string& mp );
00572
00573 void getCommitInfos(list<CommitInfo>& infos) const;
00574 const string& getLastAction() const { return lastAction.text; }
00575 const string& getExtendedErrorMessage() const { return extendedError; }
00576 void eraseCachedFreeInfo(const string& device);
00577
00578 static void waitForDevice();
00579 static int waitForDevice(const string& device);
00580
00581 static int zeroDevice(const string& device, bool random = false,
00582 unsigned long long beginK = 200, unsigned long long endK = 10);
00583 static unsigned long long sizeK( const string& device );
00584 static bool loadModuleIfNeeded( const string& module );
00585 static void clean_tmpdir();
00586
00587 static bool getDiskList( list< pair< string, Disk::SysfsInfo > >& dlist );
00588 void getDiskList( bool (* CheckFnc)( const Disk& ),
00589 std::list<Disk*>& dl );
00590 void changeDeviceName( const string& old, const string& nw );
00591
00592 int commit();
00593
00594 string getErrorString(int error) const;
00595
00596 void handleHald( bool stop );
00597
00598 void activateHld(bool val = true);
00599 void activateMultipath(bool val = true);
00600
00601 void removeDmTableTo( const Volume& vol );
00602 void removeDmTableTo( const string& device );
00603 void removeDmTableTo( unsigned long mjr, unsigned long mnr );
00604 bool removeDmTable( const string& table );
00605 bool removeDmMapsTo( const string& dev );
00606 bool checkDmMapsTo( const string& dev );
00607 void updateDmEmptyPeMap();
00608 void dumpObjectList();
00609 void dumpCommitInfos() const;
00610 bool mountTmpRo( const Volume* vol, string& mp, const string& opts="" );
00611 bool mountTmp( const Volume* vol, string& mp, const string& opts="" );
00612
00613 void setCallbackProgressBar(CallbackProgressBar pfnc) { progress_bar_cb = pfnc; }
00614 CallbackProgressBar getCallbackProgressBar() const { return progress_bar_cb; }
00615 void setCallbackShowInstallInfo(CallbackShowInstallInfo pfnc) { install_info_cb = pfnc; }
00616 CallbackShowInstallInfo getCallbackShowInstallInfo() const { return install_info_cb; }
00617 void setCallbackInfoPopup(CallbackInfoPopup pfnc) { info_popup_cb = pfnc; }
00618 CallbackInfoPopup getCallbackInfoPopup() const { return info_popup_cb; }
00619 void setCallbackYesNoPopup(CallbackYesNoPopup pfnc) { yesno_popup_cb = pfnc; }
00620 CallbackYesNoPopup getCallbackYesNoPopup() const { return yesno_popup_cb; }
00621 void setCallbackCommitErrorPopup(CallbackCommitErrorPopup pfnc) { commit_error_popup_cb = pfnc; }
00622 CallbackCommitErrorPopup getCallbackCommitErrorPopup() const { return commit_error_popup_cb; }
00623 void setCallbackPasswordPopup(CallbackPasswordPopup pfnc) { password_popup_cb = pfnc; }
00624 CallbackPasswordPopup getCallbackPasswordPopup() const { return password_popup_cb; }
00625
00626 void addInfoPopupText( const string& disk, const Text& txt );
00627
00628 CallbackProgressBar getCallbackProgressBarTheOne() const
00629 { return progress_bar_cb ? progress_bar_cb : progress_bar_cb_ycp; }
00630 CallbackShowInstallInfo getCallbackShowInstallInfoTheOne() const
00631 { return install_info_cb ? install_info_cb : install_info_cb_ycp; }
00632 CallbackInfoPopup getCallbackInfoPopupTheOne() const
00633 { return info_popup_cb ? info_popup_cb : info_popup_cb_ycp; }
00634 CallbackYesNoPopup getCallbackYesNoPopupTheOne() const
00635 { return yesno_popup_cb ? yesno_popup_cb : yesno_popup_cb_ycp; }
00636 CallbackCommitErrorPopup getCallbackCommitErrorPopupTheOne() const
00637 { return commit_error_popup_cb ? commit_error_popup_cb : commit_error_popup_cb_ycp; }
00638 CallbackPasswordPopup getCallbackPasswordPopupTheOne() const
00639 { return password_popup_cb ? password_popup_cb : password_popup_cb_ycp; }
00640
00641 void progressBarCb(const string& id, unsigned cur, unsigned max) const;
00642 void showInfoCb(const Text& info, bool quiet);
00643 void infoPopupCb(const Text& info) const;
00644 bool yesnoPopupCb(const Text& info) const;
00645 bool commitErrorPopupCb(int error, const Text& last_action, const string& extended_message) const;
00646 bool passwordPopupCb(const string& device, int attempts, string& password) const;
00647
00648
00649 protected:
00650
00651 template< class Pred >
00652 struct ConstContainerPI { typedef ContainerIter<Pred, CCIter> type; };
00653 typedef CheckFnc<const Container> CheckFncCont;
00654 typedef CheckerIterator< CheckFncCont, ConstContainerPI<CheckFncCont>::type,
00655 CCIter, Container > ConstContPIterator;
00656 template< class Pred >
00657 struct ContainerPI { typedef ContainerIter<Pred, CIter> type; };
00658 template< class Pred >
00659 struct ContainerI
00660 { typedef ContainerDerIter<Pred, typename ContainerPI<Pred>::type,
00661 Container> type; };
00662 typedef CheckerIterator< CheckFncCont, ContainerPI<CheckFncCont>::type,
00663 CIter, Container > ContPIterator;
00664 typedef DerefIterator<ContPIterator,Container> ContIterator;
00665 typedef IterPair<ContIterator> CPair;
00666
00667 public:
00668
00669 template< class Pred >
00670 struct ConstContainerI
00671 { typedef ContainerDerIter<Pred, typename ConstContainerPI<Pred>::type,
00672 const Container> type; };
00673 template< class Pred >
00674 struct ContCondIPair { typedef MakeCondIterPair<Pred,
00675 typename ConstContainerI<Pred>::type> type;};
00676 typedef DerefIterator<ConstContPIterator,const Container> ConstContIterator;
00677 typedef IterPair<ConstContIterator> ConstContPair;
00678
00679
00680 ConstContPair contPair( bool (* CheckFnc)( const Container& )=NULL ) const
00681 {
00682 return( ConstContPair( contBegin( CheckFnc ), contEnd( CheckFnc ) ));
00683 }
00684 ConstContIterator contBegin( bool (* CheckFnc)( const Container& )=NULL ) const
00685 {
00686 return( ConstContIterator( ConstContPIterator( cont.begin(), cont.end(), CheckFnc )) );
00687 }
00688 ConstContIterator contEnd( bool (* CheckFnc)( const Container& )=NULL ) const
00689 {
00690 return( ConstContIterator( ConstContPIterator( cont.begin(), cont.end(), CheckFnc, true )) );
00691 }
00692 template< class Pred > typename ContCondIPair<Pred>::type contCondPair( const Pred& p ) const
00693 {
00694 return( typename ContCondIPair<Pred>::type( contCondBegin( p ), contCondEnd( p ) ) );
00695 }
00696 template< class Pred > typename ConstContainerI<Pred>::type contCondBegin( const Pred& p ) const
00697 {
00698 return( typename ConstContainerI<Pred>::type( typename ConstContainerPI<Pred>::type( cont.begin(), cont.end(), p )) );
00699 }
00700 template< class Pred > typename ConstContainerI<Pred>::type contCondEnd( const Pred& p ) const
00701 {
00702 return( typename ConstContainerI<Pred>::type( typename ConstContainerPI<Pred>::type( cont.begin(), cont.end(), p, true )) );
00703 }
00704 protected:
00705
00706 CPair cPair( bool (* CheckFnc)( const Container& )=NULL )
00707 {
00708 return( CPair( cBegin(CheckFnc), cEnd(CheckFnc) ));
00709 }
00710 ContIterator cBegin( bool (* CheckFnc)( const Container& )=NULL )
00711 {
00712 return( ContIterator( ContPIterator( cont.begin(), cont.end(), CheckFnc )) );
00713 }
00714 ContIterator cEnd( bool (* CheckFnc)( const Container& )=NULL )
00715 {
00716 return( ContIterator( ContPIterator( cont.begin(), cont.end(), CheckFnc, true )) );
00717 }
00718
00719
00720 protected:
00721
00722 typedef CastCheckIterator<CCIter, storage::DISK, const Disk *> ContainerCDiskIter;
00723 template< class Pred >
00724 struct ConstDiskPI { typedef ContainerIter<Pred, ContainerCDiskIter> type; };
00725 typedef CastCheckIterator<CIter, storage::DISK, Disk *> ContainerDiskIter;
00726 template< class Pred >
00727 struct DiskPI { typedef ContainerIter<Pred, ContainerDiskIter> type; };
00728 template< class Pred >
00729 struct DiskI { typedef ContainerDerIter<Pred, typename DiskPI<Pred>::type, Disk> type; };
00730 typedef CheckFnc<const Disk> CheckFncDisk;
00731 typedef CheckerIterator< CheckFncDisk, ConstDiskPI<CheckFncDisk>::type,
00732 ContainerCDiskIter, Disk > ConstDiskPIterator;
00733 typedef CheckerIterator< CheckFncDisk, DiskPI<CheckFncDisk>::type,
00734 ContainerDiskIter, Disk > DiskPIterator;
00735 typedef DerefIterator<DiskPIterator,Disk> DiskIterator;
00736 typedef IterPair<DiskIterator> DiskPair;
00737
00738 public:
00739
00740 typedef DerefIterator<ConstDiskPIterator,const Disk> ConstDiskIterator;
00741 template< class Pred >
00742 struct ConstDiskI
00743 { typedef ContainerDerIter<Pred, typename ConstDiskPI<Pred>::type,
00744 const Disk> type; };
00745 template< class Pred >
00746 struct DiskCondIPair { typedef MakeCondIterPair<Pred, typename ConstDiskI<Pred>::type> type; };
00747 typedef IterPair<ConstDiskIterator> ConstDiskPair;
00748
00749
00750 ConstDiskPair diskPair( bool (* CheckFnc)( const Disk& )=NULL ) const
00751 {
00752 return( ConstDiskPair( diskBegin( CheckFnc ), diskEnd( CheckFnc ) ));
00753 }
00754 ConstDiskIterator diskBegin( bool (* CheckFnc)( const Disk& )=NULL ) const
00755 {
00756 IterPair<ContainerCDiskIter> p( ContainerCDiskIter( cont.begin(), cont.end() ),
00757 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00758 return( ConstDiskIterator( ConstDiskPIterator( p, CheckFnc )) );
00759 }
00760 ConstDiskIterator diskEnd( bool (* CheckFnc)( const Disk& )=NULL ) const
00761 {
00762 IterPair<ContainerCDiskIter> p( ContainerCDiskIter( cont.begin(), cont.end() ),
00763 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00764 return( ConstDiskIterator( ConstDiskPIterator( p, CheckFnc, true )) );
00765 }
00766 template< class Pred > typename DiskCondIPair<Pred>::type diskCondPair( const Pred& p ) const
00767 {
00768 return( typename DiskCondIPair<Pred>::type( diskCondBegin( p ), diskCondEnd( p ) ) );
00769 }
00770 template< class Pred > typename ConstDiskI<Pred>::type diskCondBegin( const Pred& p ) const
00771 {
00772 IterPair<ContainerCDiskIter> pair( ContainerCDiskIter( cont.begin(), cont.end() ),
00773 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00774 return( typename ConstDiskI<Pred>::type( typename ConstDiskPI<Pred>::type( pair, p )) );
00775 }
00776 template< class Pred > typename ConstDiskI<Pred>::type diskCondEnd( const Pred& p ) const
00777 {
00778 IterPair<ContainerCDiskIter> pair( ContainerCDiskIter( cont.begin(), cont.end() ),
00779 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00780 return( typename ConstDiskI<Pred>::type( typename ConstDiskPI<Pred>::type( pair, p, true )) );
00781 }
00782 protected:
00783
00784 DiskPair dPair( bool (* CheckFnc)( const Disk& )=NULL )
00785 {
00786 return( DiskPair( dBegin( CheckFnc ), dEnd( CheckFnc ) ));
00787 }
00788 DiskIterator dBegin( bool (* CheckFnc)( const Disk& )=NULL )
00789 {
00790 IterPair<ContainerDiskIter> p( ContainerDiskIter( cont.begin(), cont.end() ),
00791 ContainerDiskIter( cont.begin(), cont.end(), true ));
00792 return( DiskIterator( DiskPIterator( p, CheckFnc )) );
00793 }
00794 DiskIterator dEnd( bool (* CheckFnc)( const Disk& )=NULL )
00795 {
00796 IterPair<ContainerDiskIter> p( ContainerDiskIter( cont.begin(), cont.end() ),
00797 ContainerDiskIter( cont.begin(), cont.end(), true ));
00798 return( DiskIterator( DiskPIterator( p, CheckFnc, true )) );
00799 }
00800
00801
00802
00803 protected:
00804
00805 typedef CastCheckIterator<CCIter, storage::LVM, const LvmVg *> ContainerCLvmVgIter;
00806 template< class Pred >
00807 struct ConstLvmVgPI { typedef ContainerIter<Pred, ContainerCLvmVgIter> type; };
00808 typedef CastCheckIterator<CIter, storage::LVM, LvmVg *> ContainerLvmVgIter;
00809 template< class Pred >
00810 struct LvmVgPI { typedef ContainerIter<Pred, ContainerLvmVgIter> type; };
00811 template< class Pred >
00812 struct LvmVgI { typedef ContainerDerIter<Pred, typename LvmVgPI<Pred>::type, LvmVg> type; };
00813 typedef CheckFnc<const LvmVg> CheckFncLvmVg;
00814 typedef CheckerIterator< CheckFncLvmVg, ConstLvmVgPI<CheckFncLvmVg>::type,
00815 ContainerCLvmVgIter, LvmVg > ConstLvmVgPIterator;
00816 typedef CheckerIterator< CheckFncLvmVg, LvmVgPI<CheckFncLvmVg>::type,
00817 ContainerLvmVgIter, LvmVg > LvmVgPIterator;
00818 typedef DerefIterator<LvmVgPIterator,LvmVg> LvmVgIterator;
00819 typedef IterPair<LvmVgIterator> LvmVgPair;
00820
00821 public:
00822
00823 typedef DerefIterator<ConstLvmVgPIterator,const LvmVg> ConstLvmVgIterator;
00824 template< class Pred >
00825 struct ConstLvmVgI
00826 { typedef ContainerDerIter<Pred, typename ConstLvmVgPI<Pred>::type,
00827 const LvmVg> type; };
00828 template< class Pred >
00829 struct LvmVgCondIPair { typedef MakeCondIterPair<Pred, typename ConstLvmVgI<Pred>::type> type; };
00830 typedef IterPair<ConstLvmVgIterator> ConstLvmVgPair;
00831
00832
00833 ConstLvmVgPair lvmVgPair( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00834 {
00835 return( ConstLvmVgPair( lvmVgBegin( CheckFnc ), lvmVgEnd( CheckFnc ) ));
00836 }
00837 ConstLvmVgIterator lvmVgBegin( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00838 {
00839 IterPair<ContainerCLvmVgIter> p( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00840 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00841 return( ConstLvmVgIterator( ConstLvmVgPIterator( p, CheckFnc )) );
00842 }
00843 ConstLvmVgIterator lvmVgEnd( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00844 {
00845 IterPair<ContainerCLvmVgIter> p( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00846 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00847 return( ConstLvmVgIterator( ConstLvmVgPIterator( p, CheckFnc, true )) );
00848 }
00849 template< class Pred > typename LvmVgCondIPair<Pred>::type lvmVgCondPair( const Pred& p ) const
00850 {
00851 return( typename LvmVgCondIPair<Pred>::type( lvmVgCondBegin( p ), lvmVgCondEnd( p ) ) );
00852 }
00853 template< class Pred > typename ConstLvmVgI<Pred>::type lvmVgCondBegin( const Pred& p ) const
00854 {
00855 IterPair<ContainerCLvmVgIter> pair( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00856 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00857 return( typename ConstLvmVgI<Pred>::type( typename ConstLvmVgPI<Pred>::type( pair, p )) );
00858 }
00859 template< class Pred > typename ConstLvmVgI<Pred>::type lvmVgCondEnd( const Pred& p ) const
00860 {
00861 IterPair<ContainerCLvmVgIter> pair( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00862 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00863 return( typename ConstLvmVgI<Pred>::type( typename ConstLvmVgPI<Pred>::type( pair, p, true )) );
00864 }
00865 protected:
00866
00867 LvmVgPair lvgPair( bool (* CheckFnc)( const LvmVg& )=NULL )
00868 {
00869 return( LvmVgPair( lvgBegin( CheckFnc ), lvgEnd( CheckFnc ) ));
00870 }
00871 LvmVgIterator lvgBegin( bool (* CheckFnc)( const LvmVg& )=NULL )
00872 {
00873 IterPair<ContainerLvmVgIter> p( ContainerLvmVgIter( cont.begin(), cont.end() ),
00874 ContainerLvmVgIter( cont.begin(), cont.end(), true ));
00875 return( LvmVgIterator( LvmVgPIterator( p, CheckFnc )) );
00876 }
00877 LvmVgIterator lvgEnd( bool (* CheckFnc)( const LvmVg& )=NULL )
00878 {
00879 IterPair<ContainerLvmVgIter> p( ContainerLvmVgIter( cont.begin(), cont.end() ),
00880 ContainerLvmVgIter( cont.begin(), cont.end(), true ));
00881 return( LvmVgIterator( LvmVgPIterator( p, CheckFnc, true )) );
00882 }
00883
00884
00885 protected:
00886
00887 typedef CastCheckFncIterator<CCIter, isDmPart, const DmPartCo *> ContainerCDmPartIter;
00888 template< class Pred >
00889 struct ConstDmPartCoPI { typedef ContainerIter<Pred, ContainerCDmPartIter> type; };
00890 typedef CastCheckFncIterator<CIter, isDmPart, DmPartCo *> ContainerDmPartIter;
00891 template< class Pred >
00892 struct DmPartCoPI { typedef ContainerIter<Pred, ContainerDmPartIter> type; };
00893 template< class Pred >
00894 struct DmPartCoI { typedef ContainerDerIter<Pred, typename DmPartCoPI<Pred>::type, DmPartCo> type; };
00895 typedef CheckFnc<const DmPartCo> CheckFncDmPartCo;
00896 typedef CheckerIterator< CheckFncDmPartCo, ConstDmPartCoPI<CheckFncDmPartCo>::type,
00897 ContainerCDmPartIter, DmPartCo > ConstDmPartCoPIterator;
00898 typedef CheckerIterator< CheckFncDmPartCo, DmPartCoPI<CheckFncDmPartCo>::type,
00899 ContainerDmPartIter, DmPartCo > DmPartCoPIterator;
00900 typedef DerefIterator<DmPartCoPIterator,DmPartCo> DmPartCoIterator;
00901 typedef IterPair<DmPartCoIterator> DmPartCoPair;
00902
00903 public:
00904
00905 typedef DerefIterator<ConstDmPartCoPIterator,const DmPartCo> ConstDmPartCoIterator;
00906 template< class Pred >
00907 struct ConstDmPartCoI
00908 { typedef ContainerDerIter<Pred, typename ConstDmPartCoPI<Pred>::type,
00909 const DmPartCo> type; };
00910 template< class Pred >
00911 struct DmPartCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstDmPartCoI<Pred>::type> type; };
00912 typedef IterPair<ConstDmPartCoIterator> ConstDmPartCoPair;
00913
00914
00915 ConstDmPartCoPair dmpartCoPair( bool (* CheckFnc)( const DmPartCo& )=NULL ) const
00916 {
00917 return( ConstDmPartCoPair( dmpartCoBegin( CheckFnc ), dmpartCoEnd( CheckFnc ) ));
00918 }
00919 ConstDmPartCoIterator dmpartCoBegin( bool (* CheckFnc)( const DmPartCo& )=NULL ) const
00920 {
00921 IterPair<ContainerCDmPartIter> p( ContainerCDmPartIter( cont.begin(), cont.end() ),
00922 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00923 return( ConstDmPartCoIterator( ConstDmPartCoPIterator( p, CheckFnc )) );
00924 }
00925 ConstDmPartCoIterator dmpartCoEnd( bool (* CheckFnc)( const DmPartCo& )=NULL ) const
00926 {
00927 IterPair<ContainerCDmPartIter> p( ContainerCDmPartIter( cont.begin(), cont.end() ),
00928 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00929 return( ConstDmPartCoIterator( ConstDmPartCoPIterator( p, CheckFnc, true )) );
00930 }
00931 template< class Pred > typename DmPartCoCondIPair<Pred>::type dmPartCoCondPair( const Pred& p ) const
00932 {
00933 return( typename DmPartCoCondIPair<Pred>::type( dmpartCoCondBegin( p ), dmpartCoCondEnd( p ) ) );
00934 }
00935 template< class Pred > typename ConstDmPartCoI<Pred>::type dmpartCoCondBegin( const Pred& p ) const
00936 {
00937 IterPair<ContainerCDmPartIter> pair( ContainerCDmPartIter( cont.begin(), cont.end() ),
00938 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00939 return( typename ConstDmPartCoI<Pred>::type( typename ConstDmPartCoPI<Pred>::type( pair, p )) );
00940 }
00941 template< class Pred > typename ConstDmPartCoI<Pred>::type dmpartCoCondEnd( const Pred& p ) const
00942 {
00943 IterPair<ContainerCDmPartIter> pair( ContainerCDmPartIter( cont.begin(), cont.end() ),
00944 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00945 return( typename ConstDmPartCoI<Pred>::type( typename ConstDmPartCoPI<Pred>::type( pair, p, true )) );
00946 }
00947 protected:
00948
00949 DmPartCoPair dmpCoPair( bool (* CheckFnc)( const DmPartCo& )=NULL )
00950 {
00951 return( DmPartCoPair( dmpCoBegin( CheckFnc ), dmpCoEnd( CheckFnc ) ));
00952 }
00953 DmPartCoIterator dmpCoBegin( bool (* CheckFnc)( const DmPartCo& )=NULL )
00954 {
00955 IterPair<ContainerDmPartIter> p( ContainerDmPartIter( cont.begin(), cont.end() ),
00956 ContainerDmPartIter( cont.begin(), cont.end(), true ));
00957 return( DmPartCoIterator( DmPartCoPIterator( p, CheckFnc )) );
00958 }
00959 DmPartCoIterator dmpCoEnd( bool (* CheckFnc)( const DmPartCo& )=NULL )
00960 {
00961 IterPair<ContainerDmPartIter> p( ContainerDmPartIter( cont.begin(), cont.end() ),
00962 ContainerDmPartIter( cont.begin(), cont.end(), true ));
00963 return( DmPartCoIterator( DmPartCoPIterator( p, CheckFnc, true )) );
00964 }
00965
00966
00967 protected:
00968
00969 typedef CastCheckIterator<CCIter, storage::DMRAID, const DmraidCo *> ContainerCDmraidIter;
00970 template< class Pred >
00971 struct ConstDmraidCoPI { typedef ContainerIter<Pred, ContainerCDmraidIter> type; };
00972 typedef CastCheckIterator<CIter, storage::DMRAID, DmraidCo *> ContainerDmraidIter;
00973 template< class Pred >
00974 struct DmraidCoPI { typedef ContainerIter<Pred, ContainerDmraidIter> type; };
00975 template< class Pred >
00976 struct DmraidCoI { typedef ContainerDerIter<Pred, typename DmraidCoPI<Pred>::type, DmraidCo> type; };
00977 typedef CheckFnc<const DmraidCo> CheckFncDmraidCo;
00978 typedef CheckerIterator< CheckFncDmraidCo, ConstDmraidCoPI<CheckFncDmraidCo>::type,
00979 ContainerCDmraidIter, DmraidCo > ConstDmraidCoPIterator;
00980 typedef CheckerIterator< CheckFncDmraidCo, DmraidCoPI<CheckFncDmraidCo>::type,
00981 ContainerDmraidIter, DmraidCo > DmraidCoPIterator;
00982 typedef DerefIterator<DmraidCoPIterator,DmraidCo> DmraidCoIterator;
00983 typedef IterPair<DmraidCoIterator> DmraidCoPair;
00984
00985 public:
00986
00987 typedef DerefIterator<ConstDmraidCoPIterator,const DmraidCo> ConstDmraidCoIterator;
00988 template< class Pred >
00989 struct ConstDmraidCoI
00990 { typedef ContainerDerIter<Pred, typename ConstDmraidCoPI<Pred>::type,
00991 const DmraidCo> type; };
00992 template< class Pred >
00993 struct DmraidCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstDmraidCoI<Pred>::type> type; };
00994 typedef IterPair<ConstDmraidCoIterator> ConstDmraidCoPair;
00995
00996
00997 ConstDmraidCoPair dmraidCoPair( bool (* CheckFnc)( const DmraidCo& )=NULL ) const
00998 {
00999 return( ConstDmraidCoPair( dmraidCoBegin( CheckFnc ), dmraidCoEnd( CheckFnc ) ));
01000 }
01001 ConstDmraidCoIterator dmraidCoBegin( bool (* CheckFnc)( const DmraidCo& )=NULL ) const
01002 {
01003 IterPair<ContainerCDmraidIter> p( ContainerCDmraidIter( cont.begin(), cont.end() ),
01004 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
01005 return( ConstDmraidCoIterator( ConstDmraidCoPIterator( p, CheckFnc )) );
01006 }
01007 ConstDmraidCoIterator dmraidCoEnd( bool (* CheckFnc)( const DmraidCo& )=NULL ) const
01008 {
01009 IterPair<ContainerCDmraidIter> p( ContainerCDmraidIter( cont.begin(), cont.end() ),
01010 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
01011 return( ConstDmraidCoIterator( ConstDmraidCoPIterator( p, CheckFnc, true )) );
01012 }
01013 template< class Pred > typename DmraidCoCondIPair<Pred>::type dmraidCoCondPair( const Pred& p ) const
01014 {
01015 return( typename DmraidCoCondIPair<Pred>::type( dmraidCoCondBegin( p ), dmraidCoCondEnd( p ) ) );
01016 }
01017 template< class Pred > typename ConstDmraidCoI<Pred>::type dmraidCoCondBegin( const Pred& p ) const
01018 {
01019 IterPair<ContainerCDmraidIter> pair( ContainerCDmraidIter( cont.begin(), cont.end() ),
01020 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
01021 return( typename ConstDmraidCoI<Pred>::type( typename ConstDmraidCoPI<Pred>::type( pair, p )) );
01022 }
01023 template< class Pred > typename ConstDmraidCoI<Pred>::type dmraidCoCondEnd( const Pred& p ) const
01024 {
01025 IterPair<ContainerCDmraidIter> pair( ContainerCDmraidIter( cont.begin(), cont.end() ),
01026 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
01027 return( typename ConstDmraidCoI<Pred>::type( typename ConstDmraidCoPI<Pred>::type( pair, p, true )) );
01028 }
01029 protected:
01030
01031 DmraidCoPair dmrCoPair( bool (* CheckFnc)( const DmraidCo& )=NULL )
01032 {
01033 return( DmraidCoPair( dmrCoBegin( CheckFnc ), dmrCoEnd( CheckFnc ) ));
01034 }
01035 DmraidCoIterator dmrCoBegin( bool (* CheckFnc)( const DmraidCo& )=NULL )
01036 {
01037 IterPair<ContainerDmraidIter> p( ContainerDmraidIter( cont.begin(), cont.end() ),
01038 ContainerDmraidIter( cont.begin(), cont.end(), true ));
01039 return( DmraidCoIterator( DmraidCoPIterator( p, CheckFnc )) );
01040 }
01041 DmraidCoIterator dmrCoEnd( bool (* CheckFnc)( const DmraidCo& )=NULL )
01042 {
01043 IterPair<ContainerDmraidIter> p( ContainerDmraidIter( cont.begin(), cont.end() ),
01044 ContainerDmraidIter( cont.begin(), cont.end(), true ));
01045 return( DmraidCoIterator( DmraidCoPIterator( p, CheckFnc, true )) );
01046 }
01047
01048
01049
01050 protected:
01051
01052 typedef CastCheckIterator<CCIter, storage::DMMULTIPATH, const DmmultipathCo *> ContainerCDmmultipathIter;
01053 template< class Pred >
01054 struct ConstDmmultipathCoPI { typedef ContainerIter<Pred, ContainerCDmmultipathIter> type; };
01055 typedef CastCheckIterator<CIter, storage::DMMULTIPATH, DmmultipathCo *> ContainerDmmultipathIter;
01056 template< class Pred >
01057 struct DmmultipathCoPI { typedef ContainerIter<Pred, ContainerDmmultipathIter> type; };
01058 template< class Pred >
01059 struct DmmultipathCoI { typedef ContainerDerIter<Pred, typename DmmultipathCoPI<Pred>::type, DmmultipathCo> type; };
01060 typedef CheckFnc<const DmmultipathCo> CheckFncDmmultipathCo;
01061 typedef CheckerIterator< CheckFncDmmultipathCo, ConstDmmultipathCoPI<CheckFncDmmultipathCo>::type,
01062 ContainerCDmmultipathIter, DmmultipathCo > ConstDmmultipathCoPIterator;
01063 typedef CheckerIterator< CheckFncDmmultipathCo, DmmultipathCoPI<CheckFncDmmultipathCo>::type,
01064 ContainerDmmultipathIter, DmmultipathCo > DmmultipathCoPIterator;
01065 typedef DerefIterator<DmmultipathCoPIterator,DmmultipathCo> DmmultipathCoIterator;
01066 typedef IterPair<DmmultipathCoIterator> DmmultipathCoPair;
01067
01068 public:
01069
01070 typedef DerefIterator<ConstDmmultipathCoPIterator,const DmmultipathCo> ConstDmmultipathCoIterator;
01071 template< class Pred >
01072 struct ConstDmmultipathCoI
01073 { typedef ContainerDerIter<Pred, typename ConstDmmultipathCoPI<Pred>::type,
01074 const DmmultipathCo> type; };
01075 template< class Pred >
01076 struct DmmultipathCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstDmmultipathCoI<Pred>::type> type; };
01077 typedef IterPair<ConstDmmultipathCoIterator> ConstDmmultipathCoPair;
01078
01079
01080 ConstDmmultipathCoPair dmmultipathCoPair( bool (* CheckFnc)( const DmmultipathCo& )=NULL ) const
01081 {
01082 return( ConstDmmultipathCoPair( dmmultipathCoBegin( CheckFnc ), dmmultipathCoEnd( CheckFnc ) ));
01083 }
01084 ConstDmmultipathCoIterator dmmultipathCoBegin( bool (* CheckFnc)( const DmmultipathCo& )=NULL ) const
01085 {
01086 IterPair<ContainerCDmmultipathIter> p( ContainerCDmmultipathIter( cont.begin(), cont.end() ),
01087 ContainerCDmmultipathIter( cont.begin(), cont.end(), true ));
01088 return( ConstDmmultipathCoIterator( ConstDmmultipathCoPIterator( p, CheckFnc )) );
01089 }
01090 ConstDmmultipathCoIterator dmmultipathCoEnd( bool (* CheckFnc)( const DmmultipathCo& )=NULL ) const
01091 {
01092 IterPair<ContainerCDmmultipathIter> p( ContainerCDmmultipathIter( cont.begin(), cont.end() ),
01093 ContainerCDmmultipathIter( cont.begin(), cont.end(), true ));
01094 return( ConstDmmultipathCoIterator( ConstDmmultipathCoPIterator( p, CheckFnc, true )) );
01095 }
01096 template< class Pred > typename DmmultipathCoCondIPair<Pred>::type dmmultipathCoCondPair( const Pred& p ) const
01097 {
01098 return( typename DmmultipathCoCondIPair<Pred>::type( dmmultipathCoCondBegin( p ), dmmultipathCoCondEnd( p ) ) );
01099 }
01100 template< class Pred > typename ConstDmmultipathCoI<Pred>::type dmmultipathCoCondBegin( const Pred& p ) const
01101 {
01102 IterPair<ContainerCDmmultipathIter> pair( ContainerCDmmultipathIter( cont.begin(), cont.end() ),
01103 ContainerCDmmultipathIter( cont.begin(), cont.end(), true ));
01104 return( typename ConstDmmultipathCoI<Pred>::type( typename ConstDmmultipathCoPI<Pred>::type( pair, p )) );
01105 }
01106 template< class Pred > typename ConstDmmultipathCoI<Pred>::type dmmultipathCoCondEnd( const Pred& p ) const
01107 {
01108 IterPair<ContainerCDmmultipathIter> pair( ContainerCDmmultipathIter( cont.begin(), cont.end() ),
01109 ContainerCDmmultipathIter( cont.begin(), cont.end(), true ));
01110 return( typename ConstDmmultipathCoI<Pred>::type( typename ConstDmmultipathCoPI<Pred>::type( pair, p, true )) );
01111 }
01112 protected:
01113
01114 DmmultipathCoPair dmmCoPair( bool (* CheckFnc)( const DmmultipathCo& )=NULL )
01115 {
01116 return( DmmultipathCoPair( dmmCoBegin( CheckFnc ), dmmCoEnd( CheckFnc ) ));
01117 }
01118 DmmultipathCoIterator dmmCoBegin( bool (* CheckFnc)( const DmmultipathCo& )=NULL )
01119 {
01120 IterPair<ContainerDmmultipathIter> p( ContainerDmmultipathIter( cont.begin(), cont.end() ),
01121 ContainerDmmultipathIter( cont.begin(), cont.end(), true ));
01122 return( DmmultipathCoIterator( DmmultipathCoPIterator( p, CheckFnc )) );
01123 }
01124 DmmultipathCoIterator dmmCoEnd( bool (* CheckFnc)( const DmmultipathCo& )=NULL )
01125 {
01126 IterPair<ContainerDmmultipathIter> p( ContainerDmmultipathIter( cont.begin(), cont.end() ),
01127 ContainerDmmultipathIter( cont.begin(), cont.end(), true ));
01128 return( DmmultipathCoIterator( DmmultipathCoPIterator( p, CheckFnc, true )) );
01129 }
01130
01131
01132
01133 protected:
01134
01135 typedef CastCheckFncIterator<CCIter, isMdPart, const MdPartCo *> ContainerCMdPartIter;
01136 template< class Pred >
01137 struct ConstMdPartCoPI { typedef ContainerIter<Pred, ContainerCMdPartIter> type; };
01138 typedef CastCheckFncIterator<CIter, isMdPart, MdPartCo *> ContainerMdPartIter;
01139 template< class Pred >
01140 struct MdPartCoPI { typedef ContainerIter<Pred, ContainerMdPartIter> type; };
01141 template< class Pred >
01142 struct MdPartCoI { typedef ContainerDerIter<Pred, typename MdPartCoPI<Pred>::type, MdPartCo> type; };
01143 typedef CheckFnc<const MdPartCo> CheckFncMdPartCo;
01144 typedef CheckerIterator< CheckFncMdPartCo, ConstMdPartCoPI<CheckFncMdPartCo>::type,
01145 ContainerCMdPartIter, MdPartCo > ConstMdPartCoPIterator;
01146 typedef CheckerIterator< CheckFncMdPartCo, MdPartCoPI<CheckFncMdPartCo>::type,
01147 ContainerMdPartIter, MdPartCo > MdPartCoPIterator;
01148 typedef DerefIterator<MdPartCoPIterator,MdPartCo> MdPartCoIterator;
01149 typedef IterPair<MdPartCoIterator> MdPartCoPair;
01150
01151 public:
01152
01153 typedef DerefIterator<ConstMdPartCoPIterator,const MdPartCo> ConstMdPartCoIterator;
01154 template< class Pred >
01155 struct ConstMdPartCoI
01156 { typedef ContainerDerIter<Pred, typename ConstMdPartCoPI<Pred>::type,
01157 const MdPartCo> type; };
01158 template< class Pred >
01159 struct MdPartCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstMdPartCoI<Pred>::type> type; };
01160 typedef IterPair<ConstMdPartCoIterator> ConstMdPartCoPair;
01161
01162
01163 ConstMdPartCoPair mdpartCoPair( bool (* CheckFnc)( const MdPartCo& )=NULL ) const
01164 {
01165 return( ConstMdPartCoPair( mdpartCoBegin( CheckFnc ), mdpartCoEnd( CheckFnc ) ));
01166 }
01167 ConstMdPartCoIterator mdpartCoBegin( bool (* CheckFnc)( const MdPartCo& )=NULL ) const
01168 {
01169 IterPair<ContainerCMdPartIter> p( ContainerCMdPartIter( cont.begin(), cont.end() ),
01170 ContainerCMdPartIter( cont.begin(), cont.end(), true ));
01171 return( ConstMdPartCoIterator( ConstMdPartCoPIterator( p, CheckFnc )) );
01172 }
01173 ConstMdPartCoIterator mdpartCoEnd( bool (* CheckFnc)( const MdPartCo& )=NULL ) const
01174 {
01175 IterPair<ContainerCMdPartIter> p( ContainerCMdPartIter( cont.begin(), cont.end() ),
01176 ContainerCMdPartIter( cont.begin(), cont.end(), true ));
01177 return( ConstMdPartCoIterator( ConstMdPartCoPIterator( p, CheckFnc, true )) );
01178 }
01179 template< class Pred > typename MdPartCoCondIPair<Pred>::type mdPartCoCondPair( const Pred& p ) const
01180 {
01181 return( typename MdPartCoCondIPair<Pred>::type( mdpartCoCondBegin( p ), mdpartCoCondEnd( p ) ) );
01182 }
01183 template< class Pred > typename ConstMdPartCoI<Pred>::type mdpartCoCondBegin( const Pred& p ) const
01184 {
01185 IterPair<ContainerCMdPartIter> pair( ContainerCMdPartIter( cont.begin(), cont.end() ),
01186 ContainerCMdPartIter( cont.begin(), cont.end(), true ));
01187 return( typename ConstMdPartCoI<Pred>::type( typename ConstMdPartCoPI<Pred>::type( pair, p )) );
01188 }
01189 template< class Pred > typename ConstMdPartCoI<Pred>::type mdpartCoCondEnd( const Pred& p ) const
01190 {
01191 IterPair<ContainerCMdPartIter> pair( ContainerCMdPartIter( cont.begin(), cont.end() ),
01192 ContainerCMdPartIter( cont.begin(), cont.end(), true ));
01193 return( typename ConstMdPartCoI<Pred>::type( typename ConstMdPartCoPI<Pred>::type( pair, p, true )) );
01194 }
01195 protected:
01196
01197 MdPartCoPair mdpCoPair( bool (* CheckFnc)( const MdPartCo& )=NULL )
01198 {
01199 return( MdPartCoPair( mdpCoBegin( CheckFnc ), mdpCoEnd( CheckFnc ) ));
01200 }
01201 MdPartCoIterator mdpCoBegin( bool (* CheckFnc)( const MdPartCo& )=NULL )
01202 {
01203 IterPair<ContainerMdPartIter> p( ContainerMdPartIter( cont.begin(), cont.end() ),
01204 ContainerMdPartIter( cont.begin(), cont.end(), true ));
01205 return( MdPartCoIterator( MdPartCoPIterator( p, CheckFnc )) );
01206 }
01207 MdPartCoIterator mdpCoEnd( bool (* CheckFnc)( const MdPartCo& )=NULL )
01208 {
01209 IterPair<ContainerMdPartIter> p( ContainerMdPartIter( cont.begin(), cont.end() ),
01210 ContainerMdPartIter( cont.begin(), cont.end(), true ));
01211 return( MdPartCoIterator( MdPartCoPIterator( p, CheckFnc, true )) );
01212 }
01213
01214
01215
01216
01217 protected:
01218
01219 typedef ListListIterator<Container::ConstPlainIterator, ConstContIterator> ConstVolInter;
01220 template< class Pred >
01221 struct ConstVolumePI { typedef ContainerIter<Pred, ConstVolInter> type; };
01222 typedef CheckFnc<const Volume> CheckFncVol;
01223 typedef CheckerIterator< CheckFncVol, ConstVolumePI<CheckFncVol>::type,
01224 ConstVolInter, Volume > ConstVolPIterator;
01225 typedef ListListIterator<Container::PlainIterator, ContIterator> VolPart;
01226 template< class Pred >
01227 struct VolumeI { typedef ContainerIter<Pred, VolPart> type; };
01228 typedef CheckerIterator< CheckFncVol, VolumeI<CheckFncVol>::type,
01229 VolPart, Volume > VolPIterator;
01230 typedef DerefIterator<VolPIterator,Volume> VolIterator;
01231 typedef IterPair<VolIterator> VPair;
01232
01233 public:
01234
01235 template< class Pred >
01236 struct ConstVolumeI { typedef ContainerDerIter<Pred, typename ConstVolumePI<Pred>::type, const Volume> type; };
01237 template< class Pred >
01238 struct VolCondIPair { typedef MakeCondIterPair<Pred, typename ConstVolumeI<Pred>::type> type;};
01239 typedef DerefIterator<ConstVolPIterator,const Volume> ConstVolIterator;
01240 typedef IterPair<ConstVolIterator> ConstVolPair;
01241
01242
01243 ConstVolPair volPair( bool (* CheckCnt)( const Container& )) const
01244 {
01245 return( ConstVolPair( volBegin( CheckCnt ), volEnd( CheckCnt ) ));
01246 }
01247 ConstVolPair volPair( bool (* CheckVol)( const Volume& )=NULL,
01248 bool (* CheckCnt)( const Container& )=NULL) const
01249 {
01250 return( ConstVolPair( volBegin( CheckVol, CheckCnt ),
01251 volEnd( CheckVol, CheckCnt ) ));
01252 }
01253 ConstVolIterator volBegin( bool (* CheckCnt)( const Container& )) const
01254 {
01255 return( volBegin( NULL, CheckCnt ) );
01256 }
01257 ConstVolIterator volBegin( bool (* CheckVol)( const Volume& )=NULL,
01258 bool (* CheckCnt)( const Container& )=NULL) const
01259 {
01260 IterPair<ConstVolInter> p( (ConstVolInter( contPair( CheckCnt ))),
01261 (ConstVolInter( contPair( CheckCnt ), true )));
01262 return( ConstVolIterator( ConstVolPIterator(p, CheckVol )));
01263 }
01264 ConstVolIterator volEnd( bool (* CheckCnt)( const Container& )) const
01265 {
01266 return( volEnd( NULL, CheckCnt ) );
01267 }
01268 ConstVolIterator volEnd( bool (* CheckVol)( const Volume& )=NULL,
01269 bool (* CheckCnt)( const Container& )=NULL) const
01270 {
01271 IterPair<ConstVolInter> p( (ConstVolInter( contPair( CheckCnt ))),
01272 (ConstVolInter( contPair( CheckCnt ), true )));
01273 return( ConstVolIterator( ConstVolPIterator(p, CheckVol, true )));
01274 }
01275 template< class Pred > typename VolCondIPair<Pred>::type volCondPair( const Pred& p ) const
01276 {
01277 return( typename VolCondIPair<Pred>::type( volCondBegin( p ), volCondEnd( p ) ) );
01278 }
01279 template< class Pred > typename ConstVolumeI<Pred>::type volCondBegin( const Pred& p ) const
01280 {
01281 IterPair<ConstVolInter> pair( (ConstVolInter( contPair())),
01282 (ConstVolInter( contPair(), true )));
01283 return( typename ConstVolumeI<Pred>::type( typename ConstVolumePI<Pred>::type(pair, p) ) );
01284 }
01285 template< class Pred > typename ConstVolumeI<Pred>::type volCondEnd( const Pred& p ) const
01286 {
01287 IterPair<ConstVolInter> pair( (ConstVolInter( contPair())),
01288 (ConstVolInter( contPair(), true )));
01289 return( typename ConstVolumeI<Pred>::type( typename ConstVolumePI<Pred>::type(pair, p, true )) );
01290 }
01291
01292 protected:
01293
01294 VPair vPair( bool (* CheckCnt)( const Container& ))
01295 {
01296 return( VPair( vBegin( CheckCnt ), vEnd( CheckCnt ) ));
01297 }
01298 VPair vPair( bool (* CheckVol)( const Volume& )=NULL,
01299 bool (* CheckCnt)( const Container& )=NULL)
01300 {
01301 return( VPair( vBegin( CheckVol, CheckCnt ),
01302 vEnd( CheckVol, CheckCnt ) ));
01303 }
01304 VolIterator vBegin( bool (* CheckCnt)( const Container& ))
01305 {
01306 return( vBegin( NULL, CheckCnt ) );
01307 }
01308 VolIterator vBegin( bool (* CheckVol)( const Volume& )=NULL,
01309 bool (* CheckCnt)( const Container& )=NULL)
01310 {
01311 IterPair<VolPart> p( (VolPart( cPair( CheckCnt ))),
01312 (VolPart( cPair( CheckCnt ), true )));
01313 return( VolIterator( VolPIterator( p, CheckVol )));
01314 }
01315 VolIterator vEnd( bool (* CheckCnt)( const Container& ))
01316 {
01317 return( vEnd( NULL, CheckCnt ) );
01318 }
01319 VolIterator vEnd( bool (* CheckVol)( const Volume& )=NULL,
01320 bool (* CheckCnt)( const Container& )=NULL)
01321 {
01322 IterPair<VolPart> p( (VolPart( cPair( CheckCnt ))),
01323 (VolPart( cPair( CheckCnt ), true )));
01324 return( VolIterator( VolPIterator( p, CheckVol, true )));
01325 }
01326
01327
01328 protected:
01329
01330 typedef ListListIterator<Container::ConstPlainIterator, ConstDiskIterator> ConstPartInter;
01331 typedef CastIterator<ConstPartInter, Partition *> ConstPartInter2;
01332 template< class Pred >
01333 struct ConstPartitionPI { typedef ContainerIter<Pred, ConstPartInter2> type; };
01334 typedef CheckFnc<const Partition> CheckFncPartition;
01335 typedef CheckerIterator< CheckFncPartition, ConstPartitionPI<CheckFncPartition>::type,
01336 ConstPartInter2, Partition > ConstPartPIterator;
01337 public:
01338
01339 template< class Pred >
01340 struct ConstPartitionI
01341 { typedef ContainerDerIter<Pred, typename ConstPartitionPI<Pred>::type,
01342 const Partition> type; };
01343 template< class Pred >
01344 struct PartCondIPair
01345 { typedef MakeCondIterPair<Pred, typename ConstPartitionI<Pred>::type> type;};
01346 typedef DerefIterator<ConstPartPIterator, const Partition> ConstPartIterator;
01347 typedef IterPair<ConstPartIterator> ConstPartPair;
01348
01349
01350 ConstPartPair partPair( bool (* CheckCnt)( const Disk& )) const
01351 {
01352 return( ConstPartPair( partBegin( CheckCnt ), partEnd( CheckCnt ) ));
01353 }
01354 ConstPartPair partPair( bool (* CheckPart)( const Partition& )=NULL,
01355 bool (* CheckCnt)( const Disk& )=NULL) const
01356 {
01357 return( ConstPartPair( partBegin( CheckPart, CheckCnt ),
01358 partEnd( CheckPart, CheckCnt ) ));
01359 }
01360 ConstPartIterator partBegin( bool (* CheckDisk)( const Disk& )) const
01361 {
01362 return( partBegin( NULL, CheckDisk ) );
01363 }
01364 ConstPartIterator partBegin( bool (* CheckPart)( const Partition& )=NULL,
01365 bool (* CheckDisk)( const Disk& )=NULL) const
01366 {
01367 IterPair<ConstPartInter2> p( (ConstPartInter(diskPair( CheckDisk ))),
01368 (ConstPartInter(diskPair( CheckDisk ), true )));
01369 return( ConstPartIterator( ConstPartPIterator(p, CheckPart )));
01370 }
01371 ConstPartIterator partEnd( bool (* CheckDisk)( const Disk& )) const
01372 {
01373 return( partEnd( NULL, CheckDisk ) );
01374 }
01375 ConstPartIterator partEnd( bool (* CheckPart)( const Partition& )=NULL,
01376 bool (* CheckDisk)( const Disk& )=NULL) const
01377 {
01378 IterPair<ConstPartInter2> p( (ConstPartInter(diskPair( CheckDisk ))),
01379 (ConstPartInter(diskPair( CheckDisk ), true )));
01380 return( ConstPartIterator( ConstPartPIterator(p, CheckPart, true )));
01381 }
01382 template< class Pred > typename PartCondIPair<Pred>::type partCondPair( const Pred& p ) const
01383 {
01384 return( typename PartCondIPair<Pred>::type( partCondBegin( p ), partCondEnd( p ) ) );
01385 }
01386 template< class Pred > typename ConstPartitionI<Pred>::type partCondBegin( const Pred& p ) const
01387 {
01388 IterPair<ConstPartInter2> pair( (ConstPartInter( diskPair())),
01389 (ConstPartInter( diskPair(), true )));
01390 return( typename ConstPartitionI<Pred>::type( typename ConstPartitionPI<Pred>::type(pair, p) ) );
01391 }
01392 template< class Pred > typename ConstPartitionI<Pred>::type partCondEnd( const Pred& p ) const
01393 {
01394 IterPair<ConstPartInter2> pair( (ConstPartInter( diskPair())),
01395 (ConstPartInter( diskPair(), true )));
01396 return( typename ConstPartitionI<Pred>::type( typename ConstPartitionPI<Pred>::type(pair, p, true )) );
01397 }
01398
01399
01400 protected:
01401
01402 typedef ListListIterator<Container::ConstPlainIterator, ConstLvmVgIterator> ConstLvmLvInter;
01403 typedef CastIterator<ConstLvmLvInter, LvmLv *> ConstLvmLvInter2;
01404 template< class Pred >
01405 struct ConstLvmLvPI { typedef ContainerIter<Pred, ConstLvmLvInter2> type; };
01406 typedef CheckFnc<const LvmLv> CheckFncLvmLv;
01407 typedef CheckerIterator< CheckFncLvmLv, ConstLvmLvPI<CheckFncLvmLv>::type,
01408 ConstLvmLvInter2, LvmLv > ConstLvmLvPIterator;
01409 public:
01410
01411 template< class Pred >
01412 struct ConstLvmLvI
01413 { typedef ContainerDerIter<Pred, typename ConstLvmLvPI<Pred>::type,
01414 const LvmLv> type; };
01415 template< class Pred >
01416 struct LvmLvCondIPair
01417 { typedef MakeCondIterPair<Pred, typename ConstLvmLvI<Pred>::type> type;};
01418 typedef DerefIterator<ConstLvmLvPIterator, const LvmLv> ConstLvmLvIterator;
01419 typedef IterPair<ConstLvmLvIterator> ConstLvmLvPair;
01420
01421
01422 ConstLvmLvPair lvmLvPair( bool (* CheckLvmVg)( const LvmVg& )) const
01423 {
01424 return( ConstLvmLvPair( lvmLvBegin( CheckLvmVg ), lvmLvEnd( CheckLvmVg ) ));
01425 }
01426 ConstLvmLvPair lvmLvPair( bool (* CheckLvmLv)( const LvmLv& )=NULL,
01427 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
01428 {
01429 return( ConstLvmLvPair( lvmLvBegin( CheckLvmLv, CheckLvmVg ),
01430 lvmLvEnd( CheckLvmLv, CheckLvmVg ) ));
01431 }
01432 ConstLvmLvIterator lvmLvBegin( bool (* CheckLvmVg)( const LvmVg& )) const
01433 {
01434 return( lvmLvBegin( NULL, CheckLvmVg ) );
01435 }
01436 ConstLvmLvIterator lvmLvBegin( bool (* CheckLvmLv)( const LvmLv& )=NULL,
01437 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
01438 {
01439 IterPair<ConstLvmLvInter2> p( (ConstLvmLvInter(lvmVgPair( CheckLvmVg ))),
01440 (ConstLvmLvInter(lvmVgPair( CheckLvmVg ), true )));
01441 return( ConstLvmLvIterator( ConstLvmLvPIterator(p, CheckLvmLv )));
01442 }
01443 ConstLvmLvIterator lvmLvEnd( bool (* CheckLvmVg)( const LvmVg& )) const
01444 {
01445 return( lvmLvEnd( NULL, CheckLvmVg ) );
01446 }
01447 ConstLvmLvIterator lvmLvEnd( bool (* CheckLvmLv)( const LvmLv& )=NULL,
01448 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
01449 {
01450 IterPair<ConstLvmLvInter2> p( (ConstLvmLvInter(lvmVgPair( CheckLvmVg ))),
01451 (ConstLvmLvInter(lvmVgPair( CheckLvmVg ), true )));
01452 return( ConstLvmLvIterator( ConstLvmLvPIterator(p, CheckLvmLv, true )));
01453 }
01454 template< class Pred > typename LvmLvCondIPair<Pred>::type lvmLvCondPair( const Pred& p ) const
01455 {
01456 return( typename LvmLvCondIPair<Pred>::type( lvmLvCondBegin( p ), lvmLvCondEnd( p ) ) );
01457 }
01458 template< class Pred > typename ConstLvmLvI<Pred>::type lvmLvCondBegin( const Pred& p ) const
01459 {
01460 IterPair<ConstLvmLvInter2> pair( (ConstLvmLvInter( lvmVgPair())),
01461 (ConstLvmLvInter( lvmVgPair(), true )));
01462 return( typename ConstLvmLvI<Pred>::type( typename ConstLvmLvPI<Pred>::type(pair, p) ) );
01463 }
01464 template< class Pred > typename ConstLvmLvI<Pred>::type lvmLvCondEnd( const Pred& p ) const
01465 {
01466 IterPair<ConstLvmLvInter2> pair( (ConstLvmLvInter( lvmVgPair())),
01467 (ConstLvmLvInter( lvmVgPair(), true )));
01468 return( typename ConstLvmLvI<Pred>::type( typename ConstLvmLvPI<Pred>::type(pair, p, true )) );
01469 }
01470
01471
01472 protected:
01473
01474 typedef CastIterator<ConstVolInter, Md *> ConstMdInter;
01475 template< class Pred >
01476 struct ConstMdPI { typedef ContainerIter<Pred,
01477 ConstMdInter> type; };
01478 typedef CheckFnc<const Md> CheckFncMd;
01479 typedef CheckerIterator< CheckFncMd, ConstMdPI<CheckFncMd>::type,
01480 ConstMdInter, Md > ConstMdPIterator;
01481 public:
01482
01483 template< class Pred >
01484 struct ConstMdI
01485 { typedef ContainerDerIter<Pred, typename ConstMdPI<Pred>::type,
01486 const Md> type; };
01487 template< class Pred >
01488 struct MdCondIPair
01489 { typedef MakeCondIterPair<Pred, typename ConstMdI<Pred>::type> type;};
01490 typedef DerefIterator<ConstMdPIterator, const Md> ConstMdIterator;
01491 typedef IterPair<ConstMdIterator> ConstMdPair;
01492
01493
01494 ConstMdPair mdPair( bool (* CheckMd)( const Md& )=NULL ) const
01495 {
01496 return( ConstMdPair( mdBegin( CheckMd ), mdEnd( CheckMd ) ));
01497 }
01498 ConstMdIterator mdBegin( bool (* CheckMd)( const Md& )=NULL ) const
01499 {
01500 ConstVolInter b( contPair( isMd ) );
01501 ConstVolInter e( contPair( isMd ), true );
01502 IterPair<ConstMdInter> p( (ConstMdInter(b)), (ConstMdInter(e)) );
01503 return( ConstMdIterator( ConstMdPIterator(p, CheckMd )));
01504 }
01505 ConstMdIterator mdEnd( bool (* CheckMd)( const Md& )=NULL ) const
01506 {
01507 ConstVolInter b( contPair( isMd ) );
01508 ConstVolInter e( contPair( isMd ), true );
01509 IterPair<ConstMdInter> p( (ConstMdInter(b)), (ConstMdInter(e)) );
01510 return( ConstMdIterator( ConstMdPIterator(p, CheckMd, true )));
01511 }
01512 template< class Pred > typename MdCondIPair<Pred>::type mdCondPair( const Pred& p ) const
01513 {
01514 return( typename MdCondIPair<Pred>::type( mdCondBegin( p ), mdCondEnd( p ) ) );
01515 }
01516 template< class Pred > typename ConstMdI<Pred>::type mdCondBegin( const Pred& p ) const
01517 {
01518 ConstVolInter b( contPair( isMd ) );
01519 ConstVolInter e( contPair( isMd ), true );
01520 IterPair<ConstMdInter> pair( (ConstMdInter(b)), (ConstMdInter(e)) );
01521 return( typename ConstMdI<Pred>::type( typename ConstMdPI<Pred>::type(pair, p) ) );
01522 }
01523 template< class Pred > typename ConstMdI<Pred>::type mdCondEnd( const Pred& p ) const
01524 {
01525 ConstVolInter b( contPair( isMd ) );
01526 ConstVolInter e( contPair( isMd ), true );
01527 IterPair<ConstMdInter> pair( (ConstMdInter(b)), (ConstMdInter(e)) );
01528 return( typename ConstMdI<Pred>::type( typename ConstMdPI<Pred>::type(pair, p, true )) );
01529 }
01530
01532 protected:
01533
01534 typedef CastIterator<ConstVolInter, MdPart *> ConstMdPartInter;
01535 template< class Pred >
01536 struct ConstMdPartPI { typedef ContainerIter<Pred,
01537 ConstMdPartInter> type; };
01538 typedef CheckFnc<const MdPart> CheckFncMdPart;
01539 typedef CheckerIterator< CheckFncMdPart, ConstMdPartPI<CheckFncMdPart>::type,
01540 ConstMdPartInter, MdPart > ConstMdPartPIterator;
01541 public:
01542
01543 template< class Pred >
01544 struct ConstMdPartI
01545 { typedef ContainerDerIter<Pred, typename ConstMdPartPI<Pred>::type,
01546 const MdPart> type; };
01547 template< class Pred >
01548 struct MdPartCondIPair
01549 { typedef MakeCondIterPair<Pred, typename ConstMdPartI<Pred>::type> type;};
01550 typedef DerefIterator<ConstMdPartPIterator, const MdPart> ConstMdPartIterator;
01551 typedef IterPair<ConstMdPartIterator> ConstMdPartPair;
01552
01553
01554
01555 ConstMdPartPair mdPartPair( bool (* CheckMdPart)( const MdPart& )=NULL ) const
01556 {
01557 return( ConstMdPartPair( mdPartBegin( CheckMdPart ), mdPartEnd( CheckMdPart ) ));
01558 }
01559
01560 ConstMdPartIterator mdPartBegin( bool (* CheckMdPart)( const MdPart& )=NULL ) const
01561 {
01562 ConstVolInter b( contPair( isMdPart ) );
01563 ConstVolInter e( contPair( isMdPart ), true );
01564 IterPair<ConstMdPartInter> p( (ConstMdPartInter(b)), (ConstMdPartInter(e)) );
01565 return( ConstMdPartIterator( ConstMdPartPIterator(p, CheckMdPart )));
01566 }
01567 ConstMdPartIterator mdPartEnd( bool (* CheckMdPart)( const MdPart& )=NULL ) const
01568 {
01569 ConstVolInter b( contPair( isMdPart ) );
01570 ConstVolInter e( contPair( isMdPart ), true );
01571 IterPair<ConstMdPartInter> p( (ConstMdPartInter(b)), (ConstMdPartInter(e)) );
01572 return( ConstMdPartIterator( ConstMdPartPIterator(p, CheckMdPart, true )));
01573 }
01574 template< class Pred > typename MdPartCondIPair<Pred>::type mdPartCondPair( const Pred& p ) const
01575 {
01576 return( typename MdPartCondIPair<Pred>::type( mdPartCondBegin( p ), mdPartCondEnd( p ) ) );
01577 }
01578 template< class Pred > typename ConstMdPartI<Pred>::type mdPartCondBegin( const Pred& p ) const
01579 {
01580 ConstVolInter b( contPair( isMdPart ) );
01581 ConstVolInter e( contPair( isMdPart ), true );
01582 IterPair<ConstMdPartInter> pair( (ConstMdPartInter(b)), (ConstMdPartInter(e)) );
01583 return( typename ConstMdPartI<Pred>::type( typename ConstMdPartPI<Pred>::type(pair, p) ) );
01584 }
01585 template< class Pred > typename ConstMdPartI<Pred>::type mdPartCondEnd( const Pred& p ) const
01586 {
01587 ConstVolInter b( contPair( isMdPart ) );
01588 ConstVolInter e( contPair( isMdPart ), true );
01589 IterPair<ConstMdPartInter> pair( (ConstMdPartInter(b)), (ConstMdPartInter(e)) );
01590 return( typename ConstMdPartI<Pred>::type( typename ConstMdPartPI<Pred>::type(pair, p, true )) );
01591 }
01592
01593
01594
01595 protected:
01596
01597 typedef CastIterator<ConstVolInter, Loop *> ConstLoopInter;
01598 template< class Pred >
01599 struct ConstLoopPI { typedef ContainerIter<Pred,
01600 ConstLoopInter> type; };
01601 typedef CheckFnc<const Loop> CheckFncLoop;
01602 typedef CheckerIterator< CheckFncLoop, ConstLoopPI<CheckFncLoop>::type,
01603 ConstLoopInter, Loop > ConstLoopPIterator;
01604 public:
01605
01606 template< class Pred >
01607 struct ConstLoopI
01608 { typedef ContainerDerIter<Pred, typename ConstLoopPI<Pred>::type,
01609 const Loop> type; };
01610 template< class Pred >
01611 struct LoopCondIPair
01612 { typedef MakeCondIterPair<Pred, typename ConstLoopI<Pred>::type> type;};
01613 typedef DerefIterator<ConstLoopPIterator, const Loop> ConstLoopIterator;
01614 typedef IterPair<ConstLoopIterator> ConstLoopPair;
01615
01616
01617 ConstLoopPair loopPair( bool (* CheckLoop)( const Loop& )=NULL ) const
01618 {
01619 return( ConstLoopPair( loopBegin( CheckLoop ), loopEnd( CheckLoop ) ));
01620 }
01621 ConstLoopIterator loopBegin( bool (* CheckLoop)( const Loop& )=NULL ) const
01622 {
01623 ConstVolInter b( contPair( isLoop ) );
01624 ConstVolInter e( contPair( isLoop ), true );
01625 IterPair<ConstLoopInter> p( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01626 return( ConstLoopIterator( ConstLoopPIterator(p, CheckLoop )));
01627 }
01628 ConstLoopIterator loopEnd( bool (* CheckLoop)( const Loop& )=NULL ) const
01629 {
01630 ConstVolInter b( contPair( isLoop ) );
01631 ConstVolInter e( contPair( isLoop ), true );
01632 IterPair<ConstLoopInter> p( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01633 return( ConstLoopIterator( ConstLoopPIterator(p, CheckLoop, true )));
01634 }
01635 template< class Pred > typename LoopCondIPair<Pred>::type loopCondPair( const Pred& p ) const
01636 {
01637 return( typename LoopCondIPair<Pred>::type( loopCondBegin( p ), loopCondEnd( p ) ) );
01638 }
01639 template< class Pred > typename ConstLoopI<Pred>::type loopCondBegin( const Pred& p ) const
01640 {
01641 ConstVolInter b( contPair( isLoop ) );
01642 ConstVolInter e( contPair( isLoop ), true );
01643 IterPair<ConstLoopInter> pair( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01644 return( typename ConstLoopI<Pred>::type( typename ConstLoopPI<Pred>::type(pair, p) ) );
01645 }
01646 template< class Pred > typename ConstLoopI<Pred>::type loopCondEnd( const Pred& p ) const
01647 {
01648 ConstVolInter b( contPair( isLoop ) );
01649 ConstVolInter e( contPair( isLoop ), true );
01650 IterPair<ConstLoopInter> pair( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01651 return( typename ConstLoopI<Pred>::type( typename ConstLoopPI<Pred>::type(pair, p, true )) );
01652 }
01653
01654
01655 protected:
01656
01657 typedef CastIterator<ConstVolInter, Btrfs *> ConstBtrfsInter;
01658 template< class Pred >
01659 struct ConstBtrfsPI { typedef ContainerIter<Pred,
01660 ConstBtrfsInter> type; };
01661 typedef CheckFnc<const Btrfs> CheckFncBtrfs;
01662 typedef CheckerIterator< CheckFncBtrfs, ConstBtrfsPI<CheckFncBtrfs>::type,
01663 ConstBtrfsInter, Btrfs > ConstBtrfsPIterator;
01664 public:
01665
01666 template< class Pred >
01667 struct ConstBtrfsI
01668 { typedef ContainerDerIter<Pred, typename ConstBtrfsPI<Pred>::type,
01669 const Btrfs> type; };
01670 template< class Pred >
01671 struct BtrfsCondIPair
01672 { typedef MakeCondIterPair<Pred, typename ConstBtrfsI<Pred>::type> type;};
01673 typedef DerefIterator<ConstBtrfsPIterator, const Btrfs> ConstBtrfsIterator;
01674 typedef IterPair<ConstBtrfsIterator> ConstBtrfsPair;
01675
01676
01677 ConstBtrfsPair btrfsPair( bool (* CheckBtrfs)( const Btrfs& )=NULL ) const
01678 {
01679 return( ConstBtrfsPair( btrfsBegin( CheckBtrfs ), btrfsEnd( CheckBtrfs ) ));
01680 }
01681 ConstBtrfsIterator btrfsBegin( bool (* CheckBtrfs)( const Btrfs& )=NULL ) const
01682 {
01683 ConstVolInter b( contPair( isBtrfs ) );
01684 ConstVolInter e( contPair( isBtrfs ), true );
01685 IterPair<ConstBtrfsInter> p( (ConstBtrfsInter(b)), (ConstBtrfsInter(e)) );
01686 return( ConstBtrfsIterator( ConstBtrfsPIterator(p, CheckBtrfs )));
01687 }
01688 ConstBtrfsIterator btrfsEnd( bool (* CheckBtrfs)( const Btrfs& )=NULL ) const
01689 {
01690 ConstVolInter b( contPair( isBtrfs ) );
01691 ConstVolInter e( contPair( isBtrfs ), true );
01692 IterPair<ConstBtrfsInter> p( (ConstBtrfsInter(b)), (ConstBtrfsInter(e)) );
01693 return( ConstBtrfsIterator( ConstBtrfsPIterator(p, CheckBtrfs, true )));
01694 }
01695 template< class Pred > typename BtrfsCondIPair<Pred>::type btrfsCondPair( const Pred& p ) const
01696 {
01697 return( typename BtrfsCondIPair<Pred>::type( btrfsCondBegin( p ), btrfsCondEnd( p ) ) );
01698 }
01699 template< class Pred > typename ConstBtrfsI<Pred>::type btrfsCondBegin( const Pred& p ) const
01700 {
01701 ConstVolInter b( contPair( isBtrfs ) );
01702 ConstVolInter e( contPair( isBtrfs ), true );
01703 IterPair<ConstBtrfsInter> pair( (ConstBtrfsInter(b)), (ConstBtrfsInter(e)) );
01704 return( typename ConstBtrfsI<Pred>::type( typename ConstBtrfsPI<Pred>::type(pair, p) ) );
01705 }
01706 template< class Pred > typename ConstBtrfsI<Pred>::type btrfsCondEnd( const Pred& p ) const
01707 {
01708 ConstVolInter b( contPair( isBtrfs ) );
01709 ConstVolInter e( contPair( isBtrfs ), true );
01710 IterPair<ConstBtrfsInter> pair( (ConstBtrfsInter(b)), (ConstBtrfsInter(e)) );
01711 return( typename ConstBtrfsI<Pred>::type( typename ConstBtrfsPI<Pred>::type(pair, p, true )) );
01712 }
01713
01714
01715 protected:
01716
01717 typedef CastIterator<ConstVolInter, Tmpfs *> ConstTmpfsInter;
01718 template< class Pred >
01719 struct ConstTmpfsPI { typedef ContainerIter<Pred,
01720 ConstTmpfsInter> type; };
01721 typedef CheckFnc<const Tmpfs> CheckFncTmpfs;
01722 typedef CheckerIterator< CheckFncTmpfs, ConstTmpfsPI<CheckFncTmpfs>::type,
01723 ConstTmpfsInter, Tmpfs > ConstTmpfsPIterator;
01724 public:
01725
01726 template< class Pred >
01727 struct ConstTmpfsI
01728 { typedef ContainerDerIter<Pred, typename ConstTmpfsPI<Pred>::type,
01729 const Tmpfs> type; };
01730 template< class Pred >
01731 struct TmpfsCondIPair
01732 { typedef MakeCondIterPair<Pred, typename ConstTmpfsI<Pred>::type> type;};
01733 typedef DerefIterator<ConstTmpfsPIterator, const Tmpfs> ConstTmpfsIterator;
01734 typedef IterPair<ConstTmpfsIterator> ConstTmpfsPair;
01735
01736
01737 ConstTmpfsPair tmpfsPair( bool (* CheckTmpfs)( const Tmpfs& )=NULL ) const
01738 {
01739 return( ConstTmpfsPair( tmpfsBegin( CheckTmpfs ), tmpfsEnd( CheckTmpfs ) ));
01740 }
01741 ConstTmpfsIterator tmpfsBegin( bool (* CheckTmpfs)( const Tmpfs& )=NULL ) const
01742 {
01743 ConstVolInter b( contPair( isTmpfs ) );
01744 ConstVolInter e( contPair( isTmpfs ), true );
01745 IterPair<ConstTmpfsInter> p( (ConstTmpfsInter(b)), (ConstTmpfsInter(e)) );
01746 return( ConstTmpfsIterator( ConstTmpfsPIterator(p, CheckTmpfs )));
01747 }
01748 ConstTmpfsIterator tmpfsEnd( bool (* CheckTmpfs)( const Tmpfs& )=NULL ) const
01749 {
01750 ConstVolInter b( contPair( isTmpfs ) );
01751 ConstVolInter e( contPair( isTmpfs ), true );
01752 IterPair<ConstTmpfsInter> p( (ConstTmpfsInter(b)), (ConstTmpfsInter(e)) );
01753 return( ConstTmpfsIterator( ConstTmpfsPIterator(p, CheckTmpfs, true )));
01754 }
01755 template< class Pred > typename TmpfsCondIPair<Pred>::type tmpfsCondPair( const Pred& p ) const
01756 {
01757 return( typename TmpfsCondIPair<Pred>::type( tmpfsCondBegin( p ), tmpfsCondEnd( p ) ) );
01758 }
01759 template< class Pred > typename ConstTmpfsI<Pred>::type tmpfsCondBegin( const Pred& p ) const
01760 {
01761 ConstVolInter b( contPair( isTmpfs ) );
01762 ConstVolInter e( contPair( isTmpfs ), true );
01763 IterPair<ConstTmpfsInter> pair( (ConstTmpfsInter(b)), (ConstTmpfsInter(e)) );
01764 return( typename ConstTmpfsI<Pred>::type( typename ConstTmpfsPI<Pred>::type(pair, p) ) );
01765 }
01766 template< class Pred > typename ConstTmpfsI<Pred>::type tmpfsCondEnd( const Pred& p ) const
01767 {
01768 ConstVolInter b( contPair( isTmpfs ) );
01769 ConstVolInter e( contPair( isTmpfs ), true );
01770 IterPair<ConstTmpfsInter> pair( (ConstTmpfsInter(b)), (ConstTmpfsInter(e)) );
01771 return( typename ConstTmpfsI<Pred>::type( typename ConstTmpfsPI<Pred>::type(pair, p, true )) );
01772 }
01773
01774
01775 protected:
01776
01777 typedef CastIterator<ConstVolInter, Nfs *> ConstNfsInter;
01778 template< class Pred >
01779 struct ConstNfsPI { typedef ContainerIter<Pred,
01780 ConstNfsInter> type; };
01781 typedef CheckFnc<const Nfs> CheckFncNfs;
01782 typedef CheckerIterator< CheckFncNfs, ConstNfsPI<CheckFncNfs>::type,
01783 ConstNfsInter, Nfs > ConstNfsPIterator;
01784 public:
01785
01786 template< class Pred >
01787 struct ConstNfsI
01788 { typedef ContainerDerIter<Pred, typename ConstNfsPI<Pred>::type,
01789 const Nfs> type; };
01790 template< class Pred >
01791 struct NfsCondIPair
01792 { typedef MakeCondIterPair<Pred, typename ConstNfsI<Pred>::type> type;};
01793 typedef DerefIterator<ConstNfsPIterator, const Nfs> ConstNfsIterator;
01794 typedef IterPair<ConstNfsIterator> ConstNfsPair;
01795
01796
01797 ConstNfsPair nfsPair( bool (* CheckNfs)( const Nfs& )=NULL ) const
01798 {
01799 return( ConstNfsPair( nfsBegin( CheckNfs ), nfsEnd( CheckNfs ) ));
01800 }
01801 ConstNfsIterator nfsBegin( bool (* CheckNfs)( const Nfs& )=NULL ) const
01802 {
01803 ConstVolInter b( contPair( isNfs ) );
01804 ConstVolInter e( contPair( isNfs ), true );
01805 IterPair<ConstNfsInter> p( (ConstNfsInter(b)), (ConstNfsInter(e)) );
01806 return( ConstNfsIterator( ConstNfsPIterator(p, CheckNfs )));
01807 }
01808 ConstNfsIterator nfsEnd( bool (* CheckNfs)( const Nfs& )=NULL ) const
01809 {
01810 ConstVolInter b( contPair( isNfs ) );
01811 ConstVolInter e( contPair( isNfs ), true );
01812 IterPair<ConstNfsInter> p( (ConstNfsInter(b)), (ConstNfsInter(e)) );
01813 return( ConstNfsIterator( ConstNfsPIterator(p, CheckNfs, true )));
01814 }
01815 template< class Pred > typename NfsCondIPair<Pred>::type nfsCondPair( const Pred& p ) const
01816 {
01817 return( typename NfsCondIPair<Pred>::type( nfsCondBegin( p ), nfsCondEnd( p ) ) );
01818 }
01819 template< class Pred > typename ConstNfsI<Pred>::type nfsCondBegin( const Pred& p ) const
01820 {
01821 ConstVolInter b( contPair( isNfs ) );
01822 ConstVolInter e( contPair( isNfs ), true );
01823 IterPair<ConstNfsInter> pair( (ConstNfsInter(b)), (ConstNfsInter(e)) );
01824 return( typename ConstNfsI<Pred>::type( typename ConstNfsPI<Pred>::type(pair, p) ) );
01825 }
01826 template< class Pred > typename ConstNfsI<Pred>::type nfsCondEnd( const Pred& p ) const
01827 {
01828 ConstVolInter b( contPair( isNfs ) );
01829 ConstVolInter e( contPair( isNfs ), true );
01830 IterPair<ConstNfsInter> pair( (ConstNfsInter(b)), (ConstNfsInter(e)) );
01831 return( typename ConstNfsI<Pred>::type( typename ConstNfsPI<Pred>::type(pair, p, true )) );
01832 }
01833
01834
01835 protected:
01836
01837 typedef CastIterator<ConstVolInter, Dm *> ConstDmInter;
01838 template< class Pred >
01839 struct ConstDmPI { typedef ContainerIter<Pred,
01840 ConstDmInter> type; };
01841 typedef CheckFnc<const Dm> CheckFncDm;
01842 typedef CheckerIterator< CheckFncDm, ConstDmPI<CheckFncDm>::type,
01843 ConstDmInter, Dm > ConstDmPIterator;
01844 public:
01845
01846 template< class Pred >
01847 struct ConstDmI
01848 { typedef ContainerDerIter<Pred, typename ConstDmPI<Pred>::type,
01849 const Dm> type; };
01850 template< class Pred >
01851 struct DmCondIPair
01852 { typedef MakeCondIterPair<Pred, typename ConstDmI<Pred>::type> type;};
01853 typedef DerefIterator<ConstDmPIterator, const Dm> ConstDmIterator;
01854 typedef IterPair<ConstDmIterator> ConstDmPair;
01855
01856
01857 ConstDmPair dmPair( bool (* CheckDm)( const Dm& )=NULL ) const
01858 {
01859 return( ConstDmPair( dmBegin( CheckDm ), dmEnd( CheckDm ) ));
01860 }
01861 ConstDmIterator dmBegin( bool (* CheckDm)( const Dm& )=NULL ) const
01862 {
01863 ConstVolInter b( contPair( isDm ) );
01864 ConstVolInter e( contPair( isDm ), true );
01865 IterPair<ConstDmInter> p( (ConstDmInter(b)), (ConstDmInter(e)) );
01866 return( ConstDmIterator( ConstDmPIterator(p, CheckDm )));
01867 }
01868 ConstDmIterator dmEnd( bool (* CheckDm)( const Dm& )=NULL ) const
01869 {
01870 ConstVolInter b( contPair( isDm ) );
01871 ConstVolInter e( contPair( isDm ), true );
01872 IterPair<ConstDmInter> p( (ConstDmInter(b)), (ConstDmInter(e)) );
01873 return( ConstDmIterator( ConstDmPIterator(p, CheckDm, true )));
01874 }
01875 template< class Pred > typename DmCondIPair<Pred>::type dmCondPair( const Pred& p ) const
01876 {
01877 return( typename DmCondIPair<Pred>::type( dmCondBegin( p ), dmCondEnd( p ) ) );
01878 }
01879 template< class Pred > typename ConstDmI<Pred>::type dmCondBegin( const Pred& p ) const
01880 {
01881 ConstVolInter b( contPair( isDm ) );
01882 ConstVolInter e( contPair( isDm ), true );
01883 IterPair<ConstDmInter> pair( (ConstDmInter(b)), (ConstDmInter(e)) );
01884 return( typename ConstDmI<Pred>::type( typename ConstDmPI<Pred>::type(pair, p) ) );
01885 }
01886 template< class Pred > typename ConstDmI<Pred>::type dmCondEnd( const Pred& p ) const
01887 {
01888 ConstVolInter b( contPair( isDm ) );
01889 ConstVolInter e( contPair( isDm ), true );
01890 IterPair<ConstDmInter> pair( (ConstDmInter(b)), (ConstDmInter(e)) );
01891 return( typename ConstDmI<Pred>::type( typename ConstDmPI<Pred>::type(pair, p, true )) );
01892 }
01893
01894
01895 protected:
01896
01897 typedef ListListIterator<Container::ConstPlainIterator, ConstDmraidCoIterator> ConstDmraidInter;
01898 typedef CastIterator<ConstDmraidInter, Dmraid *> ConstDmraidInter2;
01899 template< class Pred >
01900 struct ConstDmraidPI { typedef ContainerIter<Pred, ConstDmraidInter2> type; };
01901 typedef CheckFnc<const Dmraid> CheckFncDmraid;
01902 typedef CheckerIterator< CheckFncDmraid, ConstDmraidPI<CheckFncDmraid>::type,
01903 ConstDmraidInter2, Dmraid > ConstDmraidPIterator;
01904 public:
01905
01906 template< class Pred >
01907 struct ConstDmraidI
01908 { typedef ContainerDerIter<Pred, typename ConstDmraidPI<Pred>::type,
01909 const Dmraid> type; };
01910 template< class Pred >
01911 struct DmraidCondIPair
01912 { typedef MakeCondIterPair<Pred, typename ConstDmraidI<Pred>::type> type;};
01913 typedef DerefIterator<ConstDmraidPIterator, const Dmraid> ConstDmraidIterator;
01914 typedef IterPair<ConstDmraidIterator> ConstDmraidPair;
01915
01916
01917 ConstDmraidPair dmrPair( bool (* CheckDmraidCo)( const DmraidCo& )) const
01918 {
01919 return( ConstDmraidPair( dmrBegin( CheckDmraidCo ), dmrEnd( CheckDmraidCo ) ));
01920 }
01921 ConstDmraidPair dmrPair( bool (* CheckDmraid)( const Dmraid& )=NULL,
01922 bool (* CheckDmraidCo)( const DmraidCo& )=NULL) const
01923 {
01924 return( ConstDmraidPair( dmrBegin( CheckDmraid, CheckDmraidCo ),
01925 dmrEnd( CheckDmraid, CheckDmraidCo ) ));
01926 }
01927 ConstDmraidIterator dmrBegin( bool (* CheckDmraidCo)( const DmraidCo& )) const
01928 {
01929 return( dmrBegin( NULL, CheckDmraidCo ) );
01930 }
01931 ConstDmraidIterator dmrBegin( bool (* CheckDmraid)( const Dmraid& )=NULL,
01932 bool (* CheckDmraidCo)( const DmraidCo& )=NULL) const
01933 {
01934 IterPair<ConstDmraidInter2> p( (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ))),
01935 (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ), true )));
01936 return( ConstDmraidIterator( ConstDmraidPIterator(p, CheckDmraid )));
01937 }
01938 ConstDmraidIterator dmrEnd( bool (* CheckDmraidCo)( const DmraidCo& )) const
01939 {
01940 return( dmrEnd( NULL, CheckDmraidCo ) );
01941 }
01942 ConstDmraidIterator dmrEnd( bool (* CheckDmraid)( const Dmraid& )=NULL,
01943 bool (* CheckDmraidCo)( const DmraidCo& )=NULL) const
01944 {
01945 IterPair<ConstDmraidInter2> p( (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ))),
01946 (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ), true )));
01947 return( ConstDmraidIterator( ConstDmraidPIterator(p, CheckDmraid, true )));
01948 }
01949 template< class Pred > typename DmraidCondIPair<Pred>::type dmrCondPair( const Pred& p ) const
01950 {
01951 return( typename DmraidCondIPair<Pred>::type( dmrCondBegin( p ), dmrCondEnd( p ) ) );
01952 }
01953 template< class Pred > typename ConstDmraidI<Pred>::type dmrCondBegin( const Pred& p ) const
01954 {
01955 IterPair<ConstDmraidInter2> pair( (ConstDmraidInter( dmraidCoPair())),
01956 (ConstDmraidInter( dmraidCoPair(), true )));
01957 return( typename ConstDmraidI<Pred>::type( typename ConstDmraidPI<Pred>::type(pair, p) ) );
01958 }
01959 template< class Pred > typename ConstDmraidI<Pred>::type dmrCondEnd( const Pred& p ) const
01960 {
01961 IterPair<ConstDmraidInter2> pair( (ConstDmraidInter( dmraidCoPair())),
01962 (ConstDmraidInter( dmraidCoPair(), true )));
01963 return( typename ConstDmraidI<Pred>::type( typename ConstDmraidPI<Pred>::type(pair, p, true )) );
01964 }
01965
01966
01967
01968 protected:
01969
01970 typedef ListListIterator<Container::ConstPlainIterator, ConstDmmultipathCoIterator> ConstDmmultipathInter;
01971 typedef CastIterator<ConstDmmultipathInter, Dmmultipath *> ConstDmmultipathInter2;
01972 template< class Pred >
01973 struct ConstDmmultipathPI { typedef ContainerIter<Pred, ConstDmmultipathInter2> type; };
01974 typedef CheckFnc<const Dmmultipath> CheckFncDmmultipath;
01975 typedef CheckerIterator< CheckFncDmmultipath, ConstDmmultipathPI<CheckFncDmmultipath>::type,
01976 ConstDmmultipathInter2, Dmmultipath > ConstDmmultipathPIterator;
01977 public:
01978
01979 template< class Pred >
01980 struct ConstDmmultipathI
01981 { typedef ContainerDerIter<Pred, typename ConstDmmultipathPI<Pred>::type,
01982 const Dmmultipath> type; };
01983 template< class Pred >
01984 struct DmmultipathCondIPair
01985 { typedef MakeCondIterPair<Pred, typename ConstDmmultipathI<Pred>::type> type; };
01986 typedef DerefIterator<ConstDmmultipathPIterator, const Dmmultipath> ConstDmmultipathIterator;
01987 typedef IterPair<ConstDmmultipathIterator> ConstDmmultipathPair;
01988
01989
01990 ConstDmmultipathPair dmmPair( bool (* CheckDmmultipathCo)( const DmmultipathCo& )) const
01991 {
01992 return( ConstDmmultipathPair( dmmBegin( CheckDmmultipathCo ), dmmEnd( CheckDmmultipathCo ) ));
01993 }
01994 ConstDmmultipathPair dmmPair( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL,
01995 bool (* CheckDmmultipathCo)( const DmmultipathCo& )=NULL) const
01996 {
01997 return( ConstDmmultipathPair( dmmBegin( CheckDmmultipath, CheckDmmultipathCo ),
01998 dmmEnd( CheckDmmultipath, CheckDmmultipathCo ) ));
01999 }
02000 ConstDmmultipathIterator dmmBegin( bool (* CheckDmmultipathCo)( const DmmultipathCo& )) const
02001 {
02002 return( dmmBegin( NULL, CheckDmmultipathCo ) );
02003 }
02004 ConstDmmultipathIterator dmmBegin( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL,
02005 bool (* CheckDmmultipathCo)( const DmmultipathCo& )=NULL) const
02006 {
02007 IterPair<ConstDmmultipathInter2> p( (ConstDmmultipathInter(dmmultipathCoPair( CheckDmmultipathCo ))),
02008 (ConstDmmultipathInter(dmmultipathCoPair( CheckDmmultipathCo ), true )));
02009 return( ConstDmmultipathIterator( ConstDmmultipathPIterator(p, CheckDmmultipath )));
02010 }
02011 ConstDmmultipathIterator dmmEnd( bool (* CheckDmmultipathCo)( const DmmultipathCo& )) const
02012 {
02013 return( dmmEnd( NULL, CheckDmmultipathCo ) );
02014 }
02015 ConstDmmultipathIterator dmmEnd( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL,
02016 bool (* CheckDmmultipathCo)( const DmmultipathCo& )=NULL) const
02017 {
02018 IterPair<ConstDmmultipathInter2> p( (ConstDmmultipathInter(dmmultipathCoPair( CheckDmmultipathCo ))),
02019 (ConstDmmultipathInter(dmmultipathCoPair( CheckDmmultipathCo ), true )));
02020 return( ConstDmmultipathIterator( ConstDmmultipathPIterator(p, CheckDmmultipath, true )));
02021 }
02022 template< class Pred > typename DmmultipathCondIPair<Pred>::type dmmCondPair( const Pred& p ) const
02023 {
02024 return( typename DmmultipathCondIPair<Pred>::type( dmmCondBegin( p ), dmmCondEnd( p ) ) );
02025 }
02026 template< class Pred > typename ConstDmmultipathI<Pred>::type dmmCondBegin( const Pred& p ) const
02027 {
02028 IterPair<ConstDmmultipathInter2> pair( (ConstDmmultipathInter( dmmultipathCoPair())),
02029 (ConstDmmultipathInter( dmmultipathCoPair(), true )));
02030 return( typename ConstDmmultipathI<Pred>::type( typename ConstDmmultipathPI<Pred>::type(pair, p) ) );
02031 }
02032 template< class Pred > typename ConstDmmultipathI<Pred>::type dmmCondEnd( const Pred& p ) const
02033 {
02034 IterPair<ConstDmmultipathInter2> pair( (ConstDmmultipathInter( dmmultipathCoPair())),
02035 (ConstDmmultipathInter( dmmultipathCoPair(), true )));
02036 return( typename ConstDmmultipathI<Pred>::type( typename ConstDmmultipathPI<Pred>::type(pair, p, true )) );
02037 }
02038
02039
02040 protected:
02041
02042 void initialize();
02043 void logSystemInfo() const;
02044 void detectDisks(SystemInfo& systeminfo);
02045 void autodetectDisks(SystemInfo& systeminfo);
02046 void detectMds(SystemInfo& systeminfo);
02047 void detectBtrfs(SystemInfo& systeminfo);
02048 void detectMdParts(SystemInfo& systeminfo);
02049 void decideMultipath();
02050 bool discoverMdPVols();
02051 void detectLoops(SystemInfo& systeminfo);
02052 void detectNfs(const EtcFstab& fstab, SystemInfo& systeminfo);
02053 void detectTmpfs(const EtcFstab& fstab, SystemInfo& systeminfo);
02054 void detectLvmVgs(SystemInfo& systeminfo);
02055 void detectDmraid(SystemInfo& systeminfo);
02056 void detectDmmultipath(SystemInfo& systeminfo);
02057 void detectDm(SystemInfo& systeminfo, bool only_crypt);
02058 void initDisk( list<DiskData>& dl, SystemInfo& systeminfo);
02059 void detectFsData(const VolIterator& begin, const VolIterator& end,
02060 SystemInfo& systeminfo);
02061 int updatePartitionArea(const string& device, unsigned long start,
02062 unsigned long size, bool noBtrfs );
02063 int resizeVolume(const string& device, unsigned long long newSizeK,
02064 bool ignore_fs);
02065 int resizeVolume(const string& device, unsigned long long newSizeK,
02066 bool ignore_fs, bool noBtrfs );
02067 int resizePartition( const string& device, unsigned long sizeCyl,
02068 bool ignore_fs );
02069 int resizePartition( const string& device, unsigned long sizeCyl,
02070 bool ignoreFs, bool noBtrfs );
02071 void addToList(Container* e);
02072 DiskIterator findDisk( const string& disk );
02073 DiskIterator findDiskId( const string& id );
02074 DiskIterator findDiskPath( const string& path );
02075 LvmVgIterator findLvmVg( const string& name );
02076 DmraidCoIterator findDmraidCo( const string& name );
02077 DmmultipathCoIterator findDmmultipathCo( const string& name );
02078 DmPartCoIterator findDmPartCo( const string& name );
02079
02080 MdPartCoIterator findMdPartCo( const string& name );
02081
02082 bool findVolume( const string& device, ContIterator& c,
02083 VolIterator& v, bool no_btrfs=false );
02084 bool findVolume( const string& device, ConstContIterator& c,
02085 ConstVolIterator& v, bool no_btrfs=false );
02086 bool findVolume( const string& device, VolIterator& v,
02087 bool also_del=false, bool no_btrfs=false );
02088 bool findVolume( const string& device, ConstVolIterator& v,
02089 bool also_del=false, bool no_btrfs=false );
02090 bool findContainer( const string& device, ContIterator& c );
02091 bool findContainer( const string& device, ConstContIterator& c );
02092
02093 Device* findDevice(const string& dev, bool no_btrfs=false);
02094
02095 void checkPwdBuf( const string& device );
02096
02097 bool haveMd( MdCo*& md );
02098 list<unsigned> getMdPartMdNums() const;
02099 bool haveDm(DmCo*& dm);
02100 bool haveNfs( NfsCo*& co );
02101 bool haveLoop( LoopCo*& loop );
02102 bool haveBtrfs( BtrfsCo*& co );
02103 bool haveTmpfs( TmpfsCo*& co );
02104 int removeContainer( Container* val );
02105 void logContainersAndVolumes(const string& Dir) const;
02106
02107 int commitPair( CPair& p, bool (* fnc)( const Container& ) );
02108 void sortCommitLists(storage::CommitStage stage, list<const Container*>& co,
02109 list<const Volume*>& vl, list<commitAction>& todo) const;
02110 bool ignoreError(int error, list<commitAction>::const_iterator ca) const;
02111 string backupStates() const;
02112 void detectObjects();
02113 void deleteBackups();
02114
02115 void setCachedFreeInfo(const string& device, bool resize_cached, const ResizeInfo& resize_info,
02116 bool content_cached, const ContentInfo& content_info);
02117 bool getCachedFreeInfo( const string& device, bool get_resize, ResizeInfo& resize_info,
02118 bool get_content, ContentInfo& content_info) const;
02119 void logFreeInfo(const string& Dir) const;
02120 void readFreeInfo(const string& file);
02121
02122 void logArchInfo(const string& Dir) const;
02123 void readArchInfo(const string& file);
02124
02125 list<commitAction> getCommitActions() const;
02126
02127
02128 const Environment env;
02129 Lock lock;
02130 bool cache;
02131 bool initialized;
02132 bool recursiveRemove;
02133 bool zeroNewPartitions;
02134 PartAlign partAlignment;
02135 MountByType defaultMountBy;
02136 FsType defaultFs;
02137 string defaultSubvolName;
02138 bool detectMounted;
02139 bool root_mounted;
02140 string tempdir;
02141 string rootprefix;
02142 unsigned hald_pid;
02143
02144 ArchInfo archinfo;
02145
02146 CCont cont;
02147 EtcFstab *fstab;
02148 EtcMdadm* mdadm;
02149
02150 ImsmDriver imsm_driver;
02151 MultipathAutostart multipath_autostart;
02152
02153 CallbackProgressBar progress_bar_cb;
02154 CallbackShowInstallInfo install_info_cb;
02155 CallbackInfoPopup info_popup_cb;
02156 CallbackYesNoPopup yesno_popup_cb;
02157 CallbackCommitErrorPopup commit_error_popup_cb;
02158 CallbackPasswordPopup password_popup_cb;
02159
02160 friend std::ostream& operator<<(std::ostream& s, const Storage& v);
02161 friend std::ostream& operator<<(std::ostream& s, Storage& v);
02162
02163 map<string, list<UsedBy>> danglingUsedBy;
02164
02165 static list<string> tmp_dirs;
02166
02167 unsigned max_log_num;
02168 Text lastAction;
02169 string extendedError;
02170 std::map<string,CCont> backups;
02171 map<string, FreeInfo> free_infos;
02172 std::map<string,string> pwdBuf;
02173 std::list<std::pair<string, Text>> infoPopupTxts;
02174 };
02175
02176 }
02177
02178 #endif