Rebase to libguestfs 1.55.12

resolves: RHEL-81733
Add btrfs-scrub-full API
resolves: RHEL-91936
This commit is contained in:
Richard W.M. Jones 2025-05-19 18:30:28 +01:00
parent 1783ce95ba
commit e10b8ff144
12 changed files with 3449 additions and 1623 deletions

View File

@ -1,38 +0,0 @@
From f6b1a7b57f96f002074e626d58b58f4244080ec9 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 9 May 2025 15:52:30 +0100
Subject: [PATCH] appliance: Remove zfs-fuse
zfs-fuse has been unmaintained for a very long time. In fact, the
website has gone. This means that whatever we need for zfs (probably
some kind of license-compatible kernel module) is not going to be
provided by zfs-fuse.
See: https://bugzilla.redhat.com/show_bug.cgi?id=2214965
---
appliance/packagelist.in | 2 --
1 file changed, 2 deletions(-)
diff --git a/appliance/packagelist.in b/appliance/packagelist.in
index d0637631d..f8c80af24 100644
--- a/appliance/packagelist.in
+++ b/appliance/packagelist.in
@@ -51,7 +51,6 @@ ifelse(REDHAT,1,
systemd dnl for /sbin/reboot and udevd
vim-minimal
xz
- zfs-fuse
zstd
)
@@ -95,7 +94,6 @@ dnl isc-dhcp-client has been replaced with dhcpcd-base
ufsutils
vim-tiny
xz-utils
- zfs-fuse
zstd
uuid-runtime
)
--
2.47.1

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
From dffc4f3fa73ee886a057cb450d12b1ee7ad25da9 Mon Sep 17 00:00:00 2001
From 575246780a0f3bbea399ac72c5feba31bc4c3748 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 29 Jul 2013 14:47:56 +0100
Subject: [PATCH] RHEL: Disable unsupported remote drive protocols
@ -180,7 +180,7 @@ index e4e1021db..8419ce78a 100755
rm test-add-uri.out
rm test-add-uri.img
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index 53fa129f5..d6b1eb719 100644
index 2cb8cc430..388366b69 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -350,22 +350,6 @@ F<filename> is interpreted as a local file or device.

View File

@ -1,706 +0,0 @@
From fcd169476f403f9f4f65dddd7c4f05a76b35baeb Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 10 May 2025 18:29:40 +0100
Subject: [PATCH] Update common submodule
Adds these commits:
Richard W.M. Jones (5):
mlstdutils: Modify List.take, List.drop to match OCaml 5.3
mlstdutils: Rename List.dropwhile -> drop_while, takewhile -> take_while
mlstdutils: Add List.last function
mlstdutils: Move List module first
mlstdutils: Add String.common_prefix, longest_common_prefix
---
common | 2 +-
contrib/visualize-alignment/tracetops.ml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Submodule common aa797fa13..4c7ae1581:
diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml
index 8462752..159fc4a 100644
--- a/common/mlstdutils/std_utils.ml
+++ b/common/mlstdutils/std_utils.ml
@@ -18,6 +18,138 @@
open Printf
+module List = struct
+ include List
+
+ (* Drop elements from a list while a predicate is true. *)
+ let rec drop_while f = function
+ | [] -> []
+ | x :: xs when f x -> drop_while f xs
+ | xs -> xs
+
+ (* Take elements from a list while a predicate is true. *)
+ let rec take_while f = function
+ | x :: xs when f x -> x :: take_while f xs
+ | _ -> []
+
+ let take n xs =
+ if n < 0 then invalid_arg "List.take"
+ else if n = 0 then []
+ else (
+ (* This optimisation avoids copying xs. *)
+ let len = List.length xs in
+ if len <= n then xs
+ else (
+ let rec take n = function
+ | x :: xs when n >= 1 -> x :: take (n-1) xs
+ | _ -> []
+ in
+ take n xs
+ )
+ )
+ let rec drop n xs =
+ if n < 0 then invalid_arg "List.drop"
+ else if n = 0 then xs
+ else if xs = [] then []
+ else drop (n-1) (List.tl xs)
+
+ let rec last = function
+ | [] -> invalid_arg "List.last"
+ | [x] -> x
+ | _ :: xs -> last xs
+
+ let rec filter_map f = function
+ | [] -> []
+ | x :: xs ->
+ match f x with
+ | Some y -> y :: filter_map f xs
+ | None -> filter_map f xs
+
+ let rec find_map f = function
+ | [] -> raise Not_found
+ | x :: xs ->
+ match f x with
+ | Some y -> y
+ | None -> find_map f xs
+
+ let rec group_by = function
+ | [] -> []
+ | (day1, x1) :: (day2, x2) :: rest when day1 = day2 ->
+ let rest = group_by ((day2, x2) :: rest) in
+ let day, xs = List.hd rest in
+ (day, x1 :: xs) :: List.tl rest
+ | (day, x) :: rest ->
+ (day, [x]) :: group_by rest
+
+ let rec combine3 xs ys zs =
+ match xs, ys, zs with
+ | [], [], [] -> []
+ | x::xs, y::ys, z::zs -> (x, y, z) :: combine3 xs ys zs
+ | _ -> invalid_arg "combine3"
+
+ let rec assoc_lbl ?(cmp = Stdlib.compare) ~default x = function
+ | [] -> default
+ | (y, y') :: _ when cmp x y = 0 -> y'
+ | _ :: ys -> assoc_lbl ~cmp ~default x ys
+
+ let uniq ?(cmp = Stdlib.compare) xs =
+ let rec loop acc = function
+ | [] -> acc
+ | [x] -> x :: acc
+ | x :: (y :: _ as xs) when cmp x y = 0 ->
+ loop acc xs
+ | x :: (y :: _ as xs) ->
+ loop (x :: acc) xs
+ in
+ List.rev (loop [] xs)
+
+ let remove_duplicates xs =
+ let h = Hashtbl.create (List.length xs) in
+ let rec loop = function
+ | [] -> []
+ | x :: xs when Hashtbl.mem h x -> xs
+ | x :: xs -> Hashtbl.add h x true; x :: loop xs
+ in
+ loop xs
+
+ let push_back xsp x = xsp := !xsp @ [x]
+ let push_front x xsp = xsp := x :: !xsp
+ let pop_back xsp =
+ let x, xs =
+ match List.rev !xsp with
+ | x :: xs -> x, xs
+ | [] -> failwith "pop" in
+ xsp := List.rev xs;
+ x
+ let pop_front xsp =
+ let x, xs =
+ match !xsp with
+ | x :: xs -> x, xs
+ | [] -> failwith "shift" in
+ xsp := xs;
+ x
+
+ let may_push_back xsp x =
+ match x with None -> () | Some x -> push_back xsp x
+ let may_push_front x xsp =
+ match x with None -> () | Some x -> push_front x xsp
+
+ let push_back_list xsp xs = xsp := !xsp @ xs
+ let push_front_list xs xsp = xsp := xs @ !xsp
+
+ let make n x =
+ let rec loop acc = function
+ | 0 -> acc
+ | i when i > 0 -> loop (x :: acc) (i-1)
+ | _ -> invalid_arg "make"
+ in
+ loop [] n
+
+ let same = function
+ | [] -> true
+ | x :: xs -> List.for_all ((=) x) xs
+end
+
module Char = struct
include Char
@@ -302,131 +434,23 @@ module String = struct
loop 0
let unix2dos str = replace str "\n" "\r\n"
-end
-module List = struct
- include List
-
- (* Drop elements from a list while a predicate is true. *)
- let rec dropwhile f = function
- | [] -> []
- | x :: xs when f x -> dropwhile f xs
- | xs -> xs
-
- (* Take elements from a list while a predicate is true. *)
- let rec takewhile f = function
- | x :: xs when f x -> x :: takewhile f xs
- | _ -> []
-
- let take n xs =
- if n <= 0 then []
- else (
- (* This optimisation avoids copying xs. *)
- let len = List.length xs in
- if len <= n then xs
- else (
- let rec take n = function
- | x :: xs when n >= 1 -> x :: take (n-1) xs
- | _ -> []
- in
- take n xs
- )
- )
- let rec drop n xs =
- if n <= 0 then xs
- else if xs = [] then []
- else drop (n-1) (List.tl xs)
-
- let rec filter_map f = function
- | [] -> []
- | x :: xs ->
- match f x with
- | Some y -> y :: filter_map f xs
- | None -> filter_map f xs
-
- let rec find_map f = function
- | [] -> raise Not_found
- | x :: xs ->
- match f x with
- | Some y -> y
- | None -> find_map f xs
-
- let rec group_by = function
- | [] -> []
- | (day1, x1) :: (day2, x2) :: rest when day1 = day2 ->
- let rest = group_by ((day2, x2) :: rest) in
- let day, xs = List.hd rest in
- (day, x1 :: xs) :: List.tl rest
- | (day, x) :: rest ->
- (day, [x]) :: group_by rest
-
- let rec combine3 xs ys zs =
- match xs, ys, zs with
- | [], [], [] -> []
- | x::xs, y::ys, z::zs -> (x, y, z) :: combine3 xs ys zs
- | _ -> invalid_arg "combine3"
-
- let rec assoc_lbl ?(cmp = Stdlib.compare) ~default x = function
- | [] -> default
- | (y, y') :: _ when cmp x y = 0 -> y'
- | _ :: ys -> assoc_lbl ~cmp ~default x ys
-
- let uniq ?(cmp = Stdlib.compare) xs =
- let rec loop acc = function
- | [] -> acc
- | [x] -> x :: acc
- | x :: (y :: _ as xs) when cmp x y = 0 ->
- loop acc xs
- | x :: (y :: _ as xs) ->
- loop (x :: acc) xs
+ let rec longest_common_prefix = function
+ | [] -> ""
+ | [s] -> s
+ | strs ->
+ let strs = List.sort compare strs in
+ let s1 = List.hd strs and s2 = List.last strs in
+ common_prefix s1 s2
+ and common_prefix s1 s2 =
+ let n1 = length s1 and n2 = length s2 in
+ let n = min n1 n2 in
+ let rec loop i =
+ if i = n then sub s1 0 n
+ else if unsafe_get s1 i <> unsafe_get s2 i then sub s1 0 i
+ else loop (i+1)
in
- List.rev (loop [] xs)
-
- let remove_duplicates xs =
- let h = Hashtbl.create (List.length xs) in
- let rec loop = function
- | [] -> []
- | x :: xs when Hashtbl.mem h x -> xs
- | x :: xs -> Hashtbl.add h x true; x :: loop xs
- in
- loop xs
-
- let push_back xsp x = xsp := !xsp @ [x]
- let push_front x xsp = xsp := x :: !xsp
- let pop_back xsp =
- let x, xs =
- match List.rev !xsp with
- | x :: xs -> x, xs
- | [] -> failwith "pop" in
- xsp := List.rev xs;
- x
- let pop_front xsp =
- let x, xs =
- match !xsp with
- | x :: xs -> x, xs
- | [] -> failwith "shift" in
- xsp := xs;
- x
-
- let may_push_back xsp x =
- match x with None -> () | Some x -> push_back xsp x
- let may_push_front x xsp =
- match x with None -> () | Some x -> push_front x xsp
-
- let push_back_list xsp xs = xsp := !xsp @ xs
- let push_front_list xs xsp = xsp := xs @ !xsp
-
- let make n x =
- let rec loop acc = function
- | 0 -> acc
- | i when i > 0 -> loop (x :: acc) (i-1)
- | _ -> invalid_arg "make"
- in
- loop [] n
-
- let same = function
- | [] -> true
- | x :: xs -> List.for_all ((=) x) xs
+ loop 0
end
let (//) = Filename.concat
diff --git a/common/mlstdutils/std_utils.mli b/common/mlstdutils/std_utils.mli
index 566c5b5..2526100 100644
--- a/common/mlstdutils/std_utils.mli
+++ b/common/mlstdutils/std_utils.mli
@@ -16,138 +16,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
-module Char : sig
- type t = char
- val chr : int -> char
- val code : char -> int
- val compare: t -> t -> int
- val escaped : char -> string
- val unsafe_chr : int -> char
-
- val lowercase_ascii : char -> char
- val uppercase_ascii : char -> char
-
- val isspace : char -> bool
- (** Return true if char is a whitespace character. *)
- val isdigit : char -> bool
- (** Return true if the character is a digit [[0-9]]. *)
- val isxdigit : char -> bool
- (** Return true if the character is a hex digit [[0-9a-fA-F]]. *)
- val isalpha : char -> bool
- (** Return true if the character is a US ASCII 7 bit alphabetic. *)
- val isalnum : char -> bool
- (** Return true if the character is a US ASCII 7 bit alphanumeric. *)
-
- val hexdigit : char -> int
- (** Return the value of a hex digit. If the char is not in
- the set [[0-9a-fA-F]] then this returns [-1]. *)
-
- val mem : char -> string -> bool
- (** [mem c str] returns true if the byte [c] is contained in [str].
-
- This is actually the same as {!String.contains} with the
- parameters reversed. *)
-end
-(** Override the Char module from stdlib. *)
-
-module String : sig
- type t = string
- val compare: t -> t -> int
- val concat : string -> string list -> string
- val contains : string -> char -> bool
- val contains_from : string -> int -> char -> bool
- val escaped : string -> string
- val get : string -> int -> char
- val index : string -> char -> int
- val index_from : string -> int -> char -> int
- val iter : (char -> unit) -> string -> unit
- val iteri : (int -> char -> unit) -> string -> unit
- val map : (char -> char) -> string -> string
- val length : string -> int
- val make : int -> char -> string
- val rcontains_from : string -> int -> char -> bool
- val rindex : string -> char -> int
- val rindex_from : string -> int -> char -> int
- val sub : string -> int -> int -> string
- val unsafe_get : string -> int -> char
-
- val lowercase_ascii : string -> string
- val uppercase_ascii : string -> string
- val capitalize_ascii : string -> string
-
- val is_prefix : string -> string -> bool
- (** [is_prefix str prefix] returns true if [prefix] is a prefix of [str]. *)
- val is_suffix : string -> string -> bool
- (** [is_suffix str suffix] returns true if [suffix] is a suffix of [str]. *)
- val find : string -> string -> int
- (** [find str sub] searches for [sub] as a substring of [str]. If
- found it returns the index. If not found, it returns [-1]. *)
- val find_from : string -> int -> string -> int
- (** [find_from str start sub] searches for [sub] as a substring of [str],
- starting at index [start]. If found it returns the index.
- If not found, it returns [-1]. *)
- val replace : string -> string -> string -> string
- (** [replace str s1 s2] replaces all instances of [s1] appearing in
- [str] with [s2]. *)
- val replace_char : string -> char -> char -> string
- (** Replace character in string. *)
- val break : int -> string -> string * string
- (** [break n str] breaks a string at the nth byte, returning the
- first and second parts. If [n] is beyond the end of the
- string it returns [(str, "")]. *)
- val split : string -> string -> string * string
- (** [split sep str] splits [str] at the first occurrence of the
- separator [sep], returning the part before and the part after.
- If separator is not found, return the whole string and an
- empty string. *)
- val nsplit : ?max:int -> string -> string -> string list
- (** [nsplit ?max sep str] splits [str] into multiple strings at each
- separator [sep].
-
- As with the Perl split function, you can give an optional
- [?max] parameter to limit the number of strings returned. The
- final element of the list will contain the remainder of the
- input string. *)
- val lines_split : string -> string list
- (** [lines_split str] splits [str] into lines, keeping continuation
- characters (i.e. [\] at the end of lines) into account. *)
- val random8 : unit -> string
- (** Return a string of 8 random printable characters. *)
- val triml : ?test:(char -> bool) -> string -> string
- (** Trim left. *)
- val trimr : ?test:(char -> bool) -> string -> string
- (** Trim right. *)
- val trim : ?test:(char -> bool) -> string -> string
- (** Trim left and right. *)
- val chomp : string -> string
- (** If the string ends with [\n], remove it. *)
- val count_chars : char -> string -> int
- (** Count number of times the character occurs in string. *)
- val explode : string -> char list
- (** Explode a string into a list of characters. *)
- val map_chars : (char -> 'a) -> string -> 'a list
- (** Explode string, then map function over the characters. *)
- val implode : char list -> string
- (** Join list of characters into a single string. *)
- val spaces : int -> string
- (** [spaces n] creates a string of n spaces. *)
- val span : string -> string -> int
- val cspan : string -> string -> int
- (** [span str accept] returns the length in bytes of the initial
- segment of [str] which contains only bytes in [accept].
-
- [cspan str reject] returns the length in bytes of the initial
- segment of [str] which contains only bytes {!i not} in [reject].
-
- These work exactly like the C functions [strspn] and [strcspn]. *)
- val unix2dos : string -> string
- (** Convert string with ordinary Unix-style line-endings to
- CRLF DOS-style line-endings.
-
- The same as {!String.replace} [str "\n" "\r\n"]. *)
-end
-(** Override the String module from stdlib. *)
-
module List : sig
val length : 'a list -> int
val hd : 'a list -> 'a
@@ -194,11 +62,11 @@ module List : sig
val sort_uniq : ('a -> 'a -> int) -> 'a list -> 'a list
val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
- val dropwhile : ('a -> bool) -> 'a list -> 'a list
- (** [dropwhile f xs] drops leading elements from [xs] until
+ val drop_while : ('a -> bool) -> 'a list -> 'a list
+ (** [drop_while f xs] drops leading elements from [xs] until
[f] returns false. *)
- val takewhile : ('a -> bool) -> 'a list -> 'a list
- (** [takewhile f xs] takes leading elements from [xs] until
+ val take_while : ('a -> bool) -> 'a list -> 'a list
+ (** [take_while f xs] takes leading elements from [xs] until
[f] returns false.
For any list [xs] and function [f],
@@ -206,12 +74,21 @@ module List : sig
val take : int -> 'a list -> 'a list
(** [take n xs] returns the first [n] elements of [xs]. If [xs] is
- shorter than [n], then it returns [xs]. Note it never fails
- for any input. *)
+ shorter than [n], then it returns [xs]. [n] must be non-negative.
+
+ @raise Invalid_argument if [n] is negative *)
val drop : int -> 'a list -> 'a list
(** [drop n xs] returns the suffix of [xs] after the first [n]
elements. If [xs] is shorter than [n], then it returns the empty
- list. Note it never fails for any input. *)
+ list. [n] must be non-negative.
+
+ @raise Invalid_argument if [n] is negative *)
+
+ val last : 'a list -> 'a
+ (** Return the last element in the list (analogous to {!List.hd} but
+ much less efficient).
+
+ @raise Invalid_argument if the list is empty *)
val filter_map : ('a -> 'b option) -> 'a list -> 'b list
(** [filter_map f xs] applies [f] to each element of [xs]. If
@@ -302,6 +179,144 @@ module List : sig
end
(** Override the List module from stdlib. *)
+module Char : sig
+ type t = char
+ val chr : int -> char
+ val code : char -> int
+ val compare: t -> t -> int
+ val escaped : char -> string
+ val unsafe_chr : int -> char
+
+ val lowercase_ascii : char -> char
+ val uppercase_ascii : char -> char
+
+ val isspace : char -> bool
+ (** Return true if char is a whitespace character. *)
+ val isdigit : char -> bool
+ (** Return true if the character is a digit [[0-9]]. *)
+ val isxdigit : char -> bool
+ (** Return true if the character is a hex digit [[0-9a-fA-F]]. *)
+ val isalpha : char -> bool
+ (** Return true if the character is a US ASCII 7 bit alphabetic. *)
+ val isalnum : char -> bool
+ (** Return true if the character is a US ASCII 7 bit alphanumeric. *)
+
+ val hexdigit : char -> int
+ (** Return the value of a hex digit. If the char is not in
+ the set [[0-9a-fA-F]] then this returns [-1]. *)
+
+ val mem : char -> string -> bool
+ (** [mem c str] returns true if the byte [c] is contained in [str].
+
+ This is actually the same as {!String.contains} with the
+ parameters reversed. *)
+end
+(** Override the Char module from stdlib. *)
+
+module String : sig
+ type t = string
+ val compare: t -> t -> int
+ val concat : string -> string list -> string
+ val contains : string -> char -> bool
+ val contains_from : string -> int -> char -> bool
+ val escaped : string -> string
+ val get : string -> int -> char
+ val index : string -> char -> int
+ val index_from : string -> int -> char -> int
+ val iter : (char -> unit) -> string -> unit
+ val iteri : (int -> char -> unit) -> string -> unit
+ val map : (char -> char) -> string -> string
+ val length : string -> int
+ val make : int -> char -> string
+ val rcontains_from : string -> int -> char -> bool
+ val rindex : string -> char -> int
+ val rindex_from : string -> int -> char -> int
+ val sub : string -> int -> int -> string
+ val unsafe_get : string -> int -> char
+
+ val lowercase_ascii : string -> string
+ val uppercase_ascii : string -> string
+ val capitalize_ascii : string -> string
+
+ val is_prefix : string -> string -> bool
+ (** [is_prefix str prefix] returns true if [prefix] is a prefix of [str]. *)
+ val is_suffix : string -> string -> bool
+ (** [is_suffix str suffix] returns true if [suffix] is a suffix of [str]. *)
+ val find : string -> string -> int
+ (** [find str sub] searches for [sub] as a substring of [str]. If
+ found it returns the index. If not found, it returns [-1]. *)
+ val find_from : string -> int -> string -> int
+ (** [find_from str start sub] searches for [sub] as a substring of [str],
+ starting at index [start]. If found it returns the index.
+ If not found, it returns [-1]. *)
+ val replace : string -> string -> string -> string
+ (** [replace str s1 s2] replaces all instances of [s1] appearing in
+ [str] with [s2]. *)
+ val replace_char : string -> char -> char -> string
+ (** Replace character in string. *)
+ val break : int -> string -> string * string
+ (** [break n str] breaks a string at the nth byte, returning the
+ first and second parts. If [n] is beyond the end of the
+ string it returns [(str, "")]. *)
+ val split : string -> string -> string * string
+ (** [split sep str] splits [str] at the first occurrence of the
+ separator [sep], returning the part before and the part after.
+ If separator is not found, return the whole string and an
+ empty string. *)
+ val nsplit : ?max:int -> string -> string -> string list
+ (** [nsplit ?max sep str] splits [str] into multiple strings at each
+ separator [sep].
+
+ As with the Perl split function, you can give an optional
+ [?max] parameter to limit the number of strings returned. The
+ final element of the list will contain the remainder of the
+ input string. *)
+ val lines_split : string -> string list
+ (** [lines_split str] splits [str] into lines, keeping continuation
+ characters (i.e. [\] at the end of lines) into account. *)
+ val random8 : unit -> string
+ (** Return a string of 8 random printable characters. *)
+ val triml : ?test:(char -> bool) -> string -> string
+ (** Trim left. *)
+ val trimr : ?test:(char -> bool) -> string -> string
+ (** Trim right. *)
+ val trim : ?test:(char -> bool) -> string -> string
+ (** Trim left and right. *)
+ val chomp : string -> string
+ (** If the string ends with [\n], remove it. *)
+ val count_chars : char -> string -> int
+ (** Count number of times the character occurs in string. *)
+ val explode : string -> char list
+ (** Explode a string into a list of characters. *)
+ val map_chars : (char -> 'a) -> string -> 'a list
+ (** Explode string, then map function over the characters. *)
+ val implode : char list -> string
+ (** Join list of characters into a single string. *)
+ val spaces : int -> string
+ (** [spaces n] creates a string of n spaces. *)
+ val span : string -> string -> int
+ val cspan : string -> string -> int
+ (** [span str accept] returns the length in bytes of the initial
+ segment of [str] which contains only bytes in [accept].
+
+ [cspan str reject] returns the length in bytes of the initial
+ segment of [str] which contains only bytes {!i not} in [reject].
+
+ These work exactly like the C functions [strspn] and [strcspn]. *)
+ val unix2dos : string -> string
+ (** Convert string with ordinary Unix-style line-endings to
+ CRLF DOS-style line-endings.
+
+ The same as {!String.replace} [str "\n" "\r\n"]. *)
+ val common_prefix : string -> string -> string
+ (** Return the longest common prefix of two strings. *)
+ val longest_common_prefix : string list -> string
+ (** Return the longest common prefix of all the strings in the list.
+ If the list is empty or there is no common prefix, [""] is
+ returned. If there is only one string in the list, it is returned. *)
+end
+(** Override the String module from stdlib. *)
+
val ( // ) : string -> string -> string
(** Concatenate directory and filename. *)
diff --git a/common/mlstdutils/std_utils_tests.ml b/common/mlstdutils/std_utils_tests.ml
index aadab17..abe842b 100644
--- a/common/mlstdutils/std_utils_tests.ml
+++ b/common/mlstdutils/std_utils_tests.ml
@@ -190,6 +190,37 @@ let () =
assert_equal_string "" (String.chomp "\n");
assert_equal_string "\n" (String.chomp "\n\n") (* only removes one *)
+(* Test Std_utils.String.common_prefix, longest_common_prefix. *)
+let () =
+ assert_equal_string "" (String.common_prefix "" "");
+ assert_equal_string "" (String.common_prefix "" "abc");
+ assert_equal_string "" (String.common_prefix "abc" "");
+ assert_equal_string "" (String.common_prefix "hello" "world");
+ assert_equal_string "abc" (String.common_prefix "abc" "abcde");
+ assert_equal_string "abc" (String.common_prefix "abcde" "abc");
+ assert_equal_string "abc" (String.common_prefix "abcde" "abcghi");
+ assert_equal_string "" (String.longest_common_prefix []);
+ assert_equal_string "" (String.longest_common_prefix [""]);
+ assert_equal_string "abc" (String.longest_common_prefix ["abc"]);
+ assert_equal_string "" (String.longest_common_prefix [""; "abc"]);
+ assert_equal_string "" (String.longest_common_prefix ["abc"; ""]);
+ assert_equal_string "" (String.longest_common_prefix ["hello"; "world"]);
+ assert_equal_string ""
+ (String.longest_common_prefix ["hello"; "there"; "world"]);
+ assert_equal_string "abc" (String.longest_common_prefix ["abc"; "abcde"]);
+ assert_equal_string "abc" (String.longest_common_prefix ["abcde"; "abc"]);
+ assert_equal_string "abc" (String.longest_common_prefix ["abcde"; "abcghi"]);
+ assert_equal_string "abc"
+ (String.longest_common_prefix ["abcde"; "abcghi"; "abc123"]);
+ assert_equal_string "abc"
+ (String.longest_common_prefix ["abc"; "abcghi"; "abc123"]);
+ assert_equal_string "abc"
+ (String.longest_common_prefix ["abcde"; "abc"; "abc123"]);
+ assert_equal_string "abc"
+ (String.longest_common_prefix ["abcde"; "abcde"; "abc"]);
+ assert_equal_string "abc"
+ (String.longest_common_prefix ["abc"; "abc"; "abc"])
+
(* Test Std_utils.which. *)
let () =
assert_nonempty_string (which "true");
@@ -216,3 +247,9 @@ let () =
let () =
assert_bool "List.same []" (List.same (List.make 0 "1"));
assert_bool "List.same [1; 1; ...; 1]" (List.same (List.make 10 1))
+
+(* Test List.last. *)
+let () =
+ assert_equal_string "3" (List.last ["1"; "2"; "3"]);
+ assert_equal_string "1" (List.last ["1"]);
+ assert_raises (Invalid_argument "List.last") (fun () -> List.last [])
diff --git a/contrib/visualize-alignment/tracetops.ml b/contrib/visualize-alignment/tracetops.ml
index b838b30f3..102a03580 100755
--- a/contrib/visualize-alignment/tracetops.ml
+++ b/contrib/visualize-alignment/tracetops.ml
@@ -185,7 +185,7 @@ let ranges =
loop i0 rest
| (false, i1) :: rest ->
let i1 = i1 - 1 in
- let rest = List.dropwhile (function (v, _) -> not v) rest in
+ let rest = List.drop_while (function (v, _) -> not v) rest in
(match rest with
| [] -> [i0, i1]
| (_, i2) :: rest -> (i0, i1) :: loop i2 rest)
--
2.47.1

View File

@ -1,4 +1,4 @@
From e55a14036a8d2f7d6c00a55e9e781855bfc7e180 Mon Sep 17 00:00:00 2001
From 67bda9410ac10e83203e017a1a4873650dc4f232 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 7 Jul 2015 09:28:03 -0400
Subject: [PATCH] RHEL: Reject use of libguestfs-winsupport features except for

View File

@ -1,248 +0,0 @@
From c4ebeee5053a2f4ac87968121c29b64a596d42aa Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 11 May 2025 12:37:23 +0100
Subject: [PATCH] Update common submodule
Pull in these commits which require minor changes:
Richard W.M. Jones (3):
mlstdutils: Remove Std_utils.identity
mlstdutils: Remove Std_utils.protect
mlstdutils: Remove List.filter_map
---
common | 2 +-
daemon/btrfs.ml | 4 ++--
daemon/cryptsetup.ml | 2 +-
daemon/filearch.ml | 2 +-
daemon/inspect_utils.ml | 6 +++---
daemon/sfdisk.ml | 2 +-
6 files changed, 9 insertions(+), 9 deletions(-)
Submodule common 4c7ae1581..3a05f1a7a:
diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml
index 159fc4a..39b5bc9 100644
--- a/common/mlstdutils/std_utils.ml
+++ b/common/mlstdutils/std_utils.ml
@@ -58,13 +58,6 @@ module List = struct
| [x] -> x
| _ :: xs -> last xs
- let rec filter_map f = function
- | [] -> []
- | x :: xs ->
- match f x with
- | Some y -> y :: filter_map f xs
- | None -> filter_map f xs
-
let rec find_map f = function
| [] -> raise Not_found
| x :: xs ->
@@ -463,8 +456,6 @@ let ( /^ ) = Int64.div
let ( &^ ) = Int64.logand
let ( ~^ ) = Int64.lognot
-external identity : 'a -> 'a = "%identity"
-
let roundup64 i a = let a = a -^ 1L in (i +^ a) &^ (~^ a)
let div_roundup64 i a = (i +^ a -^ 1L) /^ a
@@ -628,13 +619,6 @@ let unique = let i = ref 0 in fun () -> incr i; !i
type ('a, 'b) maybe = Either of 'a | Or of 'b
-let protect ~f ~finally =
- let r =
- try Either (f ())
- with exn -> Or exn in
- finally ();
- match r with Either ret -> ret | Or exn -> raise exn
-
type 'a return = { return: 'b. 'a -> 'b } [@@unboxed]
let with_return (type a) f =
let exception Return of a in
@@ -691,15 +675,15 @@ let wrap () = !wrap
let with_open_in filename f =
let chan = open_in filename in
- protect ~f:(fun () -> f chan) ~finally:(fun () -> close_in chan)
+ Fun.protect (fun () -> f chan) ~finally:(fun () -> close_in chan)
let with_open_out filename f =
let chan = open_out filename in
- protect ~f:(fun () -> f chan) ~finally:(fun () -> close_out chan)
+ Fun.protect (fun () -> f chan) ~finally:(fun () -> close_out chan)
let with_openfile filename flags perms f =
let fd = Unix.openfile filename flags perms in
- protect ~f:(fun () -> f fd) ~finally:(fun () -> Unix.close fd)
+ Fun.protect (fun () -> f fd) ~finally:(fun () -> Unix.close fd)
let read_whole_file path =
let buf = Buffer.create 16384 in
diff --git a/common/mlstdutils/std_utils.mli b/common/mlstdutils/std_utils.mli
index 2526100..04c780a 100644
--- a/common/mlstdutils/std_utils.mli
+++ b/common/mlstdutils/std_utils.mli
@@ -31,6 +31,7 @@ module List : sig
val map : ('a -> 'b) -> 'a list -> 'b list
val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
val rev_map : ('a -> 'b) -> 'a list -> 'b list
+ val filter_map : ('a -> 'b option) -> 'a list -> 'b list
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
@@ -90,9 +91,6 @@ module List : sig
@raise Invalid_argument if the list is empty *)
- val filter_map : ('a -> 'b option) -> 'a list -> 'b list
- (** [filter_map f xs] applies [f] to each element of [xs]. If
- [f x] returns [Some y] then [y] is added to the returned list. *)
val find_map : ('a -> 'b option) -> 'a list -> 'b
(** [find_map f xs] applies [f] to each element of [xs] until
[f x] returns [Some y]. It returns [y]. If we exhaust the
@@ -331,8 +329,6 @@ val ( &^ ) : int64 -> int64 -> int64
val ( ~^ ) : int64 -> int64
(** Various int64 operators. *)
-external identity : 'a -> 'a = "%identity"
-
val roundup64 : int64 -> int64 -> int64
(** [roundup64 i a] returns [i] rounded up to the next multiple of [a]. *)
val div_roundup64 : int64 -> int64 -> int64
@@ -371,18 +367,6 @@ val unique : unit -> int
type ('a, 'b) maybe = Either of 'a | Or of 'b
(** Like the Haskell [Either] type. *)
-val protect : f:(unit -> 'a) -> finally:(unit -> unit) -> 'a
-(** Execute [~f] and afterwards execute [~finally].
-
- If [~f] throws an exception then [~finally] is run and the
- original exception from [~f] is re-raised.
-
- If [~finally] throws an exception, then the original exception
- is lost. (NB: Janestreet core {!Exn.protectx}, on which this
- function is modelled, doesn't throw away the exception in this
- case, but requires a lot more work by the caller. Perhaps we
- will change this in future.) *)
-
type 'a return = { return: 'b. 'a -> 'b } [@@unboxed]
val with_return : ('a return -> 'a) -> 'a
(** {v
diff --git a/common/mlstdutils/std_utils_tests.ml b/common/mlstdutils/std_utils_tests.ml
index abe842b..10046bd 100644
--- a/common/mlstdutils/std_utils_tests.ml
+++ b/common/mlstdutils/std_utils_tests.ml
@@ -40,7 +40,7 @@ let assert_raises exn fn =
)
let assert_equal_string =
- assert_equal ~printer:identity
+ assert_equal ~printer:Fun.id
let assert_equal_int =
assert_equal ~printer:(fun x -> string_of_int x)
let assert_equal_int64 =
diff --git a/common/mlutils/c_utils_unit_tests.ml b/common/mlutils/c_utils_unit_tests.ml
index 961dac5..50c7e44 100644
--- a/common/mlutils/c_utils_unit_tests.ml
+++ b/common/mlutils/c_utils_unit_tests.ml
@@ -42,7 +42,7 @@ let assert_raises exn fn =
(* Test drive_name function. *)
let () =
- let printer = identity in
+ let printer = Fun.id in
assert_equal ~printer "a" (drive_name 0);
assert_equal ~printer "z" (drive_name 25);
assert_equal ~printer "aa" (drive_name 26);
@@ -74,7 +74,7 @@ let () =
(* Test shell_unquote function. *)
let () =
- let printer = identity in
+ let printer = Fun.id in
assert_equal ~printer "a" (shell_unquote "a");
assert_equal ~printer "b" (shell_unquote "'b'");
assert_equal ~printer "c" (shell_unquote "\"c\"");
diff --git a/daemon/btrfs.ml b/daemon/btrfs.ml
index 3f9d8308a..35e0b1765 100644
--- a/daemon/btrfs.ml
+++ b/daemon/btrfs.ml
@@ -48,7 +48,7 @@ let rec with_mounted mountable f =
rmdir tmpdir
in
- protect ~finally ~f:(fun () -> mount_cmd tmpdir; f tmpdir)
+ Fun.protect ~finally (fun () -> mount_cmd tmpdir; f tmpdir)
in
match mountable.m_type with
@@ -124,4 +124,4 @@ let btrfs_subvolume_get_default mountable =
with_mounted mountable (
fun mp -> command "btrfs" ["subvolume"; "get-default"; mp]
) in
- sscanf out "ID %Ld" identity
+ sscanf out "ID %Ld" Fun.id
diff --git a/daemon/cryptsetup.ml b/daemon/cryptsetup.ml
index ac2cf066e..9c0149b48 100644
--- a/daemon/cryptsetup.ml
+++ b/daemon/cryptsetup.ml
@@ -56,7 +56,7 @@ let cryptsetup_open ?(readonly = false) ?crypttype ?cipher device key mapname =
Option.iter (fun s -> List.push_back_list args ["--cipher"; s]) cipher;
(* Make sure we always remove the temporary file. *)
- protect ~f:(fun () -> ignore (command "cryptsetup" !args))
+ Fun.protect (fun () -> ignore (command "cryptsetup" !args))
~finally:(fun () -> unlink keyfile);
udev_settle ()
diff --git a/daemon/filearch.ml b/daemon/filearch.ml
index 6eed7d396..f45392b5f 100644
--- a/daemon/filearch.ml
+++ b/daemon/filearch.ml
@@ -116,7 +116,7 @@ and cpio_arch magic orig_path path =
let tmpdir = Mkdtemp.temp_dir "filearch" in
let finally () = ignore (Sys.command (sprintf "rm -rf %s" (quote tmpdir))) in
- protect ~finally ~f:(
+ Fun.protect ~finally (
fun () ->
(* Construct a command to extract named binaries from the initrd file. *)
let cmd =
diff --git a/daemon/inspect_utils.ml b/daemon/inspect_utils.ml
index 1aa762050..5ef8bfa25 100644
--- a/daemon/inspect_utils.ml
+++ b/daemon/inspect_utils.ml
@@ -57,8 +57,8 @@ let rec with_augeas ?name configfiles f =
Augeas.create (Sysroot.sysroot ()) None
[Augeas.AugSaveNoop; Augeas.AugNoLoad] in
- protect
- ~f:(fun () ->
+ Fun.protect
+ (fun () ->
(* Tell Augeas to only load configfiles and no other files. This
* prevents a rogue guest from performing a denial of service attack
* by having large, over-complicated configuration files which are
@@ -179,4 +179,4 @@ let with_hive hive_filename f =
| Some f -> f :: flags in
let flags = if verbose () then Hivex.OPEN_VERBOSE :: flags else flags in
let h = Hivex.open_file hive_filename flags in
- protect ~f:(fun () -> f h (Hivex.root h)) ~finally:(fun () -> Hivex.close h)
+ Fun.protect (fun () -> f h (Hivex.root h)) ~finally:(fun () -> Hivex.close h)
diff --git a/daemon/sfdisk.ml b/daemon/sfdisk.ml
index c694c328c..3265d1e83 100644
--- a/daemon/sfdisk.ml
+++ b/daemon/sfdisk.ml
@@ -35,7 +35,7 @@ let part_get_mbr_id device partnum =
udev_settle ();
(* It's printed in hex, possibly with a leading space. *)
- sscanf out " %x" identity
+ sscanf out " %x" Fun.id
let part_get_gpt_type device partnum =
if partnum <= 0 then
--
2.47.1

View File

@ -1,4 +1,4 @@
From b3c5978cdf583fba4dfc36f5ebc4d7248b5b0bfb Mon Sep 17 00:00:00 2001
From 33529af903969a9957214e39bc6b1c78f02a7b98 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 13 May 2025 17:28:25 +0100
Subject: [PATCH] RHEL: appliance/init: Run depmod -a to rebuild kernel module

View File

@ -1,25 +0,0 @@
From 464b8915e9e9b871d64446b5dfc8a806f3d87883 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 11 May 2025 15:01:06 +0100
Subject: [PATCH] ocaml-dep.sh.in: Remove mlgettext subdirectory
Libguestfs does not use ocaml-gettext at all.
---
ocaml-dep.sh.in | 1 -
1 file changed, 1 deletion(-)
diff --git a/ocaml-dep.sh.in b/ocaml-dep.sh.in
index a9c093bb0..8cdfd76ba 100755
--- a/ocaml-dep.sh.in
+++ b/ocaml-dep.sh.in
@@ -33,7 +33,6 @@ set -e
# directories must have unique names (eg. not Utils) else
# dependencies don't get built right.
include_dirs="
-common/mlgettext
common/mlpcre
common/mlstdutils
common/mlutils
--
2.47.1

View File

@ -1,531 +0,0 @@
From f9edfc9a18eec134a38872166bb2e3dac51a8d18 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 11 May 2025 21:21:56 +0100
Subject: [PATCH] Update common submodule
This pulls in the commits below, requiring us to replace all uses of
String.is_prefix and String.is_suffix.
Mostly done with Perl like this, and carefully checked by hand
afterwards since this doesn't get everything right:
$ perl -pi.bak -e 's/String.is_prefix ([^[:space:]\)]+) ([^[:space:]\)]+)/String.starts_with \2 \1/g' -- `git ls-files`
Richard W.M. Jones (3):
mlstdutils: Fix comment that still referred to the old function names
mldrivers: Link to gettext-stub if ocaml-gettext is enabled
mlstdutils: Rename String.is_prefix -> starts_with, is_suffix -> ends_with
---
common | 2 +-
daemon/cryptsetup.ml | 2 +-
daemon/devsparts.ml | 18 +++++++++---------
daemon/findfs.ml | 4 ++--
daemon/inspect_fs_unix.ml | 10 +++++-----
daemon/inspect_fs_unix_fstab.ml | 30 +++++++++++++++---------------
daemon/inspect_fs_windows.ml | 8 ++++----
daemon/ldm.ml | 2 +-
daemon/listfs.ml | 8 ++++----
daemon/md.ml | 2 +-
daemon/mount_utils.ml | 4 ++--
daemon/sfdisk.ml | 8 ++++----
daemon/utils.ml | 6 +++---
generator/daemon.ml | 2 +-
14 files changed, 53 insertions(+), 53 deletions(-)
Submodule common 3a05f1a7a..d4a81e9dd:
diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml
index 39b5bc9..4850a55 100644
--- a/common/mlstdutils/std_utils.ml
+++ b/common/mlstdutils/std_utils.ml
@@ -214,11 +214,11 @@ module String = struct
Bytes.unsafe_set b 0 (Char.uppercase_ascii (Bytes.unsafe_get b 0));
Bytes.to_string b
- let is_prefix str prefix =
+ let starts_with ~prefix str =
let n = length prefix in
length str >= n && sub str 0 n = prefix
- let is_suffix str suffix =
+ let ends_with ~suffix str =
let sufflen = length suffix
and len = length str in
len >= sufflen && sub str (len - sufflen) sufflen = suffix
@@ -824,7 +824,7 @@ let unix_like = function
| "hurd"
| "linux"
| "minix" -> true
- | typ when String.is_suffix typ "bsd" -> true
+ | typ when String.ends_with "bsd" typ -> true
| _ -> false
(** Return the last part of a string, after the specified separator. *)
diff --git a/common/mlstdutils/std_utils.mli b/common/mlstdutils/std_utils.mli
index 04c780a..fe6bf1a 100644
--- a/common/mlstdutils/std_utils.mli
+++ b/common/mlstdutils/std_utils.mli
@@ -71,7 +71,7 @@ module List : sig
[f] returns false.
For any list [xs] and function [f],
- [xs = takewhile f xs @ dropwhile f xs] *)
+ [xs = take_while f xs @ drop_while f xs] *)
val take : int -> 'a list -> 'a list
(** [take n xs] returns the first [n] elements of [xs]. If [xs] is
@@ -236,10 +236,10 @@ module String : sig
val uppercase_ascii : string -> string
val capitalize_ascii : string -> string
- val is_prefix : string -> string -> bool
- (** [is_prefix str prefix] returns true if [prefix] is a prefix of [str]. *)
- val is_suffix : string -> string -> bool
- (** [is_suffix str suffix] returns true if [suffix] is a suffix of [str]. *)
+ val starts_with : prefix:string -> string -> bool
+ (** Return true if [prefix] is a prefix of [str]. *)
+ val ends_with : suffix:string -> string -> bool
+ (** Return true if [suffix] is a suffix of [str]. *)
val find : string -> string -> int
(** [find str sub] searches for [sub] as a substring of [str]. If
found it returns the index. If not found, it returns [-1]. *)
diff --git a/common/mlstdutils/std_utils_tests.ml b/common/mlstdutils/std_utils_tests.ml
index 10046bd..133c672 100644
--- a/common/mlstdutils/std_utils_tests.ml
+++ b/common/mlstdutils/std_utils_tests.ml
@@ -87,21 +87,23 @@ let () =
assert_bool "Char.mem" (not (Char.mem 'd' "abc"));
assert_bool "Char.mem" (not (Char.mem 'a' ""))
-(* Test Std_utils.String.is_prefix. *)
+(* Test Std_utils.String.starts_with. *)
let () =
- assert_bool "String.is_prefix,," (String.is_prefix "" "");
- assert_bool "String.is_prefix,foo," (String.is_prefix "foo" "");
- assert_bool "String.is_prefix,foo,foo" (String.is_prefix "foo" "foo");
- assert_bool "String.is_prefix,foo123,foo" (String.is_prefix "foo123" "foo");
- assert_bool "not (String.is_prefix,,foo" (not (String.is_prefix "" "foo"))
+ assert_bool "String.starts_with,," (String.starts_with "" "");
+ assert_bool "String.starts_with,foo," (String.starts_with "" "foo");
+ assert_bool "String.starts_with,foo,foo" (String.starts_with "foo" "foo");
+ assert_bool "String.starts_with,foo123,foo"
+ (String.starts_with "foo" "foo123");
+ assert_bool "not (String.starts_with,,foo"
+ (not (String.starts_with "foo" ""))
-(* Test Std_utils.String.is_suffix. *)
+(* Test Std_utils.String.ends_with. *)
let () =
- assert_bool "String.is_suffix,," (String.is_suffix "" "");
- assert_bool "String.is_suffix,foo," (String.is_suffix "foo" "");
- assert_bool "String.is_suffix,foo,foo" (String.is_suffix "foo" "foo");
- assert_bool "String.is_suffix,123foo,foo" (String.is_suffix "123foo" "foo");
- assert_bool "not String.is_suffix,,foo" (not (String.is_suffix "" "foo"))
+ assert_bool "String.ends_with,," (String.ends_with "" "");
+ assert_bool "String.ends_with,foo," (String.ends_with "" "foo");
+ assert_bool "String.ends_with,foo,foo" (String.ends_with "foo" "foo");
+ assert_bool "String.ends_with,123foo,foo" (String.ends_with "foo" "123foo");
+ assert_bool "not String.ends_with,,foo" (not (String.ends_with "foo" ""))
(* Test Std_utils.String.find. *)
let () =
diff --git a/daemon/cryptsetup.ml b/daemon/cryptsetup.ml
index 9c0149b48..6f677aef0 100644
--- a/daemon/cryptsetup.ml
+++ b/daemon/cryptsetup.ml
@@ -63,7 +63,7 @@ let cryptsetup_open ?(readonly = false) ?crypttype ?cipher device key mapname =
let cryptsetup_close device =
(* Must be /dev/mapper/... *)
- if not (String.is_prefix device "/dev/mapper/") then
+ if not (String.starts_with "/dev/mapper/" device) then
failwithf "%s: you must call this on the /dev/mapper device created by cryptsetup-open" device;
let mapname = String.sub device 12 (String.length device - 12) in
diff --git a/daemon/devsparts.ml b/daemon/devsparts.ml
index 639e163d4..6b45ebc8e 100644
--- a/daemon/devsparts.ml
+++ b/daemon/devsparts.ml
@@ -38,18 +38,18 @@ let map_block_devices f =
fun file ->
let dev = Unix_utils.Realpath.realpath (sprintf "%s/%s" path file) in
(* Ignore non-/dev devices, and return without /dev/ prefix. *)
- if String.is_prefix dev "/dev/" then
+ if String.starts_with "/dev/" dev then
Some (String.sub dev 5 (String.length dev - 5))
else
None
) devs in
let devs = List.filter (
fun dev ->
- String.is_prefix dev "sd" ||
- String.is_prefix dev "hd" ||
- String.is_prefix dev "ubd" ||
- String.is_prefix dev "vd" ||
- String.is_prefix dev "sr"
+ String.starts_with "sd" dev ||
+ String.starts_with "hd" dev ||
+ String.starts_with "ubd" dev ||
+ String.starts_with "vd" dev ||
+ String.starts_with "sr" dev
) devs in
(* Ignore the root device. *)
@@ -81,7 +81,7 @@ let map_md_devices f =
let devs = Array.to_list devs in
let devs = List.filter (
fun dev ->
- String.is_prefix dev "md" &&
+ String.starts_with "md" dev &&
String.length dev >= 3 && Char.isdigit dev.[2]
) devs in
List.map f devs
@@ -111,7 +111,7 @@ and add_partitions dev =
(* Look in /sys/block/<device>/ for entries starting with
* <device>, eg. /sys/block/sda/sda1.
*)
- let parts = List.filter (fun part -> String.is_prefix part dev) parts in
+ let parts = List.filter (fun part -> String.starts_with dev part) parts in
let parts = List.map ((^) "/dev/") parts in
sort_device_names parts
@@ -133,7 +133,7 @@ let is_whole_device device =
(* A 'whole' block device will have a symlink to the device in its
* /sys/block directory
*)
- assert (String.is_prefix device "/dev/");
+ assert (String.starts_with "/dev/" device);
let device = String.sub device 5 (String.length device - 5) in
let devpath = sprintf "/sys/block/%s/device" device in
diff --git a/daemon/findfs.ml b/daemon/findfs.ml
index d5752869c..087aad27f 100644
--- a/daemon/findfs.ml
+++ b/daemon/findfs.ml
@@ -46,8 +46,8 @@ and findfs tag str =
(* Trim trailing \n if present. *)
let out = String.trim out in
- if String.is_prefix out "/dev/mapper/" ||
- String.is_prefix out "/dev/dm-" then (
+ if String.starts_with "/dev/mapper/" out ||
+ String.starts_with "/dev/dm-" out then (
match Lvm_utils.lv_canonical out with
| None ->
(* Ignore the case where 'out' doesn't appear to be an LV.
diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml
index e27863e86..952a7cd15 100644
--- a/daemon/inspect_fs_unix.ml
+++ b/daemon/inspect_fs_unix.ml
@@ -163,7 +163,7 @@ and distro_of_os_release_id = function
| "opencloudos" -> Some DISTRO_OPENCLOUDOS
| "tencentos" -> Some DISTRO_TENCENTOS
| "opensuse" -> Some DISTRO_OPENSUSE
- | s when String.is_prefix s "opensuse-" -> Some DISTRO_OPENSUSE
+ | s when String.starts_with "opensuse-" s -> Some DISTRO_OPENSUSE
| "pardus" -> Some DISTRO_PARDUS
| "pld" -> Some DISTRO_PLD_LINUX
| "rhel" -> Some DISTRO_RHEL
@@ -593,7 +593,7 @@ and check_hostname_from_file filename =
let hostname = Chroot.f chroot read_small_file filename in
- let keep_line line = line <> "" && not (String.is_prefix line "#") in
+ let keep_line line = line <> "" && not (String.starts_with "#" line) in
let lines = Option.map (List.filter keep_line) hostname in
match lines with
| None | Some [] -> None
@@ -699,11 +699,11 @@ and check_hostname_freebsd () =
let rec loop = function
| [] ->
raise Not_found
- | line :: _ when String.is_prefix line "hostname=\"" ||
- String.is_prefix line "hostname='" ->
+ | line :: _ when String.starts_with "hostname=\"" line ||
+ String.starts_with "hostname='" line ->
let len = String.length line - 10 - 1 in
String.sub line 10 len
- | line :: _ when String.is_prefix line "hostname=" ->
+ | line :: _ when String.starts_with "hostname=" line ->
let len = String.length line - 9 in
String.sub line 9 len
| _ :: lines ->
diff --git a/daemon/inspect_fs_unix_fstab.ml b/daemon/inspect_fs_unix_fstab.ml
index 395a1c794..1ec7cb1c1 100644
--- a/daemon/inspect_fs_unix_fstab.ml
+++ b/daemon/inspect_fs_unix_fstab.ml
@@ -82,13 +82,13 @@ and check_fstab_entry md_map root_mountable os_type aug entry =
* /dev/iso9660/FREEBSD_INSTALL can be found in FreeBSD's
* installation discs.
*)
- if (String.is_prefix spec "/dev/fd" &&
+ if (String.starts_with "/dev/fd" spec &&
String.length spec >= 8 && Char.isdigit spec.[7]) ||
- (String.is_prefix spec "/dev/cd" &&
+ (String.starts_with "/dev/cd" spec &&
String.length spec >= 8 && Char.isdigit spec.[7]) ||
spec = "/dev/floppy" ||
spec = "/dev/cdrom" ||
- String.is_prefix spec "/dev/iso9660/" then
+ String.starts_with "/dev/iso9660/" spec then
return None;
let mp = aug_get_noerrors aug (entry ^ "/file") in
@@ -103,20 +103,20 @@ and check_fstab_entry md_map root_mountable os_type aug entry =
if verbose () then eprintf "check_fstab_entry: mp=%s\n%!" mp;
(* Ignore certain mountpoints. *)
- if String.is_prefix mp "/dev/" ||
+ if String.starts_with "/dev/" mp ||
mp = "/dev" ||
- String.is_prefix mp "/media/" ||
- String.is_prefix mp "/proc/" ||
+ String.starts_with "/media/" mp ||
+ String.starts_with "/proc/" mp ||
mp = "/proc" ||
- String.is_prefix mp "/selinux/" ||
+ String.starts_with "/selinux/" mp ||
mp = "/selinux" ||
- String.is_prefix mp "/sys/" ||
+ String.starts_with "/sys/" mp ||
mp = "/sys" then
return None;
let mountable =
(* Resolve UUID= and LABEL= to the actual device. *)
- if String.is_prefix spec "UUID=" then (
+ if String.starts_with "UUID=" spec then (
let uuid = String.sub spec 5 (String.length spec - 5) in
let uuid = shell_unquote uuid in
(* Just ignore the device if the UUID cannot be resolved. *)
@@ -125,7 +125,7 @@ and check_fstab_entry md_map root_mountable os_type aug entry =
with
Failure _ -> return None
)
- else if String.is_prefix spec "LABEL=" then (
+ else if String.starts_with "LABEL=" spec then (
let label = String.sub spec 6 (String.length spec - 6) in
let label = shell_unquote label in
(* Just ignore the device if the label cannot be resolved. *)
@@ -135,7 +135,7 @@ and check_fstab_entry md_map root_mountable os_type aug entry =
Failure _ -> return None
)
(* EFI partition UUIDs and labels. *)
- else if String.is_prefix spec "PARTUUID=" then (
+ else if String.starts_with "PARTUUID=" spec then (
let uuid = String.sub spec 9 (String.length spec - 9) in
let uuid = shell_unquote uuid in
(* Just ignore the device if the UUID cannot be resolved. *)
@@ -144,7 +144,7 @@ and check_fstab_entry md_map root_mountable os_type aug entry =
with
Failure _ -> return None
)
- else if String.is_prefix spec "PARTLABEL=" then (
+ else if String.starts_with "PARTLABEL=" spec then (
let label = String.sub spec 10 (String.length spec - 10) in
let label = shell_unquote label in
(* Just ignore the device if the label cannot be resolved. *)
@@ -161,7 +161,7 @@ and check_fstab_entry md_map root_mountable os_type aug entry =
else if spec = "/dev/root" || (is_bsd && mp = "/") then
root_mountable
(* Resolve guest block device names. *)
- else if String.is_prefix spec "/dev/" then
+ else if String.starts_with "/dev/" spec then
resolve_fstab_device spec md_map os_type
(* In OpenBSD's fstab you can specify partitions
* on a disk by appending a period and a partition
@@ -347,7 +347,7 @@ and resolve_fstab_device spec md_map os_type =
eprintf "resolve_fstab_device: %s matched %s\n%!" spec what
in
- if String.is_prefix spec "/dev/mapper" then (
+ if String.starts_with "/dev/mapper" spec then (
debug_matching "/dev/mapper";
(* LVM2 does some strange munging on /dev/mapper paths for VGs and
* LVs which contain '-' character:
@@ -398,7 +398,7 @@ and resolve_fstab_device spec md_map os_type =
)
(* Ubuntu 22+ uses /dev/disk/by-uuid/ followed by a UUID. *)
- else if String.is_prefix spec "/dev/disk/by-uuid/" then (
+ else if String.starts_with "/dev/disk/by-uuid/" spec then (
debug_matching "diskbyuuid";
let uuid = String.sub spec 18 (String.length spec - 18) in
try
diff --git a/daemon/inspect_fs_windows.ml b/daemon/inspect_fs_windows.ml
index 8bcda5eb8..dbaf4c362 100644
--- a/daemon/inspect_fs_windows.ml
+++ b/daemon/inspect_fs_windows.ml
@@ -94,11 +94,11 @@ and get_windows_systemroot_from_boot_ini boot_ini_path =
*)
let rec loop = function
| [] -> None
- | str :: rest when String.is_prefix str "[operating systems]" ->
+ | str :: rest when String.starts_with "[operating systems]" str ->
let rec loop2 = function
| [] -> []
- | str :: rest when String.is_prefix str "multi(" ||
- String.is_prefix str "scsi(" ->
+ | str :: rest when String.starts_with "multi(" str ||
+ String.starts_with "scsi(" str ->
str :: loop2 rest
| _ -> []
in
@@ -340,7 +340,7 @@ and get_drive_mappings h root data =
let device =
if typ = Hivex.REG_BINARY then (
if String.length blob >= 24 &&
- String.is_prefix blob "DMIO:ID:" (* GPT *) then
+ String.starts_with "DMIO:ID:" blob (* GPT *) then
map_registry_disk_blob_gpt (Lazy.force partitions) blob
else if String.length blob = 12 then
map_registry_disk_blob_mbr (Lazy.force devices) blob
diff --git a/daemon/ldm.ml b/daemon/ldm.ml
index 0aa9bc9de..2710f71c2 100644
--- a/daemon/ldm.ml
+++ b/daemon/ldm.ml
@@ -38,7 +38,7 @@ and list prefix =
let dir = Sys.readdir "/dev/mapper" in
let dir = Array.to_list dir in
let dir =
- List.filter (fun d -> String.is_prefix d prefix) dir in
+ List.filter (fun d -> String.starts_with prefix d) dir in
let dir = List.map ((^) "/dev/mapper/") dir in
List.sort compare dir
)
diff --git a/daemon/listfs.ml b/daemon/listfs.ml
index dfc5ad5a5..0139e927d 100644
--- a/daemon/listfs.ml
+++ b/daemon/listfs.ml
@@ -73,18 +73,18 @@ let rec list_filesystems () =
*)
and is_not_partitioned_device device =
let device =
- if String.is_prefix device "/dev/mapper/" then
+ if String.starts_with "/dev/mapper/" device then
Unix_utils.Realpath.realpath device
else
device in
- assert (String.is_prefix device "/dev/");
+ assert (String.starts_with "/dev/" device);
let dev_name = String.sub device 5 (String.length device - 5) in
let dev_dir = "/sys/block/" ^ dev_name in
(* Open the device's directory under /sys/block/<dev_name> and
* look for entries starting with <dev_name>, eg. /sys/block/sda/sda1
*)
- let is_device_partition file = String.is_prefix file dev_name in
+ let is_device_partition file = String.starts_with dev_name file in
let files = Array.to_list (Sys.readdir dev_dir) in
let has_partition = List.exists is_device_partition files in
@@ -157,7 +157,7 @@ and check_with_vfs_type ret device =
* for things which are members of some RAID or LVM set, most
* importantly "LVM2_member" which is a PV.
*)
- else if String.is_suffix vfs_type "_member" then
+ else if String.ends_with "_member" vfs_type then
()
(* Ignore encrypted partitions. These are also containers, as above. *)
diff --git a/daemon/md.ml b/daemon/md.ml
index b4ba3b442..f2679a02d 100644
--- a/daemon/md.ml
+++ b/daemon/md.ml
@@ -68,7 +68,7 @@ let md_detail md =
* remainder to lower case.
*)
let key =
- if String.is_prefix key "MD_" then
+ if String.starts_with "MD_" key then
String.sub key 3 (String.length key - 3)
else
key in
diff --git a/daemon/mount_utils.ml b/daemon/mount_utils.ml
index 57d3eb6cf..dab34d037 100644
--- a/daemon/mount_utils.ml
+++ b/daemon/mount_utils.ml
@@ -61,8 +61,8 @@ let rec umount_all () =
let mp = proc_unmangle_path mp in
(* Allow a mount directory like "/sysroot" or "/sysroot/..." *)
- if (sysroot_len > 0 && String.is_prefix mp sysroot) ||
- (String.is_prefix mp sysroot &&
+ if (sysroot_len > 0 && String.starts_with sysroot mp) ||
+ (String.starts_with sysroot mp &&
String.length mp > sysroot_len &&
mp.[sysroot_len] = '/') then
List.push_front mp mps
diff --git a/daemon/sfdisk.ml b/daemon/sfdisk.ml
index 3265d1e83..bdba9dc17 100644
--- a/daemon/sfdisk.ml
+++ b/daemon/sfdisk.ml
@@ -142,22 +142,22 @@ let part_get_gpt_attributes device partnum =
let out = String.sub out 1 (len-1) in
loop out acc
)
- else if String.is_prefix out "RequiredPartition" then (
+ else if String.starts_with "RequiredPartition" out then (
let acc = 0 :: acc in
let out = String.sub out 17 (len-17) in
loop out acc
)
- else if String.is_prefix out "NoBlockIOProtocol" then (
+ else if String.starts_with "NoBlockIOProtocol" out then (
let acc = 1 :: acc in
let out = String.sub out 17 (len-17) in
loop out acc
)
- else if String.is_prefix out "LegacyBIOSBootable" then (
+ else if String.starts_with "LegacyBIOSBootable" out then (
let acc = 2 :: acc in
let out = String.sub out 18 (len-18) in
loop out acc
)
- else if String.is_prefix out "GUID:" then (
+ else if String.starts_with "GUID:" out then (
let out = String.sub out 5 (len-5) in
loop out acc
)
diff --git a/daemon/utils.ml b/daemon/utils.ml
index 71d1cf25c..40584c9f1 100644
--- a/daemon/utils.ml
+++ b/daemon/utils.ml
@@ -85,11 +85,11 @@ let commandr ?(fold_stdout_on_stderr = false) prog args =
if verbose () then (
if stdout <> "" then (
eprintf "command: %s: stdout:\n%s%!" prog stdout;
- if not (String.is_suffix stdout "\n") then eprintf "\n%!"
+ if not (String.ends_with "\n" stdout) then eprintf "\n%!"
);
if stderr <> "" then (
eprintf "command: %s: stderr:\n%s%!" prog stderr;
- if not (String.is_suffix stderr "\n") then eprintf "\n%!"
+ if not (String.ends_with "\n" stderr) then eprintf "\n%!"
)
);
@@ -114,7 +114,7 @@ let command ?fold_stdout_on_stderr prog args =
let split_device_partition dev =
(* Skip /dev/ prefix if present. *)
let dev =
- if String.is_prefix dev "/dev/" then
+ if String.starts_with "/dev/" dev then
String.sub dev 5 (String.length dev - 5)
else dev in
diff --git a/generator/daemon.ml b/generator/daemon.ml
index da5593ce1..6221531d2 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -511,7 +511,7 @@ let rec generate_daemon_caml_interface modname () =
generate_header OCamlStyle GPLv2plus;
let is_ocaml_module_function = function
- | { impl = OCaml m } when String.is_prefix m (modname ^ ".") -> true
+ | { impl = OCaml m } when String.starts_with (modname ^ ".") m -> true
| { impl = OCaml _ } -> false
| { impl = C } -> false
in
--
2.47.1

View File

@ -1,57 +0,0 @@
From 1c2b94f09521698ac35fc282f7e03b8cedbf094b Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 13 May 2025 13:14:00 +0100
Subject: [PATCH] docs: Update release notes for 1.56
---
docs/guestfs-release-notes-1.56.pod | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/docs/guestfs-release-notes-1.56.pod b/docs/guestfs-release-notes-1.56.pod
index 12380df0d..bab14c139 100644
--- a/docs/guestfs-release-notes-1.56.pod
+++ b/docs/guestfs-release-notes-1.56.pod
@@ -18,6 +18,8 @@ Add support for TencentOS (Denise Cheng).
Inspection of Ubuntu 22+ guests that use a split F</usr> configuration
now works properly (thanks Jaroslav Spanko, Daniel Berrange).
+Inspecting guests that have duplicated root mountpoints now works.
+
=head2 API
New C<command_out> and C<sh_out> APIs which allow you to capture
@@ -66,6 +68,9 @@ dependencies (thanks Mohamed Akram).
When using C<./configure --disable-daemon> we no longer require augeas
and hivex (thanks Mohamed Akram).
+C<zfs-fuse> support has been dropped. The project is unmaintained
+upstream.
+
=head2 Internals
The tests were modified to use a set of common functions and remove
@@ -86,6 +91,9 @@ Some deprecated autoconf macros are no longer used.
We no longer emit a false warning about C<BLKDISCARD> when creating a
block device.
+Some internal OCaml List and String functions that we used have been
+replaced by ones from the OCaml stdlib, reducing code maintenance.
+
=head2 Bugs fixed
=begin comment
@@ -116,6 +124,11 @@ fstrim on a RHEL 7.2-created XFS filesystem does not trim as much as expected
Run fstrim twice to work around incorrect fstrim behaviour in RHEL 9 kernel
+=item L<https://issues.redhat.com/browse/RHEL-90168>
+
+virt-v2v fails with mount exited with status 32: mount: /sysroot:
+/dev/sda2 already mounted on /sysroot. [rhel-9.7]
+
=item L<https://github.com/libguestfs/libguestfs/issues/155>
1.54.0: gdisk/test-expand-gpt.pl fails
--
2.47.1

View File

@ -41,7 +41,7 @@ ExcludeArch: %{ix86}
Summary: Access and modify virtual machine disk images
Name: libguestfs
Epoch: 1
Version: 1.55.11
Version: 1.55.12
Release: 1%{?dist}
License: LGPL-2.1-or-later
@ -80,15 +80,10 @@ Source8: copy-patches.sh
# https://github.com/libguestfs/libguestfs/commits/rhel-10.1
# Patches.
Patch0001: 0001-appliance-Remove-zfs-fuse.patch
Patch0002: 0002-Update-common-submodule.patch
Patch0003: 0003-Update-common-submodule.patch
Patch0004: 0004-ocaml-dep.sh.in-Remove-mlgettext-subdirectory.patch
Patch0005: 0005-Update-common-submodule.patch
Patch0006: 0006-docs-Update-release-notes-for-1.56.patch
Patch0007: 0007-RHEL-Disable-unsupported-remote-drive-protocols-RHBZ.patch
Patch0008: 0008-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
Patch0009: 0009-RHEL-appliance-init-Run-depmod-a-to-rebuild-kernel-m.patch
Patch0001: 0001-m4-Add-junk-required-to-make-AM_GNU_GETTEXT-work.patch
Patch0002: 0002-RHEL-Disable-unsupported-remote-drive-protocols-RHBZ.patch
Patch0003: 0003-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
Patch0004: 0004-RHEL-appliance-init-Run-depmod-a-to-rebuild-kernel-m.patch
BuildRequires: autoconf, automake, libtool, gettext-devel
@ -1076,8 +1071,8 @@ rm ocaml/html/.gitignore
%changelog
* Tue May 13 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.55.11-1
- Rebase to libguestfs 1.55.11
* Tue May 13 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.55.12-1
- Rebase to libguestfs 1.55.12
resolves: RHEL-81733
- Include host kernel information in libguestfs debugging output
resolves: RHEL-83026
@ -1088,6 +1083,8 @@ rm ocaml/html/.gitignore
- Fix gating test
- Fix inspection with duplicated root mountpoint
resolves: RHEL-90170
- Add btrfs-scrub-full API
resolves: RHEL-91936
* Tue Nov 26 2024 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-5
- Rebase to libguestfs 1.54.0

View File

@ -1,2 +1,2 @@
SHA512 (libguestfs-1.55.11.tar.gz) = 3c2bf753ad1bf9dd1809f50e9e39dd154e97a33de7848b9d08feac23f543cc1100b928f1533a6ea4882125202793694c2917ea5561ccbd0c72154a7313cf9050
SHA512 (libguestfs-1.55.11.tar.gz.sig) = 42764c07832f02349f8d28482aa2aefd394b66b940d84765623491879b8960b22f567c51565f32dab204cc83aa8fa26b46fd181c10a43da05db29d2ee704deb0
SHA512 (libguestfs-1.55.12.tar.gz) = 87f7c209e5b5787c212746a1fb434342b75b9dd80dd4fc01b53877150f7d194d3d856b0acac0606236029601b595e2c0db8af582b00364cf162e91394c74be10
SHA512 (libguestfs-1.55.12.tar.gz.sig) = 177730330cf94cf2a3d17fee3427482b2206d824f24928d4a5fa4bf0ef3248f319d648a17fa337f23af7b9c39b62b86eab6d0465454efda7b3c6e5a306a74c99