- fun root -> {
- insp_root = root;
- insp_arch = g#inspect_get_arch root;
- insp_distro = g#inspect_get_distro root;
- insp_filesystems = g#inspect_get_filesystems root;
- insp_hostname = g#inspect_get_hostname root;
- insp_major_version = g#inspect_get_major_version root;
- insp_minor_version = g#inspect_get_minor_version root;
- insp_mountpoints = g#inspect_get_mountpoints root;
- insp_package_format = g#inspect_get_package_format root;
- insp_package_management = g#inspect_get_package_management root;
- insp_product_name = g#inspect_get_product_name root;
- insp_type = g#inspect_get_type root;
- insp_windows_systemroot =
- try Some (g#inspect_get_windows_systemroot root)
- with Guestfs.Error _ -> None
- }
+ fun root ->
+ let typ = g#inspect_get_type root in
+ let windows_current_control_set =
+ if typ <> "windows" then None
+ else (
+ try Some (g#inspect_get_windows_current_control_set root)
+ with G.Error _ -> None
+ ) in
+ let windows_systemroot =
+ if typ <> "windows" then None
+ else (
+ try Some (g#inspect_get_windows_systemroot root)
+ with G.Error _ -> None
+ ) in
+
+ (* Create most of the OS object that we're going to return. We
+ * have to pass this to with_mount_ro below which is why we need
+ * to partially create it here.
+ *)
+ let os = {
+ insp_root = root;
+ insp_arch = g#inspect_get_arch root;
+ insp_distro = g#inspect_get_distro root;
+ insp_drive_mappings = g#inspect_get_drive_mappings root;
+ insp_filesystems = g#inspect_get_filesystems root;
+ insp_hostname = g#inspect_get_hostname root;
+ insp_major_version = g#inspect_get_major_version root;
+ insp_minor_version = g#inspect_get_minor_version root;
+ insp_mountpoints = g#inspect_get_mountpoints root;
+ insp_package_format = g#inspect_get_package_format root;
+ insp_package_management = g#inspect_get_package_management root;
+ insp_product_name = g#inspect_get_product_name root;
+ insp_product_variant = g#inspect_get_product_variant root;
+ insp_type = typ;
+ insp_windows_current_control_set = windows_current_control_set;
+ insp_windows_systemroot = windows_systemroot;
+ insp_winreg_DEFAULT = None; (* incomplete, see below *)
+ insp_winreg_SAM = None;
+ insp_winreg_SECURITY = None;
+ insp_winreg_SOFTWARE = None;
+ insp_winreg_SYSTEM = None;
+ } in
+
+ (* We need to mount the root in order to look for Registry hives. *)
+ let winreg_DEFAULT, winreg_SAM, winreg_SECURITY, winreg_SOFTWARE,
+ winreg_SYSTEM =
+ match windows_systemroot with
+ | None -> None, None, None, None, None
+ | Some sysroot ->
+ with_mount_ro g (OS os) (
+ fun () ->
+ let check_for_hive filename =
+ let path =
+ sprintf "%s/system32/config/%s" sysroot filename in
+ try Some (g#case_sensitive_path path)
+ with G.Error _ -> None
+ in
+ check_for_hive "default",
+ check_for_hive "sam",
+ check_for_hive "security",
+ check_for_hive "software",
+ check_for_hive "system"
+ ) in
+
+ (* Fill in the remaining struct fields. *)
+ let os = { os with
+ insp_winreg_DEFAULT = winreg_DEFAULT;
+ insp_winreg_SAM = winreg_SAM;
+ insp_winreg_SECURITY = winreg_SECURITY;
+ insp_winreg_SOFTWARE = winreg_SOFTWARE;
+ insp_winreg_SYSTEM = winreg_SYSTEM
+ } in
+ os