mirror of
https://github.com/gentoo-mirror/guru.git
synced 2026-07-10 15:45:15 -04:00
dev-ml/shared-block-ring: add 3.0.1
Signed-off-by: Alessandro Barbieri <lssndrbarbieri@gmail.com>
This commit is contained in:
@@ -1 +1,2 @@
|
||||
DIST shared-block-ring-3.0.0.tar.gz 18503 BLAKE2B 786997d650a9094068822ba0b214e8e26658c8caaa26a0bc28f504bdf18f5f07a69896aae46ead9d337db1c7272d8198ed37b8e573e66c7e13ebd56bf94a96d8 SHA512 1f16926aaf641bcfb285d6047cb45b271c4bbb70b345aa803b51f8f966f7815a2890f6993f449aadb11c254f05064f6469cedb9020074c5a566eb6a4ca9d2a6e
|
||||
DIST shared-block-ring-3.0.1.tar.gz 18580 BLAKE2B 7c173687b9ea520160bc66b4cc05d59a38b012ef441b4b4134f7ff3f0d8cc0ad4dfdce7473bbd6c8b3603ce09f6205b0557b51921f4aabe2de9f7ec6d6bccd18 SHA512 45af10f6336ab21cf4c26e503b05c844906c45a7092b880f402d7560a572f5d674856ca459857854b1d7b8986266ec5b2693617c7bc27e2a54973376d5abc141
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
From 4c8fb45a201cd15aa038d84bd792679a31bec5a8 Mon Sep 17 00:00:00 2001
|
||||
From: Hannes Mehnert <hannes@mehnert.org>
|
||||
Date: Thu, 27 Jan 2022 16:24:42 +0100
|
||||
Subject: [PATCH] avoid deprecated Cstruct.len, use Cstruct.length instead
|
||||
|
||||
---
|
||||
lib/eraseBlock.ml | 4 ++--
|
||||
lib/ring.ml | 22 +++++++++++-----------
|
||||
lib_test/test.ml | 2 +-
|
||||
shared-block-ring.opam | 2 +-
|
||||
4 files changed, 15 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/lib/eraseBlock.ml b/lib/eraseBlock.ml
|
||||
index 5264b20..d073c36 100644
|
||||
--- a/lib/eraseBlock.ml
|
||||
+++ b/lib/eraseBlock.ml
|
||||
@@ -23,14 +23,14 @@ module Make(B: S.BLOCK) = struct
|
||||
>>= fun info ->
|
||||
let pages = Io_page.get block_size_pages in
|
||||
let buffer = Io_page.to_cstruct pages in
|
||||
- for i = 0 to Cstruct.len buffer - 1 do
|
||||
+ for i = 0 to Cstruct.length buffer - 1 do
|
||||
Cstruct.set_char buffer i (pattern.[i mod (String.length pattern)])
|
||||
done;
|
||||
let rec loop n =
|
||||
if n = info.Mirage_block.size_sectors
|
||||
then return (Ok ())
|
||||
else
|
||||
- let buffer_in_sectors = Cstruct.len buffer / info.Mirage_block.sector_size in
|
||||
+ let buffer_in_sectors = Cstruct.length buffer / info.Mirage_block.sector_size in
|
||||
let needed = Int64.to_int (min (Int64.sub info.Mirage_block.size_sectors n) (Int64.of_int buffer_in_sectors)) in
|
||||
let towrite = Cstruct.sub buffer 0 (needed * info.Mirage_block.sector_size) in
|
||||
B.write t n [ towrite ]
|
||||
diff --git a/lib/ring.ml b/lib/ring.ml
|
||||
index 58e98c4..23db9f1 100644
|
||||
--- a/lib/ring.ml
|
||||
+++ b/lib/ring.ml
|
||||
@@ -34,7 +34,7 @@ let minimum_size_sectors = Int64.add sector_data 1L
|
||||
let magic = Printf.sprintf "mirage shared-block-device 1.0"
|
||||
|
||||
let zero buf =
|
||||
- for i = 0 to Cstruct.len buf - 1 do
|
||||
+ for i = 0 to Cstruct.length buf - 1 do
|
||||
Cstruct.set_uint8 buf i 0
|
||||
done
|
||||
|
||||
@@ -357,7 +357,7 @@ module Producer = struct
|
||||
let open ResultM in
|
||||
let _sector = alloc t.info.Mirage_block.sector_size in
|
||||
(* add a 4 byte header of size, and round up to the next 4-byte offset *)
|
||||
- let needed_bytes = Int64.(logand (lognot 3L) (add 7L (of_int (Cstruct.len item)))) in
|
||||
+ let needed_bytes = Int64.(logand (lognot 3L) (add 7L (of_int (Cstruct.length item)))) in
|
||||
let first_sector = Int64.(div t.producer.producer (of_int t.info.Mirage_block.sector_size)) in
|
||||
let first_offset = Int64.(to_int (rem t.producer.producer (of_int t.info.Mirage_block.sector_size))) in
|
||||
|
||||
@@ -365,23 +365,23 @@ module Producer = struct
|
||||
the first page as it's only a 4-byte integer and we're padding to 4-byte offsets. *)
|
||||
read_modify_write t first_sector (fun sector ->
|
||||
(* Write the header and anything else we can *)
|
||||
- Cstruct.LE.set_uint32 sector first_offset (Int32.of_int (Cstruct.len item));
|
||||
+ Cstruct.LE.set_uint32 sector first_offset (Int32.of_int (Cstruct.length item));
|
||||
if first_offset + 4 = t.info.Mirage_block.sector_size
|
||||
then item (* We can't write anything else, so just return the item *)
|
||||
else begin
|
||||
- let this = min (t.info.Mirage_block.sector_size - first_offset - 4) (Cstruct.len item) in
|
||||
+ let this = min (t.info.Mirage_block.sector_size - first_offset - 4) (Cstruct.length item) in
|
||||
Cstruct.blit item 0 sector (first_offset + 4) this;
|
||||
Cstruct.shift item this
|
||||
end) >>= fun remaining ->
|
||||
|
||||
let rec loop offset remaining =
|
||||
- if Cstruct.len remaining = 0
|
||||
+ if Cstruct.length remaining = 0
|
||||
then return ()
|
||||
else begin
|
||||
read_modify_write t offset (fun sector ->
|
||||
- let this = min t.info.Mirage_block.sector_size (Cstruct.len remaining) in
|
||||
+ let this = min t.info.Mirage_block.sector_size (Cstruct.length remaining) in
|
||||
let frag = Cstruct.sub sector 0 this in
|
||||
- Cstruct.blit remaining 0 frag 0 (Cstruct.len frag);
|
||||
+ Cstruct.blit remaining 0 frag 0 (Cstruct.length frag);
|
||||
Cstruct.shift remaining this) >>= fun remaining ->
|
||||
loop (Int64.succ offset) remaining
|
||||
end in
|
||||
@@ -408,7 +408,7 @@ module Producer = struct
|
||||
(fun () ->
|
||||
let item = Item.to_cstruct item in
|
||||
(* every item has a 4 byte header *)
|
||||
- let needed_bytes = Int64.(add 4L (of_int (Cstruct.len item))) in
|
||||
+ let needed_bytes = Int64.(add 4L (of_int (Cstruct.length item))) in
|
||||
let open C in
|
||||
let open ResultM in
|
||||
ok_to_write t needed_bytes
|
||||
@@ -535,10 +535,10 @@ module Consumer = struct
|
||||
let frag = Cstruct.sub sector (4 + first_offset) this in
|
||||
Cstruct.blit frag 0 result 0 this;
|
||||
let rec loop consumer remaining =
|
||||
- if Cstruct.len remaining = 0
|
||||
+ if Cstruct.length remaining = 0
|
||||
then return ()
|
||||
else
|
||||
- let this = min t.info.Mirage_block.sector_size (Cstruct.len remaining) in
|
||||
+ let this = min t.info.Mirage_block.sector_size (Cstruct.length remaining) in
|
||||
let frag = Cstruct.sub remaining 0 this in
|
||||
read Int64.(add sector_data (rem consumer total_sectors)) t.disk sector >>= fun () ->
|
||||
Cstruct.blit sector 0 frag 0 this;
|
||||
@@ -547,7 +547,7 @@ module Consumer = struct
|
||||
(* Read the payload before updating the consumer pointer *)
|
||||
let needed_bytes = Int64.(logand (lognot 3L) (add 7L (of_int (len)))) in
|
||||
match Item.of_cstruct result with
|
||||
- | None -> Lwt.return (Error (`Msg (Printf.sprintf "Failed to parse queue item: (%d)[%s]" (Cstruct.len result) (String.escaped (Cstruct.to_string result)))))
|
||||
+ | None -> Lwt.return (Error (`Msg (Printf.sprintf "Failed to parse queue item: (%d)[%s]" (Cstruct.length result) (String.escaped (Cstruct.to_string result)))))
|
||||
| Some result ->
|
||||
return (Int64.(add t.consumer.consumer needed_bytes),result)
|
||||
end
|
||||
diff --git a/lib_test/test.ml b/lib_test/test.ml
|
||||
index 3769137..d9ff865 100644
|
||||
--- a/lib_test/test.ml
|
||||
+++ b/lib_test/test.ml
|
||||
@@ -47,7 +47,7 @@ let alloc sector_size =
|
||||
sector
|
||||
|
||||
let fill_with_message buffer message =
|
||||
- for i = 0 to Cstruct.len buffer - 1 do
|
||||
+ for i = 0 to Cstruct.length buffer - 1 do
|
||||
Cstruct.set_char buffer i (message.[i mod (String.length message)])
|
||||
done
|
||||
|
||||
diff --git a/shared-block-ring.opam b/shared-block-ring.opam
|
||||
index d9a95d1..1c703fa 100644
|
||||
--- a/shared-block-ring.opam
|
||||
+++ b/shared-block-ring.opam
|
||||
@@ -13,7 +13,7 @@ depends: [
|
||||
"ocaml" {>= "4.06.0"}
|
||||
"bisect_ppx" {dev & >= "2.5.0"}
|
||||
"cmdliner"
|
||||
- "cstruct" {>= "3.0.0"}
|
||||
+ "cstruct" {>= "6.0.0"}
|
||||
"dune" {>= "2.7.0"}
|
||||
"duration"
|
||||
"io-page"
|
||||
@@ -0,0 +1,59 @@
|
||||
From f0b61e87f809dce36fb93e31349d02d9a679253a Mon Sep 17 00:00:00 2001
|
||||
From: Hannes Mehnert <hannes@mehnert.org>
|
||||
Date: Thu, 27 Jan 2022 16:26:39 +0100
|
||||
Subject: [PATCH] adapt to mirage-block 3.0.0 changes
|
||||
|
||||
---
|
||||
lib/ring.ml | 4 ----
|
||||
shared-block-ring.opam | 4 ++--
|
||||
2 files changed, 2 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/lib/ring.ml b/lib/ring.ml
|
||||
index 23db9f1..f1e96ce 100644
|
||||
--- a/lib/ring.ml
|
||||
+++ b/lib/ring.ml
|
||||
@@ -92,14 +92,12 @@ module Common(Log: S.LOG)(B: S.BLOCK) = struct
|
||||
m >>= function
|
||||
| Error `Is_read_only -> Lwt.return (Error `Is_read_only)
|
||||
| Error `Disconnected -> Lwt.return (Error `Disconnected)
|
||||
- | Error `Unimplemented -> Lwt.return (Error `Unimplemented)
|
||||
| Error x -> Lwt.return (Error x)
|
||||
| Ok x -> f x
|
||||
let to_msg m =
|
||||
let open Lwt.Infix in
|
||||
m >>= function
|
||||
| Error `Disconnected -> Lwt.return (Error (`Msg "BLOCK device has already disconnected"))
|
||||
- | Error `Unimplemented -> Lwt.return (Error (`Msg "BLOCK function is unimplemented"))
|
||||
| Error `Is_read_only -> Lwt.return (Error (`Msg "BLOCK device is read-only"))
|
||||
| Error _ -> Lwt.return (Error (`Msg "Unknown error from BLOCK device"))
|
||||
| Ok x -> Lwt.return (Ok x)
|
||||
@@ -110,14 +108,12 @@ module Common(Log: S.LOG)(B: S.BLOCK) = struct
|
||||
let open Lwt.Infix in
|
||||
m >>= function
|
||||
| Error `Disconnected -> Lwt.return (Error `Disconnected)
|
||||
- | Error `Unimplemented -> Lwt.return (Error `Unimplemented)
|
||||
| Error x -> Lwt.return (Error x)
|
||||
| Ok x -> f x
|
||||
let to_msg m =
|
||||
let open Lwt.Infix in
|
||||
m >>= function
|
||||
| Error `Disconnected -> Lwt.return (Error (`Msg "BLOCK device has already disconnected"))
|
||||
- | Error `Unimplemented -> Lwt.return (Error (`Msg "BLOCK function is unimplemented"))
|
||||
| Error _ -> Lwt.return (Error (`Msg "Unknown error from BLOCK device"))
|
||||
| Ok x -> Lwt.return (Ok x)
|
||||
let return x = Lwt.return (Ok x)
|
||||
diff --git a/shared-block-ring.opam b/shared-block-ring.opam
|
||||
index 1c703fa..beb5c5b 100644
|
||||
--- a/shared-block-ring.opam
|
||||
+++ b/shared-block-ring.opam
|
||||
@@ -21,8 +21,8 @@ depends: [
|
||||
"logs"
|
||||
"lwt"
|
||||
"lwt_log"
|
||||
- "mirage-block" {>= "2.0.1"}
|
||||
- "mirage-block-unix"
|
||||
+ "mirage-block" {>= "3.0.0"}
|
||||
+ "mirage-block-unix" {>= "2.13.0"}
|
||||
"mirage-clock" {>= "3.0.0"}
|
||||
"mirage-clock-unix" {with-test}
|
||||
"mirage-time" {>= "2.0.1"}
|
||||
@@ -15,12 +15,12 @@ KEYWORDS="~amd64"
|
||||
IUSE="ocamlopt test"
|
||||
|
||||
RDEPEND="
|
||||
>=dev-ml/cstruct-6.0.0:=[ppx]
|
||||
>=dev-ml/cstruct-3.0.0:=[ppx]
|
||||
dev-ml/lwt:=
|
||||
dev-ml/lwt_log:=
|
||||
dev-ml/cmdliner:=
|
||||
dev-ml/duration:=
|
||||
>=dev-ml/io-page-2.4.0:=
|
||||
>=dev-ml/io-page-2.2.0:=[unix(-)]
|
||||
dev-ml/logs:=
|
||||
>=dev-ml/mirage-block-2.0.1:=
|
||||
dev-ml/mirage-block-unix:=
|
||||
@@ -41,4 +41,7 @@ DEPEND="
|
||||
"
|
||||
|
||||
RESTRICT="!test? ( test )"
|
||||
PATCHES="${FILESDIR}/${P}-PR-62.patch"
|
||||
PATCHES=(
|
||||
"${FILESDIR}/${P}-cstruct.patch"
|
||||
"${FILESDIR}/${P}-mirage-block.patch"
|
||||
)
|
||||
|
||||
43
dev-ml/shared-block-ring/shared-block-ring-3.0.1.ebuild
Normal file
43
dev-ml/shared-block-ring/shared-block-ring-3.0.1.ebuild
Normal file
@@ -0,0 +1,43 @@
|
||||
# Copyright 1999-2022 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
inherit dune
|
||||
|
||||
DESCRIPTION="A simple on-disk fixed length queue"
|
||||
HOMEPAGE="https://github.com/mirage/shared-block-ring"
|
||||
SRC_URI="https://github.com/mirage/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
|
||||
|
||||
LICENSE="ISC"
|
||||
SLOT="0/${PV}"
|
||||
KEYWORDS="~amd64"
|
||||
IUSE="ocamlopt test"
|
||||
|
||||
RDEPEND="
|
||||
>=dev-ml/cstruct-6.0.0:=[ppx]
|
||||
dev-ml/lwt:=
|
||||
dev-ml/lwt_log:=
|
||||
dev-ml/cmdliner:=
|
||||
dev-ml/duration:=
|
||||
>=dev-ml/io-page-2.4.0:=
|
||||
dev-ml/logs:=
|
||||
>=dev-ml/mirage-block-2.0.1:=
|
||||
dev-ml/mirage-block-unix:=
|
||||
dev-ml/mirage-clock:=
|
||||
>=dev-ml/mirage-time-2.0.1:=
|
||||
>=dev-ml/ppx_sexp_conv-0.10.0:=
|
||||
dev-ml/result:=
|
||||
dev-ml/rresult:=
|
||||
dev-ml/sexplib:=
|
||||
dev-ml/sexplib0:=
|
||||
"
|
||||
DEPEND="
|
||||
${RDEPEND}
|
||||
test? (
|
||||
dev-ml/ounit2
|
||||
dev-ml/mirage-clock-unix
|
||||
)
|
||||
"
|
||||
|
||||
RESTRICT="!test? ( test )"
|
||||
Reference in New Issue
Block a user