- method virtual blocksize : int
- method virtual mapblock : int64 -> (device * int64) list
+ method virtual blocksize : int63
+ method virtual map_block : int63 -> (device * int63) list
+ method virtual contiguous : Int63.t -> Int63.t
- let first_blk = offset /^ blocksize64 in
- let offset_in_first_blk = offset -^ first_blk *^ blocksize64 in
- let last_blk = (offset +^ Int64.of_int (len-1)) /^ blocksize64 in
+ let first_blk = offset /^ blocksize in
+ let offset_in_first_blk = offset -^ first_blk *^ blocksize in
+ let last_blk = (offset +^ len -^ ~^1) /^ blocksize in
let not_mapped_error () = invalid_arg "device: read: block not mapped" in
(* Copy the first block (partial). *)
let not_mapped_error () = invalid_arg "device: read: block not mapped" in
(* Copy the first block (partial). *)
- let len = (offset +^ Int64.of_int len) -^ last_blk *^ blocksize64 in
- let len = Int64.to_int len in
- let str = dev#read 0L len in
+ let len = (offset +^ len) -^ last_blk *^ blocksize in
+ let str = dev#read ~^0 len in
Buffer.contents buf
(* Helper method to read a chunk of data into a bitstring. *)
method read_bitstring offset len =
let str = self#read offset len in
Buffer.contents buf
(* Helper method to read a chunk of data into a bitstring. *)
method read_bitstring offset len =
let str = self#read offset len in
end
(* A concrete device which just direct-maps a file or /dev device. *)
class block_device filename blocksize =
let fd = openfile filename [ O_RDONLY ] 0 in
end
(* A concrete device which just direct-maps a file or /dev device. *)
class block_device filename blocksize =
let fd = openfile filename [ O_RDONLY ] 0 in
- method mapblock new_blk =
- let orig_blk =
- new_blk *^ Int64.of_int new_blocksize /^ Int64.of_int dev#blocksize in
- dev#mapblock orig_blk
+ method map_block new_blk =
+ let orig_blk = new_blk *^ new_blocksize /^ dev#blocksize in
+ dev#map_block orig_blk
+ method contiguous offset = dev#size -^ offset
- fs_block_size : int64; (* Block size (bytes). *)
- fs_blocks_total : int64; (* Total blocks. *)
+ fs_dev : device; (* Device containing the filesystem. *)
+ fs_blocksize : int63; (* Block size (bytes). *)
+ fs_blocks_total : int63; (* Total blocks. *)
- fs_blocks_reserved : int64; (* Blocks reserved for super-user. *)
- fs_blocks_avail : int64; (* Blocks free (available). *)
- fs_blocks_used : int64; (* Blocks in use. *)
- fs_inodes_total : int64; (* Total inodes. *)
- fs_inodes_reserved : int64; (* Inodes reserved for super-user. *)
- fs_inodes_avail : int64; (* Inodes free (available). *)
- fs_inodes_used : int64; (* Inodes in use. *)
+ fs_blocks_reserved : int63; (* Blocks reserved for super-user. *)
+ fs_blocks_avail : int63; (* Blocks free (available). *)
+ fs_blocks_used : int63; (* Blocks in use. *)
+ fs_inodes_total : int63; (* Total inodes. *)
+ fs_inodes_reserved : int63; (* Inodes reserved for super-user. *)
+ fs_inodes_avail : int63; (* Inodes free (available). *)
+ fs_inodes_used : int63; (* Inodes in use. *)