package mirage-block-partition

  1. Overview
  2. Docs
Mirage block device partitioning

Install

Dune Dependency

Authors

Maintainers

Sources

mirage-block-partition-0.2.0.tbz
sha256=7173ad10ff70864846423ebd4f868a7b16e67ba85f54056a0c56bd91fe960171
sha512=665726cfe861c3de311a61591a03574e512f36ba81193451bece340b022e0a1b9a1a492132a1ae722c3439c44689a22763a83b5a9bb0dd8079c2ca5c4cdc249a

Description

Mirage-block-partition lets you view a mirage block device as smaller partitions.

Published: 21 Mar 2024

README

mirage-block-partition -- block device partitioning

Mirage-block-partition lets you view a mirage block device as smaller partitions. A partition can be further subpartitioned into smaller partitions.

module Make(B : Mirage_block.S)(Clock : Mirage_clock.PCLOCK) = struct

  module Partitioned = Mirage_block_partition.Make(B)
  module Tar = Tar_mirage.Make_KV_RO(Partitioned)
  module Chamelon = Kv.Make(Partitioned)(Clock)

  let start b =
    let open Lwt.Syntax in
    (* b1 is the first twenty sectors, b2 is the next 8k sectors (4 MiB),
       and b3 is the remaining space. Note that the initial [connect] call is
       asynchronous while the later [subpartition] calls are not. If the
       partition point is outside the block device or subpartition then an
       exception is raised. *)
    let* b = Partitioned.connect b in
    let* { size_sectors; _ } = Partition.get_info b in
    let b1 = Partitioned.subpartition ~start:0L ~len:20L b in
    (* We can further subpartition a partition: *)
    let rest = Partition.subpartition ~start:20L ~len:(Int64.sub size_sectors 20L) in
    (* And the size of the partition will be reported correctly. *)
    let* { size_sectors = remaining; _ } = Partitioned.get_info rest in
    (* [b2] is right after [b1]. *)
    let b2 = Partitioned.subpartition ~start:0L ~len:8192L rest
    and b3 = Partitioned.subpartition ~start:8192L ~len:(Int64.sub remaining 8192L) rest in
    (* now use e.g. b1 as a tar KV store, b2 as a chamelon filesystem,
       b3 as a raw block device... *)
    let* tar = Tar.connect b1
    and* chamelon = Chamelon.connect ~program_size:16 b2 in
    ...

end

mirage-block-partition-mbr

This module reads a disk labeled with a Master Boot Record and returns a list of pairs of Mbr.Partition.t and a block device representing the partition according to the MBR.

Dependencies (5)

  1. mbr-format >= "1.0.0"
  2. lwt >= "5.6.0"
  3. mirage-block >= "3.0.0"
  4. ocaml >= "4.08.0"
  5. dune >= "3.4"

Dev Dependencies (3)

  1. alcotest-lwt with-test & >= "1.0.0"
  2. alcotest with-test & >= "1.0.0"
  3. mirage-block-combinators with-test

Used by

None

Conflicts (1)

  1. result < "1.5"
OCaml

Innovation. Community. Security.