00001 #ifndef ETC_RAIDTAB_H 00002 #define ETC_RAIDTAB_H 00003 00004 #include <string> 00005 #include <map> 00006 00007 class AsciiFile; 00008 00009 class EtcRaidtab 00010 { 00011 public: 00012 EtcRaidtab( const string& prefix="" ); 00013 ~EtcRaidtab(); 00014 void updateEntry( unsigned num, const std::list<string>& entries, 00015 const string&, const std::list<string>& devs ); 00016 void removeEntry( unsigned num ); 00017 protected: 00018 struct entry 00019 { 00020 entry() { first=last=0; } 00021 entry( unsigned f, unsigned l ) { first=f; last=l; } 00022 unsigned first; 00023 unsigned last; 00024 friend std::ostream& operator<< (std::ostream& s, const entry &v ); 00025 }; 00026 friend std::ostream& operator<< (std::ostream& s, const entry &v ); 00027 00028 void updateMdadmFile(); 00029 void updateRaidtabFile(); 00030 void buildRaidtabMap(); 00031 void buildMdadmMap(); 00032 00033 Regex *whitespace; 00034 Regex *comment; 00035 string rtabname; 00036 string mdadmname; 00037 int mdadm_dev_line; 00038 std::map<unsigned,entry> mtab; 00039 std::map<unsigned,entry> rtab; 00040 AsciiFile* raidtab; 00041 AsciiFile* mdadm; 00042 }; 00044 00045 inline std::ostream& operator<< (std::ostream& s, const EtcRaidtab::entry& v ) 00046 { 00047 s << "first=" << v.first << " last=" << v.last; 00048 return( s ); 00049 } 00050 00051 #endif
1.4.4