00001 /* 00002 * Copyright (c) [2004-2010] 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 ETC_MDADM_H 00024 #define ETC_MDADM_H 00025 00026 #include <string> 00027 #include <map> 00028 00029 #include "storage/AsciiFile.h" 00030 #include "storage/Storage.h" 00031 00032 00033 namespace storage 00034 { 00035 00036 class EtcMdadm 00037 { 00038 00039 public: 00040 00041 EtcMdadm(const Storage* sto, const string& prefix = ""); 00042 00043 // From this structure line 'ARRAY' will be build in config file. 00044 // Not all fields are mandatory 00045 // If container is present then container line will be build 00046 // before volume line. 00047 struct mdconf_info 00048 { 00049 mdconf_info() : container_present(false) {} 00050 00051 string device; 00052 string uuid; 00053 00054 bool container_present; 00055 00056 /* following members only valid if container_present is true */ 00057 string container_member; 00058 string container_metadata; 00059 string container_uuid; 00060 00061 friend std::ostream& operator<<(std::ostream& s, const mdconf_info& info); 00062 }; 00063 00064 bool updateEntry(const mdconf_info& info); 00065 00066 bool removeEntry(const string& uuid); 00067 00068 protected: 00069 00070 void setDeviceLine(const string& line); 00071 void setAutoLine(const string& line); 00072 void setArrayLine(const string& line, const string& uuid); 00073 00074 string ContLine(const mdconf_info& info) const; 00075 string ArrayLine(const mdconf_info& info) const; 00076 00077 vector<string>::iterator findArray(const string& uuid); 00078 00079 string getUuid(const string& line) const; 00080 00081 const Storage* sto; 00082 00083 AsciiFile mdadm; 00084 00085 }; 00086 00087 } 00088 00089 00090 #endif
1.5.6