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 2 commits
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
16 changes: 13 additions & 3 deletions lib/mirage/impl/mirage_impl_block.ml
Expand Up @@ -101,15 +101,25 @@ let generic_block ?group ?(key = Key.value @@ Key.block ?group ()) name =
]
~default:(ramdisk name)

let archive_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 "archive" 1)
| _ -> failwith (connect_err "tar_kv_ro" 1)
in
impl ~packages ~connect "Tar_mirage.Make_KV_RO" (block @-> Mirage_impl_kv.ro)

let archive block = archive_conf $ block
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 pclock block = tar_kv_rw_conf $ pclock $ block
let archive = tar_kv_ro

let fat_conf =
let packages = [ package ~min:"0.15.0" ~max:"0.16.0" "fat-filesystem" ] in
Expand Down
3 changes: 3 additions & 0 deletions lib/mirage/impl/mirage_impl_block.mli
Expand Up @@ -8,6 +8,7 @@ val generic_block :
string ->
block Functoria.impl

val tar_kv_ro : block Functoria.impl -> Mirage_impl_kv.ro Functoria.impl
val archive : block Functoria.impl -> Mirage_impl_kv.ro Functoria.impl
val fat_ro : block Functoria.impl -> Mirage_impl_kv.ro Functoria.impl
val ramdisk : string -> block Functoria.impl
Expand All @@ -32,6 +33,8 @@ val chamelon :
program_block_size:int Functoria.key ->
(block -> Mirage_impl_pclock.pclock -> 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 ->
?nonce_len:int ->
Expand Down
4 changes: 4 additions & 0 deletions lib/mirage/mirage.ml
Expand Up @@ -80,9 +80,13 @@ 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 ?(pclock = default_posix_clock) block =
Mirage_impl_block.tar_kv_rw pclock block

type block = Mirage_impl_block.block

let block = Mirage_impl_block.block
let tar_kv_ro = Mirage_impl_block.tar_kv_ro
let archive = Mirage_impl_block.archive
let fat_ro = Mirage_impl_block.fat_ro
let generic_block = Mirage_impl_block.generic_block
Expand Down
12 changes: 10 additions & 2 deletions lib/mirage/mirage.mli
Expand Up @@ -269,8 +269,11 @@ val kv_ro : kv_ro typ
val crunch : string -> kv_ro impl
(** Crunch a directory. *)

val archive : block impl -> kv_ro impl
(** Use a TAR archive. *)
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 [@@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
(** Direct access to the underlying filesystem as a key/value store. For Xen
Expand Down Expand Up @@ -384,6 +387,11 @@ val chamelon :
$ chamelon format db.img 512
]} *)

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]. *)

val ccm_block :
?maclen:int -> ?nonce_len:int -> string option key -> block impl -> block impl
(** [ccm_block key block] returns a new block which is a AES-CCM encrypted disk.
Expand Down