package mirage-block-ramdisk

  1. Overview
  2. Docs
In-memory block device ("Ramdisk") for Mirage

Install

Dune Dependency

Authors

Maintainers

Sources

v0.3.tar.gz
sha256=d3131b4860f6f7d93cffaf58ae9a182ca68b21958c285cc0710d9d4d6e1e52aa
md5=ab0127760d2e3a2103cd2b3d5089b5e5

README.md.html

mirage-block-ramdisk

A simple in-memory BLOCK device.

Please see the API documentation.

Features

  • Can be dynamically resized

  • Supports querying sparseness information

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 ()
OCaml

Innovation. Community. Security.