From 1e0099671a2cd75e3407fc02cd16584fce3ba4ee Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 12 Aug 2025 13:04:45 +0100 Subject: [PATCH] daemon: sysroot: Avoid double-/ when creating sysroot paths in OCaml Previously calling 'sysroot_path "/dev"' for example would return the string "/sysroot//dev". While this is not wrong, it confuses some external programs (hello, setfiles), and it's not very "clean". Be a bit more careful to avoid doubling the '/' character in the common case. --- daemon/sysroot.ml | 6 +++++- daemon/sysroot.mli | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/daemon/sysroot.ml b/daemon/sysroot.ml index 286d125b9..57e727066 100644 --- a/daemon/sysroot.ml +++ b/daemon/sysroot.ml @@ -20,4 +20,8 @@ open Std_utils external sysroot : unit -> string = "guestfs_int_daemon_sysroot" -let sysroot_path path = sysroot () // path +let sysroot_path path = + let sysroot = sysroot () in + if path = "" then sysroot + else if path.[0] = '/' then sysroot ^ path + else sysroot // path diff --git a/daemon/sysroot.mli b/daemon/sysroot.mli index 7f8970cd8..1e6e75902 100644 --- a/daemon/sysroot.mli +++ b/daemon/sysroot.mli @@ -22,4 +22,4 @@ val sysroot : unit -> string in default. *) val sysroot_path : string -> string -(** Equivalent to calling [sysroot () // path] *) +(** Prepend [path] parameter with the sysroot. *) -- 2.47.1