search for: is_prefix

Displaying 20 results from an estimated 162 matches for "is_prefix".

2017 Nov 21
2
[PATCH REPOST 1/2] common/mlstdutils: Add return statement.
No change, just reposting without the "for discussion" tag. I think we should allow this as it seems like a nice coding style for a limited subset of imperative-style code. Rich.
2017 Nov 05
2
[PATCH 0/2] (mainly for discussion) Add ‘return’ statement.
When rewriting the heavily imperative original inspection code, I longed for a ‘return’ statement so I could keep the new code as close as possible to the original. OCaml of course does not have such a statement, but it's relatively simply to implement it in the language. The first patch does so, and the second patch rewrites a sample of the inspection code to use it. Rich.
2020 Sep 22
2
[v2v PATCH 1/2] linux: split kernel packages filtering from processing
...uestfs) inspect family bootloader = PCRE.compile "^initrd.img-.*$" else PCRE.compile "^initr(?:d|amfs)-.*(?:\\.img)?$" in + let kernel_pkgs = List.filter ( + fun { G.app2_name = name } -> + name = "kernel" + || String.is_prefix name "kernel-" + || String.is_prefix name "linux-image-" + ) inspect.i_apps in + if verbose () then ( + let names = List.map (fun { G.app2_name = name } -> name) kernel_pkgs in + eprintf "candidate kernel packages in this guest: %s%!\n" +...
2016 Aug 11
2
[PATCH v2] v2v: linux: accept 'sr' devices in fstab
...Golembiovský <tgolembi@redhat.com> Do not print warning for 'sr' devices when converting fstab. Not all systems create the /dev/cdrom symlink for SCSI CD-ROM devices. Moreover, on systems with multiple CD-ROMs, having entries for /dev/sr* devices may be inevitable. RWMJ: Use String.is_prefix instead of String.find, to more accurately match on the device name. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> Signed-off-by: Richard W.M. Jones <rjones@redhat.com> --- v2v/convert_linux.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/v2v/con...
2015 Oct 06
10
[PATCH 0/5] mllib: Hide bad String functions and miscellaneous refactoring.
Hide/prevent the use of bad string functions like String.lowercase. These are replaced by safe functions that won't break UTF-8 strings. Other miscellaneous refactoring. Rich.
2015 Oct 06
0
[PATCH 5/5] mllib: Replace various ad hoc string_* functions with String.*
This is just a straight refactoring. Various ad hoc string_* functions that appeared in Common_utils have been renamed and placed in the String.* namespace. The old vs "new" functions are: string_prefix -> String.is_prefix string_suffix -> String.is_suffix string_find -> String.find replace_str -> String.replace string_nsplit -> String.nsplit string_split -> String.split string_lines_split -> String.lines_split string_random8 -> String.random8 --- builder/checksums.ml...
2018 May 22
1
[PATCH v2] v2v: linux: fix kernel detection when split in different packages
...else ( - (* Which of these is the kernel itself? *) + (* Which of these is the kernel itself? Also, make sure to check + * it exists by stat'ing it. + *) let vmlinuz = List.find ( fun filename -> String.is_prefix filename "/boot/vmlinuz-" ) files in - (* Which of these is the modpath? *) - let modpath = List.find ( - fun filename -> - String.length filename >= 14 && - String.is_prefix filename &quot...
2018 Aug 09
2
[PATCH] v2v: parse_libvirt_xml: handle srN CDROM devices (RHBZ#1612785)
...2v/parse_libvirt_xml.ml +++ b/v2v/parse_libvirt_xml.ml @@ -396,7 +396,15 @@ let parse_libvirt_xml ?conn xml = else loop rest in - loop ["hd"; "sd"; "vd"; "xvd"; "fd"] in + if String.is_prefix dev "sr" then ( + let name = String.sub dev 2 (String.length dev - 2) in + try Some (int_of_string name) + with Failure _ -> + warning (f_"could not parse device name ‘%s’ from the source libvirt XML") dev; + Non...
2016 Apr 21
1
[PATCH] dib: Rewrite match statement as ordinary if statement.
...+++ b/dib/dib.ml @@ -781,9 +781,8 @@ let main () = ) @ mkfs_options @ [ "-t"; cmdline.fs_type; blockdev ] in ignore (g#debug "sh" (Array.of_list ([ "mkfs" ] @ mkfs_options))); g#set_label blockdev root_label; - (match cmdline.fs_type with - | x when String.is_prefix x "ext" -> g#set_uuid blockdev rootfs_uuid - | _ -> ()); + if String.is_prefix cmdline.fs_type "ext" then + g#set_uuid blockdev rootfs_uuid; g#mount blockdev "/"; g#mkmountpoint "/tmp"; mount_aux (); -- 2.7.4
2018 Jul 27
1
[PATCH] daemon: inspect: ignore fstab devs that cannot be resolved (RHBZ#1608131)
...ons(-) diff --git a/daemon/inspect_fs_unix_fstab.ml b/daemon/inspect_fs_unix_fstab.ml index edb797e3f..170440d2c 100644 --- a/daemon/inspect_fs_unix_fstab.ml +++ b/daemon/inspect_fs_unix_fstab.ml @@ -115,12 +115,20 @@ and check_fstab_entry md_map root_mountable os_type aug entry = if String.is_prefix spec "UUID=" then ( let uuid = String.sub spec 5 (String.length spec - 5) in let uuid = shell_unquote uuid in - Mountable.of_device (Findfs.findfs_uuid uuid) + (* Just ignore the device if the UUID cannot be resolved. *) + try + Mountable.of...
2017 Jul 14
0
[PATCH 05/27] daemon: Reimplement several devsparts APIs in OCaml.
...Street, Fifth Floor, Boston, MA 02110-1301 USA. + *) + +open Printf +open Unix + +open Std_utils + +open Utils + +let map_block_devices ~return_md f = + let devs = Sys.readdir "/sys/block" in + let devs = Array.to_list 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" || + (return_md && String.is_prefix dev "md" && + String...
2016 Aug 26
0
[PATCH v2 6/7] v2v: linux: check the kernel package name for Debian
...6f96073..464ad49 100644 --- a/v2v/convert_linux.ml +++ b/v2v/convert_linux.ml @@ -115,7 +115,8 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps = filter_map ( function | { G.app2_name = name } as app - when name = "kernel" || String.is_prefix name "kernel-" -> + when name = "kernel" || String.is_prefix name "kernel-" + || String.is_prefix name "linux-image-" -> (try (* For each kernel, list the files directly owned by the kernel. *) let...
2017 Feb 28
1
[PATCH] sysprep: Remove DHCP_HOSTNAME= from ifcfg-* files (RHBZ#1427529).
...-*" in Array.iter ( fun filename -> - (* Replace HOSTNAME=... entry. *) + (* Remove HOSTNAME=... and DHCP_HOSTNAME=... entries. *) let lines = Array.to_list (g#read_lines filename) in let lines = List.filter ( - fun line -> not (String.is_prefix line "HOSTNAME=") + fun line -> + not (String.is_prefix line "HOSTNAME=") && + not (String.is_prefix line "DHCP_HOSTNAME=") ) lines in let file = String.concat "\n" lines ^ "\n" in...
2018 Jan 22
0
[RFC PATCH v1 2/3] daemon: devsparts: add is_partitioned_device function
...ml b/daemon/devsparts.ml index 54108bb..60ac11a 100644 --- a/daemon/devsparts.ml +++ b/daemon/devsparts.ml @@ -71,6 +71,20 @@ let list_devices () = map_block_devices ~return_md:false ((^) "/dev/") in sort_device_names devices +let is_partitioned_device device = + assert (String.is_prefix device "/dev/"); + assert (not (String.is_prefix device "/dev/mapper/")); + let device = String.sub device 5 (String.length device - 5) in + + (* Open the device's directory under /sys/block *) + let parts = Sys.readdir ("/sys/block/" ^ device) in + let parts...
2020 Sep 22
0
[v2v PATCH 2/2] linux: ignore -devel kernel packages
...index dc0c285d..9a41225a 100644 --- a/v2v/linux_kernels.ml +++ b/v2v/linux_kernels.ml @@ -92,7 +92,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader = let kernel_pkgs = List.filter ( fun { G.app2_name = name } -> name = "kernel" - || String.is_prefix name "kernel-" + || (String.is_prefix name "kernel-" && not (String.is_suffix name "-devel")) || String.is_prefix name "linux-image-" ) inspect.i_apps in if verbose () then ( -- 2.26.2
2016 Sep 09
0
[PATCH] v2v: linux: Move kernel detection to a separate module.
...= - if family = `Debian_family then - Str.regexp "^initrd.img-.*$" - else - Str.regexp "^initr\\(d\\|amfs\\)-.*\\(\\.img\\)?$" in - filter_map ( - function - | { G.app2_name = name } as app - when name = "kernel" || String.is_prefix name "kernel-" - || String.is_prefix name "linux-image-" -> - (try - (* For each kernel, list the files directly owned by the kernel. *) - let files = Linux.file_list_of_package g inspect app in - - if files = [] then ( -...
2016 Sep 09
2
[PATCH] v2v: linux: Move kernel detection to a separate module.
This is a sort of follow-up to the Linux_bootloaders patch. It turns out all the kernel detection code is nicely self- contained and can therefore be moved to its own module. Rich.
2023 Jun 29
1
[v2v PATCH v2 2/3] lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
...for_libvirt_rhbz_1045069 file = > let running_as_root = Unix.geteuid () = 0 in > - if running_as_root && backend_is_libvirt () then ( > - try > - let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in > - let uid = > - if String.is_prefix user "+" then > - int_of_string (String.sub user 1 (String.length user - 1)) > - else > - (Unix.getpwnam user).pw_uid in > - debug "setting owner of %s to %d:root" file uid; > - Unix.chown file uid 0 > - with > - | ex...
2023 Jun 29
1
[v2v PATCH v2 2/3] lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
...libvirt () = let rec chown_for_libvirt_rhbz_1045069 file = let running_as_root = Unix.geteuid () = 0 in - if running_as_root && backend_is_libvirt () then ( - try - let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in - let uid = - if String.is_prefix user "+" then - int_of_string (String.sub user 1 (String.length user - 1)) - else - (Unix.getpwnam user).pw_uid in - debug "setting owner of %s to %d:root" file uid; - Unix.chown file uid 0 - with - | exn -> (* Print exception, but con...
2023 Jun 29
1
[v2v PATCH v2 2/3] lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
...file = >> let running_as_root = Unix.geteuid () = 0 in >> - if running_as_root && backend_is_libvirt () then ( >> - try >> - let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in >> - let uid = >> - if String.is_prefix user "+" then >> - int_of_string (String.sub user 1 (String.length user - 1)) >> - else >> - (Unix.getpwnam user).pw_uid in >> - debug "setting owner of %s to %d:root" file uid; >> - Unix.chown file uid 0 >>...