easyfuse.operations¶
This module implements the class that deals with operations from llfuse.
-
class
Operations
(dir_class=<class 'easyfuse.filesystem.Directory'>, filesystem=None, *args, *, autosync_delay=3, **kwargs)[source]¶ Bases:
llfuse.Operations
The class that implements all file operations.
Full descriptions of what the operations should do are shown at the
llfuse.Operations
documentation.Most methods have a
fh
orinode
argument. Currently these are the same.Parameters: - dir_class (
Directory
) – The class that represents directories. This defaults toDirectory
. - filesystem (
dict
or dictlike) – This stores the mapping from an inode number to aFile
orDirectory
object. It defaults to{}
as this is fine in most cases. For performance a class could be used that has a dict like interface to another storage option, such as a database. - autosync_delay (
int
orfloat
) – Automatically sync all dirty files after nowrite
has occured for this amount of seconds. If this is set toNone
, autosync will be disabled.
-
start_autosync_timer
()[source]¶ Start an autosync timer and cancel previously enabled ones.
This is done by calling
fsyncdir
on thellfuse.ROOT_INODE
.
-
destroy
()[source]¶ Execute all pending operations before unmount.
This currently calls
cancel_autosync_timer
and and does afullsync
.
-
getattr
(inode, ctx=None)[source]¶ Basic gettatr method.
Returns: The entry associated with the inode. Return type: BaseEntry
-
readdir
(fh, offset)[source]¶ A basic implementation
llfuse.Operations.readdir
method.
-
lookup
(parent_inode, name, ctx=None)[source]¶ A basic implementation
llfuse.Operations.lookup
method.This currently does not do anything special for the
ROOT_INODE
, but it seems to work anyway.
-
access
(inode, mode, ctx=None)[source]¶ Let everybody access everything.
TODO: Maybe implement access rights.
-
open
(inode, flags, ctx=None)[source]¶ Return a filehandler equal to the inode.
TODO: Decide if something needs to be done with the flags
-
mkdir
(parent_inode, name, mode, ctx)[source]¶ A basic implementation of the
llfuse.Operations.mkdir
method.It uses the
dir_class
argument passed to__init__
.
-
create
(parent_inode, name, mode, flags, ctx=None)[source]¶ A basic implementation of the
llfuse.Operations.create
method.This method uses
illegal_filename
andget_file_class
.
-
illegal_filename
(name)[source]¶ Return True if filename is illegal.
By default all filenames are accepted. This method should be overridden when this is not the case.
-
get_file_class
(name)[source]¶ Return the correct file class based on the filename.
This can be used to use different clasess for different filenames. By default it returns
File
-
read
(fh, offset, length)[source]¶ A basic implementation of the
llfuse.Operations.read
method.It reads bytes from the
content
attribute of the selectedFile
.
-
setattr
(inode, attr, fields, fh, ctx=None)[source]¶ A basic implementation of the
llfuse.Operations.setattr
method.It currently only supports changing the size of the file.
-
write
(inode, offset, buf)[source]¶ A basic implementation of the
llfuse.Operations.write
method.
-
unlink
(parent_inode, name, ctx=None)[source]¶ A basic implementation of the
llfuse.Operations.unlink
method.This removes files.
-
rmdir
(parent_inode, name, ctx=None)[source]¶ A basic implementation of the
llfuse.Operations.rmdir
method.
-
fsync
(fh, datasync)[source]¶ A basic implementation of the
llfuse.Operations.fsync
method.
-
forget
(inode_list)[source]¶ A basic implementation of the
llfuse.Operations.forget
method.
- dir_class (