package mirage-block-ramdisk

  1. Overview
  2. Docs
In-memory BLOCK device for MirageOS

Install

Dune Dependency

Authors

Maintainers

Sources

mirage-block-ramdisk-0.5.tbz
sha256=cc0e814fd54efe7a5b7a8c5eb1c04e2dece751b7d8dee2d95908a0768896e8af
sha512=2557896713c0d7a833d30b9847e2c545929df40cd04c534fed7a8d0ea25c2cd1075b8ae5ba56e47bdeac5a60a07a222a1780b32cc12ebcb2ce94fdffdcf0657c

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.