package mfat

  1. Overview
  2. Docs
An implementation of FAT32 in OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mfat-0.0.1.beta1.tbz
sha256=a3dcb21bb74a9b17bb21bbd6b8f2e56d687d85ff732841c3ddb425a9be9cf1e3
sha512=a70ce27dc2e81c0a7515e64fdbdd695f9ef57f35a213a0ad6ceaed3fbe88439087100d2b3f2bc256228c8e169c28c88a9f6d47355d93856bb49bdb86ff745d1d

doc/README.html

mfat, a FAT32 file system in OCaml

mfat is an implementation of the FAT32 file system. It allows users to manipulate an image (in the form of a file) using the mfat utility, as well as in the form of a library, provided the user provides an implementation of a block device. For example, here is a possible implementation for unikernels using mkernel:

module Blk = struct
  type t = Mkernel.Block.t

  let pagesize = Mkernel.Block.pagesize
  let read = Mkernel.Block.atomic_read
  let write = Mkernel.Block.atomic_write
end

module FS = Mfat_bos.Make (Blk)

let fs ~name =
  let fn blk () =
    let v = FS.create blk in
    let v = Result.map_error (fun (`Msg msg) -> msg) v in
    Result.error_to_failure v
  in
  Mkernel.map fn [ Mkernel.block name ]

let () =
  Mkernel.(run [ fs ~name:"fs"]) @@ fun fs () ->
  ...

The user can then create an image using the mfat tool:

$ mfat make -s 2048 fs.img
$ mount fs.img /mnt
$ cd /mnt
$ echo "Hello World!" > foo.txt
$ cd -
$ umount /mnt
$ mfat cat fs.img /foo.txt
Hello World!

Finally, the image can be manipulated from OCaml code using, among other things, the Mfat_bos.Make interface (a replica of the bos interface).