mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
daemon: Search device-mapper devices for list-filesystems API.
In case any bare filesystems were decrypted using cryptsetup-open, they would appear as /dev/mapper/name devices. Since list-filesystems did not consider those when searching for filesystems, the unencrypted filesystems would not be returned. Note that previously this worked for LUKS because the common case (eg. for Fedora) was that whole devices were encrypted and thoes devices contained LVs, so luks-open + vgactivate would activate the LVs which would then be found by list-filesystems. For Windows BitLocker, the common case seems to be that each separate NTFS filesystem is contained in a separate BitLocker wrapper.
This commit is contained in:
@@ -35,6 +35,14 @@ let rec list_filesystems () =
|
||||
let devices = List.filter is_not_partitioned_device devices in
|
||||
List.iter (check_with_vfs_type ret) devices;
|
||||
|
||||
(* Device-mapper devices.
|
||||
* We include these in case any encrypted devices contain
|
||||
* direct filesystems.
|
||||
*)
|
||||
let devices = Lvm_dm.list_dm_devices () in
|
||||
let devices = List.filter is_not_partitioned_device devices in
|
||||
List.iter (check_with_vfs_type ret) devices;
|
||||
|
||||
(* Partitions. *)
|
||||
let partitions = Devsparts.list_partitions () in
|
||||
let partitions = List.filter is_partition_can_hold_filesystem partitions in
|
||||
@@ -64,6 +72,11 @@ let rec list_filesystems () =
|
||||
* such devices.
|
||||
*)
|
||||
and is_not_partitioned_device device =
|
||||
let device =
|
||||
if String.is_prefix device "/dev/mapper/" then
|
||||
Unix_utils.Realpath.realpath device
|
||||
else
|
||||
device in
|
||||
assert (String.is_prefix device "/dev/");
|
||||
let dev_name = String.sub device 5 (String.length device - 5) in
|
||||
let dev_dir = "/sys/block/" ^ dev_name in
|
||||
|
||||
Reference in New Issue
Block a user