libguestfs/0014-daemon-inspect_fs_windows.ml-Add-debugging-for-MBR-d.patch
Richard W.M. Jones 5c2ffa1df5 Ignore blank disks in Windows drive mapping
resolves: RHEL-109258
2025-08-14 16:04:08 +01:00

76 lines
2.6 KiB
Diff

From b43ca06ea69cebbdd774ed03bc0da63eb3955d66 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 14 Aug 2025 14:56:47 +0100
Subject: [PATCH] daemon/inspect_fs_windows.ml: Add debugging for MBR drive
mappings
The function 'map_registry_disk_blob_gpt' immediately below this one
has a debugging statement. Add the equivalent to the function
'map_registry_disk_blob_mbr'.
The output looks like:
map_registry_disk_blob_mbr: searching for MBR disk ID 31 32 33 34
map_registry_disk_blob_mbr: searching for MBR partition offset 00 00 00 10 00 00 00 00
---
daemon/inspect_fs_windows.ml | 8 ++++++++
daemon/utils.ml | 4 ++++
daemon/utils.mli | 4 ++++
3 files changed, 16 insertions(+)
diff --git a/daemon/inspect_fs_windows.ml b/daemon/inspect_fs_windows.ml
index dbaf4c362..5991cdba3 100644
--- a/daemon/inspect_fs_windows.ml
+++ b/daemon/inspect_fs_windows.ml
@@ -376,6 +376,10 @@ and map_registry_disk_blob_mbr devices blob =
* disk with this disk ID.
*)
let diskid = String.sub blob 0 4 in
+ if verbose () then
+ eprintf "map_registry_disk_blob_mbr: searching for MBR disk ID %s\n%!"
+ (hex_of_string diskid);
+
let device =
List.find (
fun dev ->
@@ -388,6 +392,10 @@ and map_registry_disk_blob_mbr devices blob =
* partition byte offset from Parted.part_list.
*)
let offset = String.sub blob 4 8 in
+ if verbose () then
+ eprintf "map_registry_disk_blob_mbr: searching for MBR partition offset \
+ %s\n%!"
+ (hex_of_string offset);
let offset = int_of_le64 offset in
let partitions = Parted.part_list device in
let partition =
diff --git a/daemon/utils.ml b/daemon/utils.ml
index 40584c9f1..3aa1d7ed2 100644
--- a/daemon/utils.ml
+++ b/daemon/utils.ml
@@ -291,3 +291,7 @@ let parse_key_value_strings ?unquote lines =
match unquote with
| None -> lines
| Some f -> List.map (fun (k, v) -> (k, f v)) lines
+
+let hex_of_string s =
+ let bytes = String.map_chars (fun c -> sprintf "%02x" (Char.code c)) s in
+ String.concat " " bytes
diff --git a/daemon/utils.mli b/daemon/utils.mli
index 0f2ae471f..e14735038 100644
--- a/daemon/utils.mli
+++ b/daemon/utils.mli
@@ -121,5 +121,9 @@ val parse_key_value_strings : ?unquote:(string -> string) -> string list -> (str
it is applied on the values as unquote function. Empty lines,
or that start with a comment character [#], are ignored. *)
+val hex_of_string : string -> string
+(** Return a string as a list of hex bytes.
+ Use this for debugging msgs only. *)
+
(**/**)
val get_verbose_flag : unit -> bool
--
2.47.1