79 lines
3.0 KiB
Diff
79 lines
3.0 KiB
Diff
From 42afed95dc6611dc9585ab23134bdcc39a5b75ec Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Thu, 14 Aug 2025 15:17:59 +0100
|
|
Subject: [PATCH] daemon/inspect_fs_windows.ml: Ignore blank disks in drive
|
|
mapping
|
|
|
|
If HKLM\System\MountedDevices references a blank disk, then when we
|
|
try to search for the actual backing device we will get an error from
|
|
parted:
|
|
|
|
parted: /dev/sdb: parted exited with status 1: Error: /dev/sdb: unrecognised disk label: Invalid argument
|
|
|
|
Just ignore these errors instead of failing inspection.
|
|
|
|
Fixes: https://issues.redhat.com/browse/RHEL-108803
|
|
Reported-by: Ameen Barakat
|
|
Thanks: Ming Xie
|
|
---
|
|
daemon/inspect_fs_windows.ml | 35 ++++++++++++++++++++++++++---------
|
|
1 file changed, 26 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/daemon/inspect_fs_windows.ml b/daemon/inspect_fs_windows.ml
|
|
index 00acf5196..ba8ef4ee3 100644
|
|
--- a/daemon/inspect_fs_windows.ml
|
|
+++ b/daemon/inspect_fs_windows.ml
|
|
@@ -389,8 +389,18 @@ and map_registry_disk_blob_mbr devices blob =
|
|
let device =
|
|
List.find (
|
|
fun dev ->
|
|
- Parted.part_get_parttype dev = "msdos" &&
|
|
+ try
|
|
+ Parted.part_get_parttype dev = "msdos" &&
|
|
pread dev 4 0x01b8 = diskid
|
|
+ with Unix.Unix_error (EINVAL, "parted", msg) ->
|
|
+ (* Errors can happen here if the disk is empty. Just ignore
|
|
+ * them. It means the drive mapping might have missing
|
|
+ * entries but that's not important. (RHEL-108803)
|
|
+ *)
|
|
+ if verbose () then
|
|
+ eprintf "map_registry_disk_blob_mbr: parted returned: \
|
|
+ %s (ignored)\n" msg;
|
|
+ false
|
|
) devices in
|
|
|
|
(* Next 8 bytes are the offset of the partition in bytes(!) given as
|
|
@@ -428,14 +438,21 @@ and map_registry_disk_blob_gpt partitions blob =
|
|
let partition =
|
|
List.find (
|
|
fun part ->
|
|
- let partnum = Devsparts.part_to_partnum part in
|
|
- let device = Devsparts.part_to_dev part in
|
|
- let typ = Parted.part_get_parttype device in
|
|
- if typ <> "gpt" then false
|
|
- else (
|
|
- let guid = Sfdisk.part_get_gpt_guid device partnum in
|
|
- String.lowercase_ascii guid = blob_guid
|
|
- )
|
|
+ try
|
|
+ let partnum = Devsparts.part_to_partnum part in
|
|
+ let device = Devsparts.part_to_dev part in
|
|
+ let typ = Parted.part_get_parttype device in
|
|
+ if typ <> "gpt" then false
|
|
+ else (
|
|
+ let guid = Sfdisk.part_get_gpt_guid device partnum in
|
|
+ String.lowercase_ascii guid = blob_guid
|
|
+ )
|
|
+ with Unix.Unix_error (EINVAL, "parted", msg) ->
|
|
+ (* See comment in MBR code above (RHEL-108803) *)
|
|
+ if verbose () then
|
|
+ eprintf "map_registry_disk_blob_gpt: parted returned: \
|
|
+ %s (ignored)\n" msg;
|
|
+ false
|
|
) partitions in
|
|
Some partition
|
|
with
|
|
--
|
|
2.47.1
|
|
|