package mirage-block-lwt

  1. Overview
  2. Docs

Safe block devices

Construct a safe wrapper around B where necessary buffer preconditions are checked on read and write, and useful error messages generated. Some concrete implementations generate confusing errors (e.g. Unix might say "EINVAL") which are harder to debug.

Parameters

module B : S

Signature

type error = private [>
  1. | Mirage_block.error
  2. | `Unsafe of string
]

The type for errors.

type write_error = private [>
  1. | Mirage_block.write_error
  2. | `Unsafe of string
]

The type for write errors.

include S with type t = B.t and type error := error and type write_error := write_error
type page_aligned_buffer = Cstruct.t
val pp_error : error Fmt.t
val pp_write_error : write_error Fmt.t
type 'a io = 'a Lwt.t
type t = B.t
val disconnect : t -> unit io
val get_info : t -> Mirage_block.info io
val read : t -> int64 -> page_aligned_buffer list -> (unit, error) Stdlib.result io
val write : t -> int64 -> page_aligned_buffer list -> (unit, write_error) Stdlib.result io
val unsafe_read : t -> int64 -> page_aligned_buffer list -> (unit, B.error) Result.result Lwt.t

unsafe_read is like read except it bypasses the necessary buffer precondition checks. Only use this if you want maximum performance and if you can prove the preconditions are respected.

val unsafe_write : t -> int64 -> page_aligned_buffer list -> (unit, B.write_error) Result.result Lwt.t

unsafe_write is like write except it bypasses the necessary buffer precondition checks. Only use this if you want maximum performance and if you can prove the buffer preconditions are respected.

OCaml

Innovation. Community. Security.