00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LOOP_H
00024 #define LOOP_H
00025
00026 #include "storage/Volume.h"
00027
00028 namespace storage
00029 {
00030 class LoopCo;
00031 class SystemInfo;
00032
00033
00034 class Loop : public Volume
00035 {
00036 public:
00037
00038 Loop( const LoopCo& d, const string& LoopDev, const string& LoopFile,
00039 bool dmcrypt, const string& dm_dev,
00040 SystemInfo& systeminfo, SystemCmd& losetup);
00041 Loop( const LoopCo& d, const string& file, bool reuseExisting,
00042 unsigned long long sizeK, bool dmcr );
00043 Loop(const LoopCo& c, const Loop& v);
00044 virtual ~Loop();
00045
00046 const string& loopFile() const { return lfile; }
00047 void setLoopFile( const string& file );
00048 bool getReuse() const { return reuseFile; }
00049 void setReuse( bool reuseExisting );
00050 void setDelFile( bool val=true ) { delFile=val; }
00051 bool removeFile();
00052 bool createFile();
00053 string lfileRealPath() const;
00054 void setDmcryptDev( const string& dm_dev, bool active=true );
00055 friend std::ostream& operator<< (std::ostream& s, const Loop& l );
00056
00057 virtual void print( std::ostream& s ) const { s << *this; }
00058 virtual int setEncryption( bool val, storage::EncryptType typ=storage::ENC_LUKS );
00059
00060 Text removeText( bool doing ) const;
00061 Text createText( bool doing ) const;
00062 Text formatText( bool doing ) const;
00063
00064 void getInfo( storage::LoopInfo& info ) const;
00065 bool equalContent( const Loop& rhs ) const;
00066
00067 void logDifference(std::ostream& log, const Loop& rhs) const;
00068
00069 static unsigned loopMajor();
00070 static string loopDeviceName( unsigned num );
00071
00072 static bool notDeleted( const Loop& l ) { return( !l.deleted() ); }
00073
00074 protected:
00075
00076 void checkReuse();
00077
00078 string lfile;
00079 bool reuseFile;
00080 bool delFile;
00081
00082 static unsigned loop_major;
00083
00084 mutable storage::LoopInfo info;
00085
00086 private:
00087
00088 Loop(const Loop&);
00089 Loop& operator=(const Loop&);
00090
00091 };
00092
00093 }
00094
00095 #endif