On Tue, Jan 21, 2020 at 03:07:12PM +0100, Jan Synacek wrote:
> ---
> daemon/listfs.ml | 18 +++---
> daemon/luks.c| 1 +
> 2 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/daemon/listfs.ml b/daemon/listfs.ml
> index bf4dca6d4..48880f2e5 100644
> --- a/daemon/listfs.ml
> +++ b/daemon/listfs.ml
> @@ -19,6 +19,7 @@
> open Printf
>
> open Std_utils
> +open Utils
>
> (* Enumerate block devices (including MD, LVM, LDM and partitions) and use
> * vfs-type to check for filesystems on devices. Some block devices cannot
> @@ -30,6 +31,7 @@ let rec list_filesystems () =
>
>(* Devices. *)
>let devices = Devsparts.list_devices () in
> +
>let devices = List.filter is_not_partitioned_device devices in
>let ret = List.filter_map check_with_vfs_type devices in
>
> @@ -144,9 +146,19 @@ and check_with_vfs_type device =
>else if String.is_suffix vfs_type "_member" then
> None
>
> - (* Ignore LUKS-encrypted partitions. These are also containers, as above.
> *)
> - else if vfs_type = "crypto_LUKS" then
> -None
> + (* If a LUKS-encrypted partition had been opened, include the corresponding
> + * device mapper filesystem path. *)
> + else if vfs_type = "crypto_LUKS" then (
> +let out = command "lsblk" ["-n"; "-l"; "-o"; "NAME"; device] in
> + (* Example output: #lsblk -n -l -o NAME /dev/sda5
> + * sda5
> + * lukssda5
> + *)
> + match String.trimr @@ snd @@ String.split "\n" out with
> + | "" -> None
> + | part -> let mnt = Mountable.of_path @@ "/dev/mapper/" ^ part in
As a matter of style I'd put the "let" on a new line.
> + Some [mnt, Blkid.vfs_type mnt]
> + )
>
>(* A single btrfs device can turn into many volumes. *)
>else if vfs_type = "btrfs" then (
> diff --git a/daemon/luks.c b/daemon/luks.c
> index d631cb100..1ffeaf293 100644
> --- a/daemon/luks.c
> +++ b/daemon/luks.c
> @@ -110,6 +110,7 @@ luks_open (const char *device, const char *key, const
> char *mapname,
>ADD_ARG (argv, i, "-d");
>ADD_ARG (argv, i, tempfile);
>if (readonly) ADD_ARG (argv, i, "--readonly");
> + ADD_ARG (argv, i, "--allow-discards");
>ADD_ARG (argv, i, "luksOpen");
>ADD_ARG (argv, i, device);
>ADD_ARG (argv, i, mapname);
Seems fine except for considering if --allow-discards should
be a flag (boolean optarg) for the luks_open API.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs