package mbr-format

  1. Overview
  2. Docs
A simple library for manipulating Master Boot Records

Install

Dune Dependency

Authors

Maintainers

Sources

mbr-format-1.0.0.tbz
sha256=8007ab4cf6b9bca89db8dc29ad4b5689b712cb303868e553cc583f5a995fa787
sha512=5bb55faf907b3cc6bd8fbd56bac6b7bfcd0ab37a62daf0235accc66c6a9e89a15e72f8274d725bbace1c815d72959c9894f053dd22a6f31d65bd7f8f9ec948a3

Description

Published: 28 Sep 2022

README

ocaml-mbr

A simple library for manipulating Master Boot Records. The primary purposes of this library are:

  1. to create bootable disk images creating mirage kernels

  2. for mirage kernels to read the partition tables on attached disks

Usage

Define a single partition as follows:

    let disk_length_bytes = Int32.(mul (mul 16l 1024l) 1024l) in
    let disk_length_sectors = Int32.(div disk_length_bytes 512l) in

    let start_sector = 2048l in
    let length_sectors = Int32.sub disk_length_sectors start_sector in
    let partition = Mbr.Partition.make ~active:true ~ty:6 start_sector length_sectors in
    let mbr = Mbr.make [ partition ] in

You can write the MBR to sector zero of a block device B as follows:

    B.connect id >>= fun device ->
    let sector = Cstruct.create 512 in
    Mbr.marshal sector mbr;
    B.write device 0L [ sector ] >>= fun () ->
    ...

To do items

  • Implement tools to manipulate MBR-formatted disk images to construct, inspect or fill partitions that can later be used in Mirage unikernels.

Dependencies (4)

  1. ppx_cstruct
  2. cstruct >= "6.0.0"
  3. dune >= "3.4.0"
  4. ocaml >= "4.08.0"

Dev Dependencies (2)

  1. alcotest with-test
  2. fmt with-test

Conflicts (1)

  1. result < "1.5"
OCaml

Innovation. Community. Security.