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 "y2storage/Volume.h"
00027
00028 namespace storage
00029 {
00030 class LoopCo;
00031 class ProcPart;
00032
00033 class Loop : public Volume
00034 {
00035 public:
00036 Loop( const LoopCo& d, const string& LoopDev, const string& LoopFile,
00037 bool dmcrypt, const string& dm_dev,
00038 ProcPart& ppart, SystemCmd& losetup );
00039 Loop( const LoopCo& d, const string& file, bool reuseExisting,
00040 unsigned long long sizeK, bool dmcr );
00041 Loop( const LoopCo& d, const Loop& rhs );
00042 virtual ~Loop();
00043 const string& loopFile() const { return lfile; }
00044 void setLoopFile( const string& file );
00045 bool getReuse() { return( reuseFile ); }
00046 void setReuse( bool reuseExisting );
00047 void setDelFile( bool val=true ) { delFile=val; }
00048 bool removeFile();
00049 bool createFile();
00050 string lfileRealPath() const;
00051 void setDmcryptDev( const string& dm_dev, bool active=true );
00052 friend std::ostream& operator<< (std::ostream& s, const Loop& l );
00053
00054 virtual void print( std::ostream& s ) const { s << *this; }
00055 virtual int setEncryption( bool val, storage::EncryptType typ=storage::ENC_LUKS );
00056
00057 string removeText( bool doing ) const;
00058 string createText( bool doing ) const;
00059 string formatText( bool doing ) const;
00060
00061 void getInfo( storage::LoopInfo& info ) const;
00062 bool equalContent( const Loop& rhs ) const;
00063 void logDifference( const Loop& d ) const;
00064 static unsigned major();
00065 static string loopDeviceName( unsigned num );
00066
00067 static bool notDeleted( const Loop& l ) { return( !l.deleted() ); }
00068
00069 protected:
00070 void init();
00071 void checkReuse();
00072 static void getLoopMajor();
00073 Loop& operator=( const Loop& );
00074
00075 string lfile;
00076 bool reuseFile;
00077 bool delFile;
00078
00079 static unsigned loop_major;
00080 mutable storage::LoopInfo info;
00081 };
00082
00083 }
00084
00085 #endif