mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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.
(cherry picked from commit 1e0099671a)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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. *)
|
||||
|
||||
Reference in New Issue
Block a user