2012-01-28 07:25:31 -07:00
|
|
|
/* Copyright (C) 2012 Mike Fleetwood
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2014-01-23 03:59:48 -07:00
|
|
|
* GNU General Public License for more details.
|
2012-01-28 07:25:31 -07:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 03:59:48 -07:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2012-01-28 07:25:31 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* LVM2_PV_Info
|
|
|
|
*
|
|
|
|
* A persistent cache of information about LVM2 PVs that helps to
|
|
|
|
* minimize the number of executions of lvm commands used to query
|
|
|
|
* their attributes.
|
|
|
|
*/
|
|
|
|
|
2013-05-27 05:20:16 -06:00
|
|
|
#ifndef GPARTED_LVM2_PV_INFO_H
|
|
|
|
#define GPARTED_LVM2_PV_INFO_H
|
2012-01-28 07:25:31 -07:00
|
|
|
|
|
|
|
#include "../include/Utils.h"
|
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
2015-06-07 03:15:16 -06:00
|
|
|
struct LVM2_PV
|
|
|
|
{
|
|
|
|
Glib::ustring pv_name;
|
|
|
|
Byte_Value pv_size;
|
|
|
|
Byte_Value pv_free;
|
|
|
|
Glib::ustring vg_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LVM2_VG
|
|
|
|
{
|
|
|
|
Glib::ustring vg_name;
|
|
|
|
Glib::ustring vg_attr;
|
|
|
|
Glib::ustring lv_name;
|
|
|
|
Glib::ustring lv_attr;
|
|
|
|
};
|
|
|
|
|
2012-01-28 07:25:31 -07:00
|
|
|
class LVM2_PV_Info
|
|
|
|
{
|
|
|
|
public:
|
2015-06-05 13:54:37 -06:00
|
|
|
static bool is_lvm2_pv_supported();
|
2015-06-07 14:42:08 -06:00
|
|
|
static void clear_cache();
|
2015-06-05 13:54:37 -06:00
|
|
|
static Glib::ustring get_vg_name( const Glib::ustring & path );
|
|
|
|
static Byte_Value get_size_bytes( const Glib::ustring & path );
|
|
|
|
static Byte_Value get_free_bytes( const Glib::ustring & path );
|
|
|
|
static bool has_active_lvs( const Glib::ustring & path );
|
|
|
|
static bool is_vg_exported( const Glib::ustring & vgname );
|
|
|
|
static std::vector<Glib::ustring> get_vg_members( const Glib::ustring & vgname );
|
|
|
|
static std::vector<Glib::ustring> get_error_messages( const Glib::ustring & path );
|
2012-01-28 07:25:31 -07:00
|
|
|
private:
|
2015-06-05 13:54:37 -06:00
|
|
|
static void initialize_if_required();
|
2015-06-05 12:44:07 -06:00
|
|
|
static void set_command_found();
|
|
|
|
static void load_lvm2_pv_info_cache();
|
2015-06-07 03:15:16 -06:00
|
|
|
static const LVM2_PV & get_pv_cache_entry_by_name( const Glib::ustring & pvname );
|
|
|
|
static const LVM2_VG & get_vg_cache_entry_by_name( const Glib::ustring & vgname );
|
|
|
|
static Byte_Value lvm2_pv_size_to_num( const Glib::ustring str ) ;
|
2012-07-09 07:19:14 -06:00
|
|
|
static bool bit_set( const Glib::ustring & attr, unsigned int bit ) ;
|
2012-01-28 07:25:31 -07:00
|
|
|
static bool lvm2_pv_info_cache_initialized ;
|
|
|
|
static bool lvm_found ;
|
2015-06-07 03:15:16 -06:00
|
|
|
static std::vector<LVM2_PV> lvm2_pv_cache;
|
|
|
|
static std::vector<LVM2_VG> lvm2_vg_cache;
|
2012-02-09 13:58:55 -07:00
|
|
|
static std::vector<Glib::ustring> error_messages ;
|
2012-01-28 07:25:31 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}//GParted
|
|
|
|
|
2013-05-27 05:20:16 -06:00
|
|
|
#endif /* GPARTED_LVM2_PV_INFO_H */
|