Utility Functions

The following functions do not necessarily translate to calls to the FUSE library. They are provided because they’re potentially useful when implementing file systems in Python.

pyfuse3.setxattr(path, name, value, namespace='user')

Set extended attribute

path and name have to be of type str. In Python 3.x, they may contain surrogates. value has to be of type bytes.

Under FreeBSD, the namespace parameter may be set to system or user to select the namespace for the extended attribute. For other platforms, this parameter is ignored.

In contrast to the os.setxattr function from the standard library, the method provided by pyfuse3 is also available for non-Linux systems.

pyfuse3.getxattr(path, name, size_t size_guess=128, namespace=u'user')

Get extended attribute

path and name have to be of type str. In Python 3.x, they may contain surrogates. Returns a value of type bytes.

If the caller knows the approximate size of the attribute value, it should be supplied in size_guess. If the guess turns out to be wrong, the system call has to be carried out three times (the first call will fail, the second determines the size and the third finally gets the value).

Under FreeBSD, the namespace parameter may be set to system or user to select the namespace for the extended attribute. For other platforms, this parameter is ignored.

In contrast to the os.getxattr function from the standard library, the method provided by pyfuse3 is also available for non-Linux systems.

pyfuse3.listdir(path)

Like os.listdir, but releases the GIL.

This function returns an iterator over the directory entries in path.

The returned values are of type str. Surrogate escape coding (cf. PEP 383) is used for directory names that do not have a string representation.

pyfuse3.get_sup_groups(pid)

Return supplementary group ids of pid

This function is relatively expensive because it has to read the group ids from /proc/[pid]/status. For the same reason, it will also not work on systems that do not provide a /proc file system.

Returns a set.

pyfuse3.syncfs(path)

Sync filesystem mounted at path

This is a Python interface to the syncfs(2) system call. There is no particular relation to libfuse, it is provided by pyfuse3 as a convience.