Portability | GHC 6.4-7.8.2 |
---|---|
Stability | experimental |
Maintainer | Montez Fitzpatrick |
Safe Haskell | None |
A binding for the FUSE (Filesystem in USErspace) library (http://fuse.sourceforge.net/), which allows filesystems to be implemented as userspace processes.
The binding tries to follow as much as possible current Haskell POSIX interface in System.Posix.Files and System.Posix.Directory.
FUSE uses POSIX threads, so any Haskell application using this library must
be linked against a threaded runtime system (eg. using the threaded
GHC
option).
- module Foreign.C.Error
- data FuseOperations fh = FuseOperations {
- fuseGetFileStat :: FilePath -> IO (Either Errno FileStat)
- fuseReadSymbolicLink :: FilePath -> IO (Either Errno FilePath)
- fuseCreateDevice :: FilePath -> EntryType -> FileMode -> DeviceID -> IO Errno
- fuseCreateDirectory :: FilePath -> FileMode -> IO Errno
- fuseRemoveLink :: FilePath -> IO Errno
- fuseRemoveDirectory :: FilePath -> IO Errno
- fuseCreateSymbolicLink :: FilePath -> FilePath -> IO Errno
- fuseRename :: FilePath -> FilePath -> IO Errno
- fuseCreateLink :: FilePath -> FilePath -> IO Errno
- fuseSetFileMode :: FilePath -> FileMode -> IO Errno
- fuseSetOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO Errno
- fuseSetFileSize :: FilePath -> FileOffset -> IO Errno
- fuseSetFileTimes :: FilePath -> EpochTime -> EpochTime -> IO Errno
- fuseOpen :: FilePath -> OpenMode -> OpenFileFlags -> IO (Either Errno fh)
- fuseRead :: FilePath -> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString)
- fuseWrite :: FilePath -> fh -> ByteString -> FileOffset -> IO (Either Errno ByteCount)
- fuseGetFileSystemStats :: String -> IO (Either Errno FileSystemStats)
- fuseFlush :: FilePath -> fh -> IO Errno
- fuseRelease :: FilePath -> fh -> IO ()
- fuseSynchronizeFile :: FilePath -> SyncType -> IO Errno
- fuseOpenDirectory :: FilePath -> IO Errno
- fuseReadDirectory :: FilePath -> IO (Either Errno [(FilePath, FileStat)])
- fuseReleaseDirectory :: FilePath -> IO Errno
- fuseSynchronizeDirectory :: FilePath -> SyncType -> IO Errno
- fuseAccess :: FilePath -> Int -> IO Errno
- fuseInit :: IO ()
- fuseDestroy :: IO ()
- defaultFuseOps :: FuseOperations fh
- fuseMain :: Exception e => FuseOperations fh -> (e -> IO Errno) -> IO ()
- fuseRun :: String -> [String] -> Exception e => FuseOperations fh -> (e -> IO Errno) -> IO ()
- defaultExceptionHandler :: SomeException -> IO Errno
- data FileStat = FileStat {}
- data EntryType
- = Unknown
- | NamedPipe
- | CharacterSpecial
- | Directory
- | BlockSpecial
- | RegularFile
- | SymbolicLink
- | Socket
- data FileSystemStats = FileSystemStats {}
- data SyncType
- getFuseContext :: IO FuseContext
- data FuseContext
- entryTypeToFileMode :: EntryType -> FileMode
- fileModeToEntryType :: FileMode -> EntryType
- data OpenMode
- data OpenFileFlags = OpenFileFlags {}
- intersectFileModes :: FileMode -> FileMode -> FileMode
- unionFileModes :: FileMode -> FileMode -> FileMode
Using FUSE
FuseOperations
contains a field for each filesystem operations that can be called
by FUSE. Think like if you were implementing a file system inside the Linux kernel.
Each actions must return a POSIX error code, also called Errno
reflecting
operation result. For actions not using Either
, you should return eOK
in case
of success.
Read and writes are done with Haskell ByteString
type.
module Foreign.C.Error
data FuseOperations fh Source
This record, given to fuseMain
, binds each required file system
operations.
Each field is named against Posix
names. Matching Linux system
calls are also given as a reference.
fh
is the file handle type returned by fuseOpen
and subsequently passed
to all other file operations.
FuseOperations | |
|
defaultFuseOps :: FuseOperations fhSource
Empty / default versions of the FUSE operations.
fuseMain :: Exception e => FuseOperations fh -> (e -> IO Errno) -> IO ()Source
Main function of FUSE.
This is all that has to be called from the main
function. On top of
the FuseOperations
record with filesystem implementation, you must give
an exception handler converting Haskell exceptions to Errno
.
This function does the following:
- parses command line options (
-d
,-s
and-h
) ; - passes all options after
--
to the fusermount program ; - mounts the filesystem by calling
fusermount
; - installs signal handlers for
keyboardSignal
,lostConnection
,softwareTermination
andopenEndedPipe
; - registers an exit handler to unmount the filesystem on program exit ;
- registers the operations ;
- calls FUSE event loop.
defaultExceptionHandler :: SomeException -> IO ErrnoSource
Default exception handler.
Print the exception on error output and returns eFAULT
.
Operations datatypes
Used by fuseGetFileStat
. Corresponds to struct stat
from stat.h
;
st_dev
, st_ino
and st_blksize
are omitted, since (from the libfuse
documentation): "the st_dev
and st_blksize
fields are ignored. The
st_ino
field is ignored except if the use_ino mount option is given."
TODO: at some point the inode field will probably be needed.
The Unix type of a node in the filesystem.
Unknown | Unknown entry type |
NamedPipe | |
CharacterSpecial | |
Directory | |
BlockSpecial | |
RegularFile | |
SymbolicLink | |
Socket |
data FileSystemStats Source
Type used by the fuseGetFileSystemStats
.
FileSystemStats | |
|
Used by fuseSynchronizeFile
and fuseSynchronizeDirectory
.
FUSE Context
getFuseContext :: IO FuseContextSource
Returns the context of the program doing the current FUSE call.
data FuseContext Source
Returned by getFuseContext
.
File modes
data OpenFileFlags
Correspond to some of the int flags from C's fcntl.h.
intersectFileModes :: FileMode -> FileMode -> FileMode
Combines two file modes into one that only contains modes that appear in both.
unionFileModes :: FileMode -> FileMode -> FileMode
Combines the two file modes into one that contains modes that appear in either.