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
This commit is contained in:
Mike Fleetwood 2021-03-29 20:31:48 +01:00 committed by Curtis Gedak
parent 5cacb02015
commit 1e813d83a5
3 changed files with 12 additions and 2 deletions

View File

@ -38,6 +38,7 @@ struct FS_Entry
class FS_Info class FS_Info
{ {
public: public:
static void clear_cache();
static void load_cache_for_paths(const std::vector<Glib::ustring>& paths); 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_fs_type( const Glib::ustring & path );
static Glib::ustring get_label( const Glib::ustring & path, bool & found ); static Glib::ustring get_label( const Glib::ustring & path, bool & found );

View File

@ -51,15 +51,23 @@ bool FS_Info::need_blkid_vfat_cache_update_workaround = true;
std::vector<FS_Entry> FS_Info::fs_info_cache; std::vector<FS_Entry> FS_Info::fs_info_cache;
void FS_Info::load_cache_for_paths(const std::vector<Glib::ustring>& paths) void FS_Info::clear_cache()
{ {
set_commands_found(); set_commands_found();
fs_info_cache.clear(); fs_info_cache.clear();
run_blkid_load_cache(paths);
fs_info_cache_initialized = true; fs_info_cache_initialized = true;
} }
void FS_Info::load_cache_for_paths(const std::vector<Glib::ustring>& paths)
{
if (not_initialised_then_error())
return;
run_blkid_load_cache(paths);
}
// Retrieve the file system type for the path // Retrieve the file system type for the path
Glib::ustring FS_Info::get_fs_type( const Glib::ustring & path ) Glib::ustring FS_Info::get_fs_type( const Glib::ustring & path )
{ {

View File

@ -248,6 +248,7 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
} }
// Initialise and load caches needed for content discovery. // Initialise and load caches needed for content discovery.
FS_Info::clear_cache();
const std::vector<Glib::ustring>& device_and_partition_paths = const std::vector<Glib::ustring>& device_and_partition_paths =
Proc_Partitions_Info::get_device_and_partition_paths_for(device_paths); Proc_Partitions_Info::get_device_and_partition_paths_for(device_paths);
FS_Info::load_cache_for_paths(device_and_partition_paths); FS_Info::load_cache_for_paths(device_and_partition_paths);