package mirage-fs-unix

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Loopback implementation of the FS signature.

include V1.FS with type +'a io = 'a Lwt.t and type page_aligned_buffer = Cstruct.t
type block_device_error

The type for errors from the block layer

type error = [
  1. | `Not_a_directory of string
    (*

    Cannot create a directory entry in a file

    *)
  2. | `Is_a_directory of string
    (*

    Cannot read or write the contents of a directory

    *)
  3. | `Directory_not_empty of string
    (*

    Cannot remove a non-empty directory

    *)
  4. | `No_directory_entry of string * string
    (*

    Cannot find a directory entry

    *)
  5. | `File_already_exists of string
    (*

    Cannot create a file with a duplicate name

    *)
  6. | `No_space
    (*

    No space left on the block device

    *)
  7. | `Format_not_recognised of string
    (*

    The block device appears to not be formatted

    *)
  8. | `Unknown_error of string
  9. | `Block_device of block_device_error
]

The type for filesystem errors.

include V1.DEVICE with type error := error with type +'a io = 'a Lwt.t
type +'a io = 'a Lwt.t

The type for potentially blocking I/O operation

type t

The type representing the internal state of the device

type id

This type is no longer used and will be removed once other * modules stop using it in their type signatures.

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 = Cstruct.t

The type for memory buffers.

val read : t -> string -> int -> int -> [ `Ok of page_aligned_buffer list | `Error of error ] 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 -> [ `Error of error | `Ok of int64 ] io

Get the value size.

type stat = {
  1. filename : string;
    (*

    Filename within the enclosing directory

    *)
  2. read_only : bool;
    (*

    True means the contents are read-only

    *)
  3. directory : bool;
    (*

    True means the entity is a directory; false means a file

    *)
  4. size : int64;
    (*

    Size of the entity in bytes

    *)
}

The type for Per-file/directory statistics.

val format : t -> int64 -> [ `Ok of unit | `Error of error ] io

format t size erases the contents of t and creates an empty filesystem of size size bytes.

val create : t -> string -> [ `Ok of unit | `Error of error ] 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 -> [ `Ok of unit | `Error of error ] 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 -> [ `Ok of unit | `Error of error ] io

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

val stat : t -> string -> [ `Ok of stat | `Error of error ] io

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

val listdir : t -> string -> [ `Ok of string list | `Error of error ] io

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

val write : t -> string -> int -> page_aligned_buffer -> [ `Ok of unit | `Error of error ] 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.

val string_of_error : error -> string

Pretty print errors.

val connect : string -> [ `Ok of t | `Error of error ] io