Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

LvmAccess.h

Go to the documentation of this file.
00001 // Maintainer: fehr@suse.de
00002 
00003 #ifndef _LvmAccess_h
00004 #define _LvmAccess_h
00005 
00006 #include <string>
00007 #include <list>
00008 
00009 using std::list;
00010 
00011 #include "PartInfo.defs.h"
00012 #include "SystemCmd.h"
00013 
00014 struct PvInfo
00015     {
00016     string Name_C;
00017     string VgName_C;
00018     bool Allocatable_b;
00019     bool Active_b;
00020     bool Created_b;
00021     bool Multipath_b;
00022     int PartitionId_i;
00023     unsigned long Blocks_l;
00024     unsigned long Free_l;
00025     list<string> RealDevList_C;
00026     };
00027 
00028 struct LvInfo
00029     {
00030     string Name_C;
00031     string VgName_C;
00032     bool Writable_b;
00033     bool Active_b;
00034     bool AllocCont_b;
00035     unsigned long Stripe_l;
00036     unsigned long Blocks_l;
00037     };
00038 
00039 struct VgInfo
00040     {
00041     string Name_C;
00042     unsigned long Blocks_l;
00043     unsigned long Free_l;
00044     unsigned long PeSize_l;
00045     bool Active_b;
00046     bool Lvm2_b;
00047     list<PvInfo> Pv_C;
00048     list<LvInfo> Lv_C;
00049     };
00050 
00051 class LvmAccess
00052     {
00053     public:
00054         LvmAccess( bool Expensive_bv=true );
00055         virtual ~LvmAccess();
00056         unsigned VgCnt();
00057         unsigned PvCnt();
00058         unsigned LvCnt();
00059         int GetVgIdx( const string& VgName_Cv );
00060         int GetPvIdx( const string& PvName_Cv );
00061         VgInfo GetVg( int Idx_ii );
00062         LvInfo GetLv( int Idx_ii );
00063         PvInfo GetPv( int Idx_ii );
00064         void ChangeId( int Idx_ii, int Id_iv );
00065         void ChangePvVgName( const string& Device_Cv, const string& Name_Cv );
00066         void DoExpensive();
00067         bool CreatePv( const string& PvName_Cv, bool NewMeta_bv );
00068         string GetErrorText();
00069         string GetCmdLine();
00070         int  LvmVersion() { return LvmVersion_i; };
00071         bool Lvm2() { return LvmVersion_i==2; };
00072         bool ChangeActive( const string& Name_Cv, bool Active_bv );
00073         bool DeleteVg( const string& VgName_Cv );
00074         bool ExtendVg( const string& VgName_Cv, const string& PvName_Cv );
00075         bool ShrinkVg( const string& VgName_Cv, const string& PvName_Cv );
00076         bool CreateVg( const string& VgName_Cv, unsigned long PeSize_lv,
00077                        bool NewMeta_bv, list<string>& Devices_Cv );
00078         bool CreateLv( const string& LvName_Cv, const string& VgName_Cv,
00079                        unsigned long Size_lv, unsigned long Stripe_lv,
00080                        unsigned long StripeSize_lv );
00081         bool ChangeLvSize( const string& LvName_Cv, unsigned long Size_lv );
00082         bool DeleteLv( const string& LvName_Cv );
00083         void UpdateDisk( list<PartInfo>& Part_Cv, const string& Disk_Cv );
00084         void ActivateLvm();
00085         bool ActivateVGs( bool Activate_bv=true );
00086         list<string> PhysicalDeviceList();
00087         static unsigned long long UnitToValue( const string& Unit_Cv );
00088 
00089     protected:
00090         struct VgIntern
00091             {
00092             string Name_C;
00093             unsigned long Blocks_l;
00094             unsigned long Free_l;
00095             unsigned long PeSize_l;
00096             bool Active_b;
00097             bool Lvm2_b;
00098             list<PvInfo*> Pv_C;
00099             list<LvInfo*> Lv_C;
00100             operator VgInfo();
00101             };
00102 
00103         void ProcessMd();
00104         void ScanForDisks();
00105         void ScanForInactiveVg();
00106         void ScanLvmStatus();
00107         void ScanProcLvm();
00108         void ScanVgdisplayOutput();
00109         void PrepareLvmCmd();
00110         list<PvInfo>::iterator SortIntoPvList( const PvInfo& PvElem_rv );
00111         bool ExecuteLvmCmd( const string& Cmd_Cv );
00112         bool MountRamdisk( const string& Path_Cv, unsigned SizeMb_iv );
00113         string GetPvDevicename( const string& VgName_Cv, const string& FDev_Cv,
00114                                 const string& Dev_Cv, int Num_iv, int Mp_iv );
00115         void LvIntoList( VgIntern& VgElem_rr, list<LvInfo>& LvList_Cr,
00116                          const LvInfo& LvElem_rv );
00117         void PvIntoList( VgIntern& VgElem_rr, list<PvInfo>& PvList_Cr,
00118                          const PvInfo& PvElem_rv );
00119 
00120 
00121         list<VgIntern>::iterator FindVg( const string& Name_Cv );
00122         list<PvInfo>::iterator FindPv( const string& Device_Cv );
00123         list<LvInfo>::iterator FindLv( const string& Name_Cv );
00124         list<VgIntern> VgList_C;
00125         list<PvInfo> PvList_C;
00126         list<LvInfo> LvList_C;
00127         bool Expensive_b;
00128         bool DidVgchangeA_b;
00129         SystemCmd LvmCmd_C;
00130         string LvmOutput_C;
00131         string CmdLine_C;
00132         int LvmRet_i;
00133         int LvmVersion_i;
00134     };
00135 
00136 #endif

Generated on Wed Nov 12 06:35:35 2008 for yast2-storage by  doxygen 1.3.9.1