package mirage-fs

  1. Overview
  2. Docs
On This Page
  1. Filesystem
Legend:
Library
Module
Module type
Parameter
Class
Class type

Filesystem

type error = private [>
  1. | `Is_a_directory
  2. | `No_directory_entry
  3. | `Not_a_directory
]

The type for errors.

val pp_error : error Fmt.t

pp_error is the pretty-printer for errors.

type write_error = private [>
  1. | `Is_a_directory
  2. | `No_directory_entry
  3. | `Not_a_directory
  4. | `File_already_exists
  5. | `No_directory_entry
  6. | `No_space
]

The type for FS write errors.

val pp_write_error : write_error Fmt.t

pp_write_error is the pretty-printer for write errors.

include Mirage_device.S
type +'a io

The type for potentially blocking I/O operation

type t

The type representing the internal state of the device

val disconnect : t -> unit io

Disconnect from the device. While this might take some time to complete, it can never result in an error.

type page_aligned_buffer

The type for memory buffers.

val read : t -> string -> int -> int -> (page_aligned_buffer list, error) Stdlib.result io

read t key offset length reads up to length bytes from the value associated with key. If less data is returned than requested, this indicates the end of the value.

val size : t -> string -> (int64, error) Stdlib.result io

Get the value size.

val create : t -> string -> (unit, write_error) Stdlib.result io

create t path creates an empty file at path. If path contains directories that do not yet exist, create will attempt to create them.

val mkdir : t -> string -> (unit, write_error) Stdlib.result io

mkdir t path creates an empty directory at path. If path contains intermediate directories that do not yet exist, mkdir will create them. If a directory already exists at path, mkdir returns `Ok () and takes no action.

val destroy : t -> string -> (unit, write_error) Stdlib.result io

destroy t path removes a path (which may be a file or an empty directory) on filesystem t.

val stat : t -> string -> (stat, error) Stdlib.result io

stat t path returns information about file or directory at path.

val listdir : t -> string -> (string list, error) Stdlib.result io

listdir t path returns the names of files and subdirectories within the directory path.

val write : t -> string -> int -> page_aligned_buffer -> (unit, write_error) Stdlib.result io

write t path offset data writes data at offset in file path on filesystem t.

If path contains directories that do not exist, write will attempt to create them. If path already exists, write will overwrite existing information starting at off.

OCaml

Innovation. Community. Security.