|
yast2-storage
|
00001 /* 00002 * Copyright (c) [2004-2009] Novell, Inc. 00003 * 00004 * All Rights Reserved. 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of version 2 of the GNU General Public License as published 00008 * by the Free Software Foundation. 00009 * 00010 * This program is distributed in the hope that it will be useful, but WITHOUT 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00013 * more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, contact Novell, Inc. 00017 * 00018 * To contact Novell about this file by physical or electronic mail, you may 00019 * find current contact information at www.novell.com. 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; // workaround for broken ycp bindings 00085 00086 private: 00087 00088 Loop(const Loop&); // disallow 00089 Loop& operator=(const Loop&); // disallow 00090 00091 }; 00092 00093 } 00094 00095 #endif
1.7.3