Module Image

Disk images.

type partition_scheme =
  1. | Mbr
  2. | Gpt
    (*

    The type for partition schemes.

    *)
type file_system =
  1. | Exfat
  2. | Fat32
    (*

    The type for file systems.

    *)
type byte_size = int

The type for file system sizes.

val kb_to_byte : int -> int
val mb_to_byte : int -> int
val gb_to_byte : int -> int
val byte_size_gb_multiple : int -> int
val make : partition_scheme:partition_scheme -> file_system:file_system -> byte_size:int -> name:string option -> force:bool -> make_path:bool -> B0_std.Fpath.t -> (unit, string) Stdlib.result

name maybe truncated depending on format.

val with_mount' : image:B0_std.Fpath.t -> (mount_root:B0_std.Fpath.t -> 'a) -> ('a, string) Stdlib.result

with_mount ~image f tries to mount image in a temporary directory mount_root and hands it out to f for processing. The image is unmounted when f returns.

val with_mount : image:B0_std.Fpath.t -> (mount_root:B0_std.Fpath.t -> ('a, string) Stdlib.result) -> ('a, string) Stdlib.result

with_mount' is like with_mount but it Result.joins the result of f.

Path tools

val cut_file : B0_std.Fpath.t -> ((B0_std.Fpath.t * B0_std.Fpath.t) option, string) Stdlib.result

cut_file p is Some (file, q) if file is an existing file on the file system and q the remaining path in p as an absolute path.

If p is exactly an existing file then the result is None. In this case p/ is Some (p, Fpath.root p.

The syntactic directoryness of p is kept in q.

val path_in_mount_to_image_path : image:B0_std.Fpath.t -> mount_root:B0_std.Fpath.t -> B0_std.Fpath.t -> B0_std.Fpath.t

path_in_mount_to_image_path ~image ~mount_root p drops mount_root from p and prepends image to id.

  • raises Invalid_argument

    if mount_root is not a prefix of p.

val get_existing_path_in_mount : image:B0_std.Fpath.t -> mount_root:B0_std.Fpath.t -> B0_std.Fpath.t -> (B0_std.Fpath.t, string) Stdlib.result

path_in_mount_root ~image ~mount_root p checks that the absolute path p (usually obtained via cut_file) exists in mount_root, that it does not goes above the mount point mount_root and returns its path prepended by mount_root. This is not syntactic it's based on realpath.

image is the path to the image, it is used for reporting errors as if they originate from a sub path of this file.

val get_syntactic_path_in_mount : image:B0_std.Fpath.t -> mount_root:B0_std.Fpath.t -> B0_std.Fpath.t -> (B0_std.Fpath.t, string) Stdlib.result

ensure_path_in_mount is like get_existing_path_in_mount execept the path may not exist.