daemon/utils.ml: Replace Bytes.get_uint8 with native call

Bytes.get_uint8 was added in OCaml 4.08.  To support OCaml >= 4.04 (in
particular, RHEL 8 has OCaml 4.07) we have to replace this function
with the equivalent native call.  We can remove this commit once the
baseline OCaml moves up.

Updates: commit edfebee404
This commit is contained in:
Richard W.M. Jones
2022-04-14 11:31:03 +01:00
parent 05419dbcec
commit d64d2b7649

View File

@@ -187,6 +187,11 @@ and compare_device_names a b =
)
)
(* Bytes.get_uint8 was added in OCaml 4.08, so when we depend on
* that version, remove this definition.
*)
external bytes_get_uint8 : bytes -> int -> int = "%bytes_safe_get"
let has_bogus_mbr device =
try
with_openfile device [O_RDONLY; O_CLOEXEC] 0 (fun fd ->
@@ -201,7 +206,7 @@ let has_bogus_mbr device =
0x0E (* FAT16B LBA *)] in
let sec0 = Bytes.create sec0size in
let sec0read = read fd sec0 0 sec0size in
let sec0at = Bytes.get_uint8 sec0 in
let sec0at = bytes_get_uint8 sec0 in
(* sector read completely *)
sec0read = sec0size &&