yast2-storage

ProcMdstat.h

Go to the documentation of this file.
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 PROC_MDSTAT_H
00024 #define PROC_MDSTAT_H
00025 
00026 
00027 namespace storage
00028 {
00029 
00030     class ProcMdstat
00031     {
00032     public:
00033 
00034         ProcMdstat();
00035 
00036         struct Entry
00037         {
00038             Entry() : md_type(RAID_UNK), md_parity(PAR_DEFAULT), size_k(0), chunk_k(0),
00039                       readonly(false), inactive(false), is_container(false), has_container(false) {}
00040 
00041             MdType md_type;
00042             MdParity md_parity;
00043 
00044             string super;
00045 
00046             unsigned long long size_k;
00047             unsigned long chunk_k;
00048 
00049             bool readonly;
00050             bool inactive;
00051 
00052             list<string> devices;
00053             list<string> spares;
00054 
00055             bool is_container;
00056 
00057             bool has_container;
00058             string container_name;
00059             string container_member;
00060         };
00061 
00062         friend std::ostream& operator<<(std::ostream& s, const Entry& entry);
00063 
00064         list<string> getEntries() const;
00065 
00066         bool getEntry(const string& name, Entry& entry) const;
00067 
00068         typedef map<string, Entry>::const_iterator const_iterator;
00069 
00070         const_iterator begin() const { return data.begin(); }
00071         const_iterator end() const { return data.end(); }
00072 
00073     private:
00074 
00075         Entry parse(const string& line1, const string& line2);
00076 
00077         map<string, Entry> data;
00078 
00079     };
00080 
00081 
00082     struct MdadmDetails
00083     {
00084         string uuid;
00085         string devname;
00086         string metadata;
00087     };
00088 
00089     bool getMdadmDetails(const string& dev, MdadmDetails& details);
00090 
00091 
00092     bool isImsmPlatform();
00093 
00094 }
00095 
00096 
00097 #endif