Module Tjr_fs_shared.Blk_intf

Blk-related interfaces

The main choices:

NOTE this is included in the top-level package module

module Blk_sz : sig ... end
type blk_sz = Blk_sz.blk_sz
val blk_sz_4096 : Blk_sz.blk_sz
module Blk_id_as_int : sig ... end

This is a common instance of blk_id; we don't open it by default because we want most code to be independent of the exact repn. of blk_id

module Blk_ops : sig ... end
include Blk_ops
type ('blk, 'buf) blk_ops = {
blk_sz : blk_sz;
blk_to_buf : 'blk -> 'buf;
buf_to_blk : 'buf -> 'blk;
}

NOTE the conversion to blk checks the length

module Blk_dev_ops : sig ... end
include Blk_dev_ops
type ('blk_id, 'blk, 't) blk_dev_ops = {
blk_sz : blk_sz;
write : blk_id:'blk_id -> blk:'blk -> (unit, 't) Tjr_monad.m;
read : blk_id:'blk_id -> ('blk't) Tjr_monad.m;
write_many : ('blk_id * 'blk) list -> (unit, 't) Tjr_monad.m;
}

A block device: read and write blocks.

module Blk_allocator_ops : sig ... end
include Blk_allocator_ops
type ('blk_id, 't) blk_allocator_ops = {
blk_alloc : unit -> ('blk_id't) Tjr_monad.m;
blk_free : 'blk_id -> (unit, 't) Tjr_monad.m;
}

NOTE we assume alloc never fails, or that error is handled elsewhere in the monad; fields were named alloc and free

type ('blk_id, 'blk, 't, 'fd) blk_dev_impl = < add_debug : ('blk_id'blk't) blk_dev_ops -> ('blk_id'blk't) blk_dev_ops; add_profiling : ('blk_id'blk't) blk_dev_ops -> ('blk_id'blk't) blk_dev_ops; with_ : blk_sz:blk_sz -> < from_fd : 'fd -> < blk_dev_ops : ('blk_id'blk't) blk_dev_ops; fd : 'fd; sync : unit -> (unit, 't) Tjr_monad.m; close : unit -> (unit, 't) Tjr_monad.m; >; >; >