TPFS-0.1: Tagged plain file system in which a file can only have multiple tags and nothing more.




Functions for dealing with TPFS blocks.

This is not a high level interface; it only provides a few utility functions for dealing with the blocks on disk themselves. It does not deal with extents or anything like that. See System.TPFS.Extent.

If you are looking for a high level interface, check out the modules for the the objects you are trying to access, as TPFS blocks simply contain these objects.



blockIndexToAddress :: Header -> BlockIndex -> AddressSource

Converts a BlockIndex to an Address in the context of a filesystem.

addressToBlockIndex :: Header -> Address -> BlockIndexSource

Converts an Address to a Blockindex in the context of a filesystem.

Note: This function will floor any addresses to the block boundary; it does not preserve offsets. See addressToBlockIndexAndOffset.

addressToBlockIndexAndOffset :: Header -> Address -> (BlockIndex, Word64)Source

Converts an Address to a BlockIndex and byte offset within the block in the context of a filesystem.

Note: Undefined when the Address points to somewhere before the beginning of the block space.

divBlocks :: Integral i => i -> Header -> iSource

Divides a number of bytes into the required number of blocks according to a filesystem header.

Reading and writing

readBlock :: Device m h => Filesystem m h -> BlockIndex -> m ByteStringSource

Reads an entire block into memory.

writeBlock :: Device m h => Filesystem m h -> BlockIndex -> ByteString -> m ()Source

Replaces a block with the given string. The string is truncated/padded with NULs to fit the filesystem's block size.