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