FUSE API Functions

llfuse.init(ops, mountpoint, options=default_options)

Initialize and mount FUSE file system

ops has to be an instance of the Operations class (or another class defining the same methods).

args has to be a set of strings. default_options provides some reasonable defaults. It is recommended to use these options as a basis and add or remove options as necessary. For example:

my_opts = set(llfuse.default_options)
my_opts.add('allow_other')
my_opts.discard('default_permissions')
llfuse.init(ops, mountpoint, my_opts)

Valid options are listed under struct fuse_opt fuse_mount_opts[] (mount.c:82) and struct fuse_opt fuse_ll_opts[] (fuse_lowlevel_c:2626).

llfuse.main(workers=None, handle_signals=True)

Run FUSE main loop

workers specifies the number of threads that will process requests concurrently. If workers is None, llfuse will pick a reasonable number bigger than one. If workers is 1 all requests will be processed by the thread calling main.

This function will also start additional threads for internal purposes (even if workers is 1). These (and all worker threads) are guaranteed to have terminated when main returns.

Unless handle_signals is False, while this function is running, special signal handlers will be installed for the SIGTERM, SIGINT (Ctrl-C), SIGHUP, SIGUSR1 and SIGPIPE signals. SIGPIPE will be ignored, while the other three signals will cause request processing to stop and the function to return. SIGINT (Ctrl-C) will thus not result in a KeyboardInterrupt exception while this function is runnning. Note setting handle_signals to False means you must handle the signals by yourself and call stop to make the main returns.

When the function returns because the file system has received an unmount request it will return None. If it returns because it has received a signal, it will return the signal number.

llfuse.close(unmount=True)

Clean up and ensure filesystem is unmounted

If unmount is False, only clean up operations are peformed, but the file system is not explicitly unmounted.

Normally, the filesystem is unmounted by the user calling umount(8) or fusermount(1), which then terminates the FUSE main loop. However, the loop may also terminate as a result of an exception or a signal. In this case the filesystem remains mounted, but any attempt to access it will block (while the filesystem process is still running) or (after the filesystem process has terminated) return an error. If unmount is True, this function will ensure that the filesystem is properly unmounted.

Note: if the connection to the kernel is terminated via the /sys/fs/fuse/connections/ interface, this function will not unmount the filesystem even if unmount is True.

llfuse.invalidate_inode(fuse_ino_t inode, attr_only=False)

Invalidate cache for inode

Instructs the FUSE kernel module to forgot cached attributes and data (unless attr_only is True) for inode. This operation is carried out asynchronously, i.e. the method may return before the kernel has executed the request.

llfuse.invalidate_entry(fuse_ino_t inode_p, name)

Invalidate directory entry

Instructs the FUSE kernel module to forget about the directory entry name in the directory with inode inode_p. This operation is carried out asynchronously, i.e. the method may return before the kernel has executed the request.

llfuse.notify_store(inode, offset, data)

Store data in kernel page cache

Sends data for the kernel to store it in the page cache for inode at offset. If this provides data beyond the current file size, the file is automatically extended.

If this function raises an exception, the store may still have completed partially.

llfuse.get_ino_t_bits()

Return number of bits available for inode numbers

Attempts to use inode values that need more bytes will result in OverflowError.

llfuse.get_off_t_bits()

Return number of bytes available for file offsets

Attempts to use values whose representation needs more bytes will result in OverflowError.