1
0
mirror of https://gitlab.gnome.org/GNOME/gparted synced 2024-07-07 19:39:25 +00:00
gparted/include/FS_Info.h
Mike Fleetwood 1e813d83a5 Make FS_Info (blkid) cache incrementally loadable (#148)
Since changes for issue #131 "GParted hangs when non-named device is
hung" FS_Info cache is initialised, cleared and loaded via one call to
load_cache_for_paths().  It runs blkid for named or found disk devices
and associated found partitions from /proc/partitions, rather than
running blkid and letting it report for all block devices.

To avoid the possibility of using blkid on an encryption mapping on a
non-specified and possibly hung block device GParted can't just specify
all encryption mappings.  Instead only encryption mappings which belong
to the above identified block devices should be probed.  That requires
identifying LUKS encryption data in the block devices first so will
require subsequently loading additional data into the FS_Info cache and
running blkid again.

To accommodate this make the FS_Info cache incrementally loadable,
rather than doing everything in a single call to load_cache_for_paths().
Have a separate clear_cache() call which initialises and clears the
cache and make load_cache_for_paths() just run blkid and insert data for
the named paths.

Closes 148 - Encrypted file systems are no longer recognised
2021-04-03 17:02:04 +00:00

66 lines
2.0 KiB
C++

/* Copyright (C) 2008, 2009, 2010 Curtis Gedak
*
* 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/>.
*/
#ifndef GPARTED_FS_INFO_H
#define GPARTED_FS_INFO_H
#include "BlockSpecial.h"
#include <glibmm/ustring.h>
#include <vector>
namespace GParted
{
struct FS_Entry
{
BlockSpecial path;
Glib::ustring type;
Glib::ustring sec_type;
Glib::ustring uuid;
bool have_label;
Glib::ustring label;
};
class FS_Info
{
public:
static void clear_cache();
static void load_cache_for_paths(const std::vector<Glib::ustring>& paths);
static Glib::ustring get_fs_type( const Glib::ustring & path );
static Glib::ustring get_label( const Glib::ustring & path, bool & found );
static Glib::ustring get_uuid( const Glib::ustring & path );
static Glib::ustring get_path_by_uuid( const Glib::ustring & uuid );
static Glib::ustring get_path_by_label( const Glib::ustring & label );
private:
static bool not_initialised_then_error();
static void set_commands_found();
static const FS_Entry & get_cache_entry_by_path( const Glib::ustring & path );
static void run_blkid_load_cache(const std::vector<Glib::ustring>& paths);
static void update_fs_info_cache_all_labels();
static bool run_blkid_update_cache_one_label( FS_Entry & fs_entry );
static bool fs_info_cache_initialized ;
static bool blkid_found ;
static bool need_blkid_vfat_cache_update_workaround;
static std::vector<FS_Entry> fs_info_cache;
};
}//GParted
#endif /* GPARTED_FS_INFO_H */