From 26b97b7a1addcceed3c0095541e92c9fff5bd004 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 7 Mar 2024 14:20:43 +0000 Subject: [PATCH] daemon: listfs: Ignore invalid partitions in check Commit b699111e04 ("daemon: list-filesystems: Filter out MBR extended partitions.") calls part_get_gpt_type which calls sgdisk to get the partition type. However sgdisk can fail, eg. on ISOs. Catch this case and ignore. The error was: guestfsd: error: sgdisk: Invalid partition data! Reported-by: Andrey Drobyshev Fixes: commit b699111e04665276fd61f3ca68b91066e8a296fb --- daemon/listfs.ml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/daemon/listfs.ml b/daemon/listfs.ml index 2376b61dbc..3c6e86fa59 100644 --- a/daemon/listfs.ml +++ b/daemon/listfs.ml @@ -113,17 +113,20 @@ and is_partition_can_hold_filesystem partition = true else ( (* MBR partition id will be converted into corresponding GPT type. *) - let gpt_type = Parted.part_get_gpt_type device partnum in + let gpt_type = + try Some (Parted.part_get_gpt_type device partnum) + with Failure _ -> None in match gpt_type with (* Windows Logical Disk Manager metadata partition. *) - | "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3" + | Some "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3" (* Windows Logical Disk Manager data partition. *) - | "AF9B60A0-1431-4F62-BC68-3311714A69AD" + | Some "AF9B60A0-1431-4F62-BC68-3311714A69AD" (* Microsoft Reserved Partition. *) - | "E3C9E316-0B5C-4DB8-817D-F92DF00215AE" + | Some "E3C9E316-0B5C-4DB8-817D-F92DF00215AE" (* Windows Snapshot Partition. *) - | "CADDEBF1-4400-4DE8-B103-12117DCF3CCF" -> false - | _ -> true + | Some "CADDEBF1-4400-4DE8-B103-12117DCF3CCF" -> false + (* Any other partition type, or if there is no partition. *) + | Some _ | None -> true ) ) else true -- 2.43.1