Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tar_kv_ro and tar_kv_rw #1389

Merged
merged 4 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/mirage/impl/mirage_impl_block.ml
Expand Up @@ -101,17 +101,24 @@ let generic_block ?group ?(key = Key.value @@ Key.block ?group ()) name =
]
~default:(ramdisk name)

let tar_kv_ro_conf, tar_kv_rw_conf =
let tar_kv_ro_conf =
let packages = [ package ~min:"1.0.0" ~max:"3.0.0" "tar-mirage" ] in
let connect _ modname = function
| [ block ] -> Fmt.str "%s.connect %s" modname block
| _ -> failwith (connect_err "tar_kv" 1)
| _ -> failwith (connect_err "tar_kv_ro" 1)
in
impl ~packages ~connect "Tar_mirage.Make_KV_RO" (block @-> Mirage_impl_kv.ro),
impl ~packages ~connect "Tar_mirage.Make_KV_RW" (block @-> Mirage_impl_kv.rw)
impl ~packages ~connect "Tar_mirage.Make_KV_RO" (block @-> Mirage_impl_kv.ro)

let tar_kv_rw_conf =
let packages = [ package ~min:"1.0.0" ~max:"3.0.0" "tar-mirage" ] in
reynir marked this conversation as resolved.
Show resolved Hide resolved
let connect _ modname = function
| [ _pclock; block ] -> Fmt.str "%s.connect %s" modname block
| _ -> failwith (connect_err "tar_kv_rw" 2)
in
impl ~packages ~connect "Tar_mirage.Make_KV_RW" (pclock @-> block @-> Mirage_impl_kv.rw)

let tar_kv_ro block = tar_kv_ro_conf $ block
let tar_kv_rw block = tar_kv_rw_conf $ block
let tar_kv_rw pclock block = tar_kv_rw_conf $ pclock $ block
let archive = tar_kv_ro

let fat_conf =
Expand Down
2 changes: 1 addition & 1 deletion lib/mirage/impl/mirage_impl_block.mli
Expand Up @@ -33,7 +33,7 @@ val chamelon :
program_block_size:int Functoria.key ->
(block -> Mirage_impl_pclock.pclock -> Mirage_impl_kv.rw) Functoria.impl

val tar_kv_rw : block Functoria.impl -> Mirage_impl_kv.rw Functoria.impl
val tar_kv_rw : Mirage_impl_pclock.pclock Functoria.impl -> block Functoria.impl -> Mirage_impl_kv.rw Functoria.impl

val ccm_block :
?maclen:int ->
Expand Down
3 changes: 2 additions & 1 deletion lib/mirage/mirage.ml
Expand Up @@ -80,7 +80,8 @@ let docteur ?mode ?disk ?analyze ?branch ?extra_deps remote =
let chamelon ~program_block_size ?(pclock = default_posix_clock) block =
Mirage_impl_block.chamelon ~program_block_size $ block $ pclock

let tar_kv_rw = Mirage_impl_block.tar_kv_rw
let tar_kv_rw ?(pclock = default_posix_clock) block =
Mirage_impl_block.tar_kv_rw pclock block

type block = Mirage_impl_block.block

Expand Down
4 changes: 2 additions & 2 deletions lib/mirage/mirage.mli
Expand Up @@ -272,7 +272,7 @@ val crunch : string -> kv_ro impl
val tar_kv_ro : block impl -> kv_ro impl
(** [tar_kv_ro block] is a read-only tar archive. *)

val archive : block impl -> kv_ro impl
val archive : block impl -> kv_ro impl [@@ocaml.deprecated "use Mirage.tar_kv_ro"]
(** @deprecated You should use {!val:tar_kv_ro} (or {!val:tar_kv_rw}). *)

val direct_kv_ro : string -> kv_ro impl
Expand Down Expand Up @@ -387,7 +387,7 @@ val chamelon :
$ chamelon format db.img 512
]} *)

val tar_kv_rw : block impl -> kv_rw impl
val tar_kv_rw : ?pclock:pclock impl -> block impl -> kv_rw impl
(** [tar_kv_rw block] is a read/write tar archive. Note that the filesystem is
append-only. That is, files can generally not be removed, [set_partial] only
works on what is allocated, and there are restrictions on [rename]. *)
Expand Down