Request Handlers¶
(You can use the Index to directly jump to a specific handler).
-
class
llfuse.Operations¶ This class defines the general and request handler methods that an Python-LLFUSE file system may implement. If a particular request handler has not been implemented, it must raise
FUSEErrorwith an errorcode oferrno.ENOSYS. Further requests of this type will then be handled directly by the FUSE kernel module without calling the handler again.It is recommended that file systems are derived from this class and only overwrite the handlers that they actually implement. (The default implementations defined in this class all just raise the not-implemented exception).
The only exception that request handlers are allowed to raise is
FUSEError. This will cause the specified errno to be returned by the syscall that is being handled.Note that all character data (directory entry names, extended attribute names and values, symbolic link targets etc) are passed as
bytesand must be returned asbytes. This applies to both running under Python 2.x and 3.x-
access(inode, mode, ctx)¶ Check if requesting process has mode rights on inode.
ctx will be a
RequestContextinstance. The method must return a boolean value.If the
default_permissionsmount option is given, this method is not called.
-
create(inode_parent, name, mode, flags, ctx)¶ Create a file with permissions mode and open it with flags
ctx will be a
RequestContextinstance.The method must return a tuple of the form (fh, attr), where fh is a file handle like the one returned by
openand attr is anEntryAttributesinstance with the attributes of the newly created directory entry.Once an inode has been returned by
lookup,create,symlink,link,mknodormkdir, it must be kept by the file system until it receives aforgetrequest for the inode. Ifunlinkorrmdirrequests are received prior to theforgetcall, they are expect to remove only the directory entry for the inode and defer removal of the inode itself until theforgetcall.
-
destroy()¶ Clean up operations.
This method will be called when
llfuse.closehas been called and the file system is about to be unmounted.Since this handler is thus not run as part of the main loop, it is also not called with the global lock acquired (unless the caller of
llfuse.closealready holds the lock).This method must not raise any exceptions (including
FUSEError, since this method is not handling a particular syscall).
-
flush(fh)¶ Handle close() syscall.
This method is called whenever a file descriptor is closed. It may be called multiple times for the same open file (e.g. if the file handle has been duplicated).
If the file system implements locking, this method must clear all locks belonging to the file handle’s owner.
-
forget(inode_list)¶ Notify about inodes being removed from the kernel cache
inode_list is a list of
(inode, nlookup)tuples. This method is called when the kernel removes the listed inodes from its internal caches. nlookup is the number of times that the inode has been looked up by calling either of thelookup,create,symlink,mknod,linkormkdirmethods.The file system is expected to keep track of the number of times an inode has been looked up and forgotten. No request handlers other than
lookupwill be called for an inode with a lookup count of zero.If the lookup count reaches zero after a call to
forget, the file system is expected to check if there are still directory entries referring to this inode and, if not, delete the inode itself.If the file system is unmounted, it will may not receive
forgetcalls for inodes that are still cached. Thedestroymethod may be used to clean up any remaining inodes for which noforgetcall has been received.
-
fsync(fh, datasync)¶ Flush buffers for open file fh
If datasync is true, only the file contents should be flushed (in contrast to the metadata about the file).
-
fsyncdir(fh, datasync)¶ Flush buffers for open directory fh
If datasync is true, only the directory contents should be flushed (in contrast to metadata about the directory itself).
-
getattr(inode)¶ Get attributes for inode
This method should return an
EntryAttributesinstance with the attributes of inode. Theentry_timeoutattribute is ignored in this context.
-
getxattr(inode, name)¶ Return extended attribute value
If the attribute does not exist, the method must raise
FUSEErrorwith an error code ofENOATTR.
-
init()¶ Initialize operations
This function will be called just before the file system starts handling requests. It must not raise any exceptions (including
FUSEError, since this method is not handling a particular syscall).
-
link(inode, new_parent_inode, new_name)¶ Create a hard link.
The method must return an
EntryAttributesinstance with the attributes of the newly created directory entry.Once an inode has been returned by
lookup,create,symlink,link,mknodormkdir, it must be kept by the file system until it receives aforgetrequest for the inode. Ifunlinkorrmdirrequests are received prior to theforgetcall, they are expect to remove only the directory entry for the inode and defer removal of the inode itself until theforgetcall.
-
listxattr(inode)¶ Get list of extended attribute names
-
lookup(parent_inode, name)¶ Look up a directory entry by name and get its attributes.
If the entry name does not exist in the directory with inode parent_inode, this method must raise
FUSEErrorwith an errno oferrno.ENOENT. Otherwise it must return anEntryAttributesinstance.Once an inode has been returned by
lookup,create,symlink,link,mknodormkdir, it must be kept by the file system until it receives aforgetrequest for the inode. Ifunlinkorrmdirrequests are received prior to theforgetcall, they are expect to remove only the directory entry for the inode and defer removal of the inode itself until theforgetcall.The file system must be able to handle lookups for
.and.., no matter if these entries are returned byreaddiror not.
-
mkdir(parent_inode, name, mode, ctx)¶ Create a directory
ctx will be a
RequestContextinstance. The method must return anEntryAttributesinstance with the attributes of the newly created directory entry.Once an inode has been returned by
lookup,create,symlink,link,mknodormkdir, it must be kept by the file system until it receives aforgetrequest for the inode. Ifunlinkorrmdirrequests are received prior to theforgetcall, they are expect to remove only the directory entry for the inode and defer removal of the inode itself until theforgetcall.
-
mknod(parent_inode, name, mode, rdev, ctx)¶ Create (possibly special) file
ctx will be a
RequestContextinstance. The method must return anEntryAttributesinstance with the attributes of the newly created directory entry.Once an inode has been returned by
lookup,create,symlink,link,mknodormkdir, it must be kept by the file system until it receives aforgetrequest for the inode. Ifunlinkorrmdirrequests are received prior to theforgetcall, they are expect to remove only the directory entry for the inode and defer removal of the inode itself until theforgetcall.
-
open(inode, flags)¶ Open a file.
flags will be a bitwise or of the open flags described in the open(2) manpage and defined in the
osmodule (with the exception ofO_CREAT,O_EXCL,O_NOCTTYandO_TRUNC)This method should return an integer file handle. The file handle will be passed to the
read,write,flush,fsyncandreleasemethods to identify the open file.
-
opendir(inode)¶ Open a directory.
This method should return an integer file handle. The file handle will be passed to the
readdir,fsyncdirandreleasedirmethods to identify the directory.
-
read(fh, off, size)¶ Read size bytes from fh at position off
This function should return exactly the number of bytes requested except on EOF or error, otherwise the rest of the data will be substituted with zeroes.
-
readdir(fh, off)¶ Read directory entries
This method should return an iterator over the contents of directory fh, starting at the entry identified by off. Directory entries must be of type
bytes.The iterator must yield tuples of the form
(name, attr, next_), where attr is anEntryAttributesinstance and next_ gives an offset that can be passed as off to start a successivereaddircall at the right position.Iteration may be stopped as soon as enough elements have been retrieved. The method should be prepared for this case.
If entries are added or removed during a
readdircycle, they may or may not be returned. However, they must not cause other entries to be skipped or returned more than once..and..entries may be included but are not required.
-
release(fh)¶ Release open file
This method will be called when the last file descriptor of fh has been closed. Therefore it will be called exactly once for each
opencall.
-
releasedir(fh)¶ Release open directory
This method must be called exactly once for each
opendircall.
-
removexattr(inode, name)¶ Remove extended attribute
If the attribute does not exist, the method must raise
FUSEErrorwith an error code ofENOATTR.
-
rename(inode_parent_old, name_old, inode_parent_new, name_new)¶ Rename a directory entry
If name_new already exists, it should be overwritten.
If the file system has received a
lookup, but noforgetcall for the file that is about to be overwritten,renameis expected to only overwrite the directory entry and defer removal of the old inode with the its contents and metadata until theforgetcall is received.
-
rmdir(inode_parent, name)¶ Remove a directory
If the file system has received a
lookup, but noforgetcall for this file yet,unlinkis expected to remove only the directory entry and defer removal of the inode with the actual file contents and metadata until theforgetcall is received.
-
setattr(inode, attr)¶ Change attributes of inode
attr is an
EntryAttributesinstance with the new attributes. Only the attributesst_size,st_mode,st_uid,st_gid,st_atimeandst_mtimeare relevant. Unchanged attributes will have a valueNone.The method should return a new
EntryAttributesinstance with the updated attributes (i.e., all attributes except forentry_timeoutshould be set).
-
setxattr(inode, name, value)¶ Set an extended attribute.
The attribute may or may not exist already.
-
stacktrace()¶ Asynchronous debugging
This method will be called when the
fuse_stacktraceextended attribute is set on the mountpoint. It will be called without holding the global lock. The default implementation logs the current stack trace of every running Python thread. This can be quite useful to debug file system deadlocks.
-
statfs()¶ Get file system statistics
The method is expected to return an appropriately filled
StatvfsDatainstance.
-
symlink(inode_parent, name, target, ctx)¶ Create a symbolic link
ctx will be a
RequestContextinstance. The method must return anEntryAttributesinstance with the attributes of the newly created directory entry.Once an inode has been returned by
lookup,create,symlink,link,mknodormkdir, it must be kept by the file system until it receives aforgetrequest for the inode. Ifunlinkorrmdirrequests are received prior to theforgetcall, they are expect to remove only the directory entry for the inode and defer removal of the inode itself until theforgetcall.
-
unlink(parent_inode, name)¶ Remove a (possibly special) file
If the file system has received a
lookup, but noforgetcall for this file yet,unlinkis expected to remove only the directory entry and defer removal of the inode with the actual file contents and metadata until theforgetcall is received.Note that an unlinked file may also appear again if it gets a new directory entry by the
linkmethod.
-
write(fh, off, buf)¶ Write buf into fh at off
This method should return the number of bytes written. If no error occured, this should be exactly
len(buf).
-