mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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
This commit is contained in:
2
common
2
common
Submodule common updated: 3a05f1a7a0...d4a81e9dd2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 ->
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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. *)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user