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 or inode argument. Currently these are the same.

Parameters:
  • dir_class (Directory) – The class that represents directories. This defaults to Directory.
  • filesystem (dict or dictlike) – This stores the mapping from an inode number to a File or Directory 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 or float) – Automatically sync all dirty files after no write has occured for this amount of seconds. If this is set to None, autosync will be disabled.
fullsync()[source]

Sync all dirty files using fsync.

start_autosync_timer()[source]

Start an autosync timer and cancel previously enabled ones.

This is done by calling fsyncdir on the llfuse.ROOT_INODE.

cancel_autosync_timer()[source]

Cancel a possibly initiated autosync timer.

destroy()[source]

Execute all pending operations before unmount.

This currently calls cancel_autosync_timer and and does a fullsync.

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.

opendir(inode, ctx=None)[source]

Return a filehandler equal to the requested inode.

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 and get_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 selected File.

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.

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.

fsyncdir(fh, datasync)[source]

Same as fsyncdir but for directories.

forget(inode_list)[source]

A basic implementation of the llfuse.Operations.forget method.