Extract common code into Mount_Info::lookup_uuid_or_label() (#162)
Closes #162 - It is no longer possible to mount a LUKS encrypted file system
This commit is contained in:
parent
49747f656d
commit
f5e6239452
|
@ -67,6 +67,7 @@ private:
|
|||
static bool have_rootfs_dev( MountMapping & map );
|
||||
static void read_mountpoints_from_mount_command( MountMapping & map );
|
||||
static const MountEntry& find(MountMapping& map, const Glib::ustring& path);
|
||||
static Glib::ustring lookup_uuid_or_label(const Glib::ustring& ref);
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -142,25 +142,12 @@ void Mount_Info::read_mountpoints_from_file( const Glib::ustring & filename, Mou
|
|||
struct mntent* p = NULL;
|
||||
while ( ( p = getmntent( fp ) ) != NULL )
|
||||
{
|
||||
Glib::ustring node = p->mnt_fsname;
|
||||
Glib::ustring node = lookup_uuid_or_label(p->mnt_fsname);
|
||||
if (node.empty())
|
||||
node = p->mnt_fsname;
|
||||
|
||||
Glib::ustring mountpoint = p->mnt_dir;
|
||||
|
||||
Glib::ustring uuid = Utils::regexp_label( node, "^UUID=(.*)" );
|
||||
if ( ! uuid.empty() )
|
||||
{
|
||||
Glib::ustring temp = FS_Info::get_path_by_uuid(uuid);
|
||||
if (! temp.empty())
|
||||
node = temp;
|
||||
}
|
||||
|
||||
Glib::ustring label = Utils::regexp_label( node, "^LABEL=(.*)" );
|
||||
if ( ! label.empty() )
|
||||
{
|
||||
Glib::ustring temp = FS_Info::get_path_by_label(label);
|
||||
if (! temp.empty())
|
||||
node = temp;
|
||||
}
|
||||
|
||||
add_mountpoint_entry(map, node, mountpoint, parse_readonly_flag(p->mnt_opts));
|
||||
}
|
||||
|
||||
|
@ -281,23 +268,7 @@ const MountEntry& Mount_Info::find(MountMapping& map, const Glib::ustring& path)
|
|||
}
|
||||
for (unsigned i = 0; i < ref_nodes.size(); i++)
|
||||
{
|
||||
Glib::ustring node;
|
||||
Glib::ustring uuid = Utils::regexp_label(ref_nodes[i].m_name, "^UUID=(.*)");
|
||||
if (! uuid.empty())
|
||||
{
|
||||
Glib::ustring temp = FS_Info::get_path_by_uuid(uuid);
|
||||
if (! temp.empty())
|
||||
node = temp;
|
||||
}
|
||||
|
||||
Glib::ustring label = Utils::regexp_label(ref_nodes[i].m_name, "^LABEL=(.*)");
|
||||
if (! label.empty())
|
||||
{
|
||||
Glib::ustring temp = FS_Info::get_path_by_label(label);
|
||||
if (! temp.empty())
|
||||
node = temp;
|
||||
}
|
||||
|
||||
Glib::ustring node = lookup_uuid_or_label(ref_nodes[i].m_name);
|
||||
if (! node.empty())
|
||||
{
|
||||
// Insert new mount entry and delete the old one.
|
||||
|
@ -314,4 +285,19 @@ const MountEntry& Mount_Info::find(MountMapping& map, const Glib::ustring& path)
|
|||
return not_mounted;
|
||||
}
|
||||
|
||||
|
||||
// Return file system's block device given a UUID=... or LABEL=... reference, or return
|
||||
// the empty string when not found.
|
||||
Glib::ustring Mount_Info::lookup_uuid_or_label(const Glib::ustring& ref)
|
||||
{
|
||||
if (ref.compare(0, 5, "UUID=") == 0)
|
||||
return FS_Info::get_path_by_uuid(ref.substr(5));
|
||||
|
||||
if (ref.compare(0, 6, "LABEL=") == 0)
|
||||
return FS_Info::get_path_by_label(ref.substr(6));
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
} //GParted
|
||||
|
|
Loading…
Reference in New Issue