yast2-storage

Md.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 MD_H
00024 #define MD_H
00025 
00026 #include "storage/StorageInterface.h"
00027 #include "storage/Volume.h"
00028 
00029 namespace storage
00030 {
00031     class MdCo;
00032     class EtcMdadm;
00033 
00034 
00035 class Md : public Volume
00036     {
00037         friend class MdPartCo;
00038 
00039     public:
00040         Md(const MdCo& c, const string& name, const string& device, MdType Type,
00041            const list<string>& devs, const list<string>& spares);
00042         Md(const MdCo& c, const string& name, const string& device, SystemInfo& systeminfo);
00043         Md(const MdCo& c, const Md& v);
00044         virtual ~Md();
00045 
00046         storage::MdType personality() const { return md_type; }
00047         void setPersonality( storage::MdType val ); 
00048         storage::MdParity parity() const { return md_parity; }
00049         int setParity( storage::MdParity val ); 
00050         unsigned long chunkSizeK() const { return chunk_k; }
00051         void setChunkSizeK(unsigned long val) { chunk_k = val; }
00052         void setMdUuid( const string&val ) { md_uuid=val; }
00053         bool destroySb() const { return( destrSb ); }
00054         void setDestroySb( bool val=true ) { destrSb=val; }
00055         const string& getMdUuid() const { return(md_uuid); }
00056         list<string> getDevs(bool all = true, bool spare = false) const;
00057         int checkDevices();
00058         int addDevice( const string& dev, bool spare=false );
00059         int removeDevice( const string& dev );
00060         string createCmd() const;
00061         static bool matchRegex( const string& dev );
00062         static unsigned mdMajor();
00063 
00064         void updateData(SystemInfo& systeminfo);
00065         void setUdevData(SystemInfo& systeminfo);
00066 
00067         virtual list<string> udevId() const { return udev_id; }
00068 
00069         virtual string procName() const { return nm; }
00070         virtual string sysfsPath() const;
00071 
00072         static bool mdStringNum( const string& name, unsigned& num ); 
00073         static string mdDevice( unsigned num );
00074 
00075         friend std::ostream& operator<< (std::ostream& s, const Md& m );
00076         virtual void print( std::ostream& s ) const { s << *this; }
00077         Text removeText( bool doing ) const;
00078         Text createText( bool doing ) const;
00079         Text formatText( bool doing ) const;
00080         static bool notDeleted( const Md& l ) { return( !l.deleted() ); }
00081         void changeDeviceName( const string& old, const string& nw );
00082 
00083         void getInfo( storage::MdInfo& info ) const;
00084         bool equalContent( const Md& rhs ) const;
00085 
00086         void logDifference(std::ostream& log, const Md& rhs) const;
00087 
00088         int getState(MdStateInfo& info) const;
00089 
00090         bool updateEntry(EtcMdadm* mdadm) const;
00091 
00092         virtual list<string> getUsing() const;
00093 
00094     protected:
00095 
00096         void computeSize();
00097 
00098         MdType md_type;
00099         MdParity md_parity;
00100         unsigned long chunk_k;
00101         string md_uuid;
00102         string md_name;         // line in /dev/md/*
00103         string sb_ver;
00104         bool destrSb;
00105         list<string> devs;
00106         list<string> spare;
00107 
00108         list<string> udev_id;
00109 
00110         // In case of IMSM and DDF raids there is 'container'.
00111         bool has_container;
00112         bool inactive;
00113         string parent_container;
00114         string parent_uuid;
00115         string parent_md_name;
00116         string parent_metadata;
00117         string parent_member;
00118 
00119         static unsigned md_major;
00120 
00121         mutable storage::MdInfo info; // workaround for broken ycp bindings
00122 
00123     private:
00124 
00125         Md(const Md&);                // disallow
00126         Md& operator=(const Md&);     // disallow
00127 
00128     };
00129 
00130 }
00131 
00132 #endif