Safe Haskell | Unsafe |
---|
This module exports the basic interface for creating and using the
labeled file system, implemented as a file store. Trusted code should
use initFSTCB
to set the root of the labeled file system. Moreover,
trusted code should implement all the IO functions in terms of
createFileTCB
, createDirectoryTCB
, and getPathLabelTCB
and
setPathLabelTCB
.
- initFSTCB :: SLabel l => FilePath -> Maybe l -> LIO l ()
- mkFSTCB :: SLabel l => FilePath -> l -> LIO l ()
- setFSTCB :: SLabel l => FilePath -> LIO l ()
- getRootDirTCB :: SLabel l => LIO l FilePath
- setPathLabelTCB :: SLabel l => FilePath -> l -> LIO l ()
- getPathLabelTCB :: SLabel l => FilePath -> LIO l l
- createFileTCB :: SLabel l => l -> FilePath -> IOMode -> LIO l Handle
- createDirectoryTCB :: SLabel l => l -> FilePath -> LIO l ()
- data LFilePath l = LFilePathTCB {}
- data FSError
- type SLabel l = (Label l, Serialize l)
- lazyEncodeLabel :: SLabel l => l -> L8
- encodeLabel :: SLabel l => l -> AttrValue
- decodeLabel :: SLabel l => AttrValue -> Either String l
Initializing labeled filesystem
initFSTCB :: SLabel l => FilePath -> Maybe l -> LIO l ()Source
Initialize filesystem at the given path. The supplied path must be
absolute, otherwise initFSTCB
throw FSRootInvalid
. If the FS has
already been created then initFSTCB
solely verifies that the root
directory is not corrupt (see setFSTCB
). Otherwise, a new FS is created
with the supplied label (see mkFSTCB
).
This function performs several checks that setFSTCB
and mkFSTCB
perform,
so when considering performance they should be called directly.
Create a the file store (i.e., labeled file system) with a given
label and root file path. The path must be an absolute path,
otherwise initFSTCB
throws FSRootInvalid
.
setFSTCB :: SLabel l => FilePath -> LIO l ()Source
Set the given file path as the root of the labeled filesystem. This
function throws a FSLabelCorrupt
if the directory does not contain a
valid label, and a FSRootCorrupt
if the magicAttr
attribute is
missing.
getRootDirTCB :: SLabel l => LIO l FilePathSource
Get the root directory.
Handling path labels
setPathLabelTCB :: SLabel l => FilePath -> l -> LIO l ()Source
Set the label of a given path. This function sets the labelAttr
attribute to the encoded label, and the hash to labelHashAttr
.
getPathLabelTCB :: SLabel l => FilePath -> LIO l lSource
Get the label of a given path. If the object does not have an
associated label or the hash of the label and stored-hash are not
equal, this function throws FSLabelCorrupt
.
Creating labeled objects
createFileTCB :: SLabel l => l -> FilePath -> IOMode -> LIO l HandleSource
Create a file object with the given label and return a handle to the new file.
createDirectoryTCB :: SLabel l => l -> FilePath -> LIO l ()Source
Create a directory object with the given label.
Labeled FilePath
LFilePathTCB | |
|
Filesystem errors
Filesystem errors
FSRootCorrupt | Root structure is corrupt. |
FSRootInvalid | Root is invalid (must be absolute). |
FSRootExists | Root already exists. |
FSRootNoExist | Root does not exists. |
FSRootNeedLabel | Cannot create root, missing label. |
FSObjNeedLabel | FSobjectcannot be created without a label. |
FSLabelCorrupt FilePath | Object label is corrupt. |
FSIllegalFileName | Supplied file name is illegal. |
Serializable label constraint
lazyEncodeLabel :: SLabel l => l -> L8Source
Encode a label into an attribute value.
encodeLabel :: SLabel l => l -> AttrValueSource
Encode a label into an attribute value.