package mirage-block-combinators

  1. Overview
  2. Docs
Block signatures and implementations for MirageOS using Lwt

Install

Dune Dependency

Authors

Maintainers

Sources

mirage-block-v3.0.0.tbz
sha256=341e67269a6932d762d070e329c080a918cee2f21b00c7e73fddf83fe4a7ce65
sha512=57826493d421926aa54001c309cea8ef33bbd4ea7c05b35c23ee4483c9ea5ed6baf9ef078a9fbdf298c390b5976025e8875b2ed3ac078a4dee5667af39427291

README.md.html

Block implementations for mirage

This repo contains generic operations over Mirage BLOCK devices.

Please consult the API documentation.

Example usage

In a top-level like utop:

# #require "io-page.unix";;
# #require "mirage-block";;
# #require "mirage-block-ramdisk";;
# #require "lwt.syntax";;

# lwt t_or_error = Ramdisk.create ~name:"hello" ~size_sectors:1024L ~sector_size:512;;
val t_or_error : [ `Error of Ramdisk.error | `Ok of Ramdisk.t ] = `Ok <abstr>

# let t = Mirage_block.Error.ok_exn t_or_error;;
val t : Ramdisk.t = <abstr>

# let page = Io_page.(to_cstruct (get 1));;
val page : Ramdisk.page_aligned_buffer =
  {Cstruct.buffer = <abstr>; off = 0; len = 4096}

# lwt result_or_error = Ramdisk.read t 0L [ page ];;
val result_or_error : [ `Error of Ramdisk.error | `Ok of unit ] = `Ok ()

# lwt ok_or_error = Mirage_block.sparse_copy (module Ramdisk) t (module Ramdisk) t;;
val ok_or_error :
  [ `Error of [> `Different_sizes | `Is_read_only | `Msg of bytes ]
  | `Ok of unit ] = `Ok ()
OCaml

Innovation. Community. Security.