00001 #ifndef LOOP_H
00002 #define LOOP_H
00003
00004 #include "y2storage/Volume.h"
00005
00006 namespace storage
00007 {
00008 class LoopCo;
00009 class ProcPart;
00010
00011 class Loop : public Volume
00012 {
00013 public:
00014 Loop( const LoopCo& d, const string& LoopDev, const string& LoopFile,
00015 bool dmcrypt, const string& dm_dev,
00016 ProcPart& ppart, SystemCmd& losetup );
00017 Loop( const LoopCo& d, const string& file, bool reuseExisting,
00018 unsigned long long sizeK, bool dmcr );
00019 Loop( const LoopCo& d, const Loop& rhs );
00020 virtual ~Loop();
00021 const string& loopFile() const { return lfile; }
00022 void setLoopFile( const string& file );
00023 bool getReuse() { return( reuseFile ); }
00024 void setReuse( bool reuseExisting );
00025 void setDelFile( bool val=true ) { delFile=val; }
00026 bool removeFile();
00027 bool createFile();
00028 string lfileRealPath() const;
00029 void setDmcryptDev( const string& dm_dev, bool active=true );
00030 friend std::ostream& operator<< (std::ostream& s, const Loop& l );
00031
00032 virtual void print( std::ostream& s ) const { s << *this; }
00033 virtual int setEncryption( bool val, storage::EncryptType typ=storage::ENC_LUKS );
00034
00035 string removeText( bool doing ) const;
00036 string createText( bool doing ) const;
00037 string formatText( bool doing ) const;
00038
00039 void getInfo( storage::LoopInfo& info ) const;
00040 bool equalContent( const Loop& rhs ) const;
00041 void logDifference( const Loop& d ) const;
00042 static unsigned major();
00043 static string loopDeviceName( unsigned num );
00044
00045 static bool notDeleted( const Loop& l ) { return( !l.deleted() ); }
00046
00047 protected:
00048 void init();
00049 void checkReuse();
00050 static void getLoopMajor();
00051 Loop& operator=( const Loop& );
00052
00053 string lfile;
00054 bool reuseFile;
00055 bool delFile;
00056
00057 static unsigned loop_major;
00058 mutable storage::LoopInfo info;
00059 };
00060
00061 }
00062
00063 #endif