File: SWRaid_Info.h

package info (click to toggle)
gparted 1.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,752 kB
  • sloc: cpp: 34,868; sh: 5,073; makefile: 462; sed: 16; ansic: 9
file content (81 lines) | stat: -rw-r--r-- 2,446 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Copyright (C) 2015 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
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
 */


/* SWRaid_Info
 *
 * Cache of information about RAID array members recognised by mdadm so
 * the command only needs to be executed once per refresh.  This will
 * include Linux Software RAID arrays and also IMSM and DDF type
 * Firmware / BIOS / ATARAID arrays whether or not the distribution uses
 * dmraid or mdadm to manage them.
 *
 * Note that ATARAID array members will only report as active in this
 * module if they were started using mdadm and appear in /proc/mdstat.
 */

#ifndef GPARTED_SWRAID_INFO_H
#define GPARTED_SWRAID_INFO_H


#include "BlockSpecial.h"
#include "Utils.h"

#include <glibmm/ustring.h>
#include <vector>


namespace GParted
{


struct SWRaid_Member
{
	BlockSpecial  member;
	FSType        fstype;
	Glib::ustring array;
	Glib::ustring uuid;
	Glib::ustring label;
	bool          active;
};

class SWRaid_Info
{
public:
	static void load_cache();
	static bool is_member( const Glib::ustring & member_path );
	static bool is_member_active( const Glib::ustring & member_path );
	static FSType get_fstype(const Glib::ustring& member_path);
	static const Glib::ustring& get_array(const Glib::ustring& member_path);
	static const Glib::ustring& get_uuid(const Glib::ustring& member_path);
	static const Glib::ustring& get_label(const Glib::ustring& member_path);

private:
	static void initialise_if_required();
	static void set_command_found();
	static void load_swraid_info_cache();
	static SWRaid_Member & get_cache_entry_by_member( const Glib::ustring & member_path );
	static Glib::ustring mdadm_to_canonical_uuid( const Glib::ustring & mdadm_uuid );

	static bool cache_initialised;
	static bool mdadm_found;
	static std::vector<SWRaid_Member> swraid_info_cache;
};


}//GParted

#endif /* GPARTED_SWRAID_INFO_H */