package mirage-block-combinators

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

Install

Dune Dependency

Authors

Maintainers

Sources

mirage-block-3.0.1.tbz
sha256=082a4d6a2208d920d5806650d147237025a532803e2dd6df12ad5aac8273e56f
sha512=b016a7410d7dcd885b87b480199ccd9722f664d82d57d1a6592b019c30086979b3b8650f017bd4130ef74f4f6d755a61d3b4c4910ff2dc4773c49590cf5f0ae6

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 "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 = Cstruct.create 4096;;
val page : Cstruct.t =
  {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.