Source: LvmAccess.h


Annotated List
Files
Globals
Hierarchy
Index
// Maintainer: fehr@suse.de

#ifndef _LvmAccess_h
#define _LvmAccess_h

#include 
#include 

using std::list;

#include "PartInfo.defs.h"
#include "SystemCmd.h"

struct PvInfo
    {
    string Name_C;
    string VgName_C;
    bool Allocatable_b;
    bool Active_b;
    bool Created_b;
    bool Multipath_b;
    int PartitionId_i;
    unsigned long Blocks_l;
    unsigned long Free_l;
    list RealDevList_C;
    };

struct LvInfo
    {
    string Name_C;
    string VgName_C;
    bool Writable_b;
    bool Active_b;
    bool AllocCont_b;
    unsigned long Stripe_l;
    unsigned long Blocks_l;
    };

struct VgInfo
    {
    string Name_C;
    unsigned long Blocks_l;
    unsigned long Free_l;
    unsigned long PeSize_l;
    bool Active_b;
    bool Lvm2_b;
    list Pv_C;
    list Lv_C;
    };

class LvmAccess
    {
    public:
	LvmAccess( bool Expensive_bv=true );
	virtual ~LvmAccess();
	unsigned VgCnt();
	unsigned PvCnt();
	unsigned LvCnt();
	int GetVgIdx( const string& VgName_Cv );
	int GetPvIdx( const string& PvName_Cv );
	VgInfo GetVg( int Idx_ii );
	LvInfo GetLv( int Idx_ii );
	PvInfo GetPv( int Idx_ii );
	void ChangeId( int Idx_ii, int Id_iv );
	void ChangePvVgName( const string& Device_Cv, const string& Name_Cv );
	void DoExpensive();
	bool CreatePv( const string& PvName_Cv, bool NewMeta_bv );
	string GetErrorText();
	string GetCmdLine();
	int  LvmVersion() { return LvmVersion_i; };
	bool Lvm2() { return LvmVersion_i==2; };
	bool ChangeActive( const string& Name_Cv, bool Active_bv );
	bool DeleteVg( const string& VgName_Cv );
	bool ExtendVg( const string& VgName_Cv, const string& PvName_Cv );
	bool ShrinkVg( const string& VgName_Cv, const string& PvName_Cv );
	bool CreateVg( const string& VgName_Cv, unsigned long PeSize_lv,
	               bool NewMeta_bv, list& Devices_Cv );
	bool CreateLv( const string& LvName_Cv, const string& VgName_Cv,
	               unsigned long Size_lv, unsigned long Stripe_lv,
	               unsigned long StripeSize_lv );
	bool ChangeLvSize( const string& LvName_Cv, unsigned long Size_lv );
	bool DeleteLv( const string& LvName_Cv );
	void UpdateDisk( list& Part_Cv, const string& Disk_Cv );
	void ActivateLvm();
	bool ActivateVGs( bool Activate_bv=true );
	list PhysicalDeviceList();
	static unsigned long long UnitToValue( const string& Unit_Cv );

    protected:
	struct VgIntern
	    {
	    string Name_C;
	    unsigned long Blocks_l;
	    unsigned long Free_l;
	    unsigned long PeSize_l;
	    bool Active_b;
	    bool Lvm2_b;
	    list Pv_C;
	    list Lv_C;
	    operator VgInfo();
	    };

	void ProcessMd();
	void ScanForDisks();
	void ScanForInactiveVg();
	void ScanLvmStatus();
	void ScanProcLvm();
	void ScanVgdisplayOutput();
	void PrepareLvmCmd();
	list::iterator SortIntoPvList( const PvInfo& PvElem_rv );
	bool ExecuteLvmCmd( const string& Cmd_Cv );
	bool MountRamdisk( const string& Path_Cv, unsigned SizeMb_iv );
	string GetPvDevicename( const string& VgName_Cv, const string& FDev_Cv,
	                        const string& Dev_Cv, int Num_iv, int Mp_iv );
	void LvIntoList( VgIntern& VgElem_rr, list& LvList_Cr,
			 const LvInfo& LvElem_rv );
	void PvIntoList( VgIntern& VgElem_rr, list& PvList_Cr,
			 const PvInfo& PvElem_rv );


	list::iterator FindVg( const string& Name_Cv );
	list::iterator FindPv( const string& Device_Cv );
	list::iterator FindLv( const string& Name_Cv );
	list VgList_C;
	list PvList_C;
	list LvList_C;
	bool Expensive_b;
	bool DidVgchangeA_b;
	SystemCmd LvmCmd_C;
	string LvmOutput_C;
	string CmdLine_C;
	int LvmRet_i;
	int LvmVersion_i;
    };

#endif

Generated by: root on D60 on Mon Oct 20 16:15:28 2003, using kdoc 2.0a54.