libfuse: fuse-3.18.2/include/fuse_lowlevel.h File Reference

libfuse

Data Structures | Macros | Typedefs | Enumerations | Functions
fuse_lowlevel.h File Reference
`#include "fuse_common.h"`
`#include <stddef.h>`
`#include <utime.h>`
`#include <fcntl.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <sys/statvfs.h>`
`#include <sys/uio.h>`

Go to the source code of this file.

## Data Structures
struct | fuse_entry_param
struct | fuse_ctx
struct | fuse_lowlevel_ops
struct | fuse_cmdline_opts

## Macros
#define | FUSE_ROOT_ID 1

## Typedefs
typedef uint64_t | fuse_ino_t
typedef struct fuse_req * | fuse_req_t
typedef void(* | fuse_interrupt_func_t) (fuse_req_t req, void *data)

## Enumerations
enum | fuse_notify_entry_flags

## Functions
int | fuse_reply_err (fuse_req_t req, int err)
void | fuse_reply_none (fuse_req_t req)
int | fuse_reply_entry (fuse_req_t req, const struct fuse_entry_param *e)
int | fuse_reply_create (fuse_req_t req, const struct fuse_entry_param *e, const struct fuse_file_info *fi)
int | fuse_reply_attr (fuse_req_t req, const struct stat *attr, double attr_timeout)
int | fuse_reply_readlink (fuse_req_t req, const char *link)
int | fuse_passthrough_open (fuse_req_t req, int fd)
int | fuse_reply_open (fuse_req_t req, const struct fuse_file_info *fi)
int | fuse_reply_write (fuse_req_t req, size_t count)
int | fuse_reply_buf (fuse_req_t req, const char *buf, size_t size)
int | fuse_reply_data (fuse_req_t req, struct fuse_bufvec *bufv, enum fuse_buf_copy_flags flags)
int | fuse_reply_iov (fuse_req_t req, const struct iovec *iov, int count)
int | fuse_reply_statfs (fuse_req_t req, const struct statvfs *stbuf)
int | fuse_reply_xattr (fuse_req_t req, size_t count)
int | fuse_reply_lock (fuse_req_t req, const struct flock *lock)
int | fuse_reply_bmap (fuse_req_t req, uint64_t idx)
size_t | fuse_add_direntry (fuse_req_t req, char *buf, size_t bufsize, const char *name, const struct stat *stbuf, off_t off)
size_t | fuse_add_direntry_plus (fuse_req_t req, char *buf, size_t bufsize, const char *name, const struct fuse_entry_param *e, off_t off)
int | fuse_reply_ioctl_retry (fuse_req_t req, const struct iovec *in_iov, size_t in_count, const struct iovec *out_iov, size_t out_count)
int | fuse_reply_ioctl (fuse_req_t req, int result, const void *buf, size_t size)
int | fuse_reply_ioctl_iov (fuse_req_t req, int result, const struct iovec *iov, int count)
int | fuse_reply_poll (fuse_req_t req, unsigned revents)
int | fuse_reply_lseek (fuse_req_t req, off_t off)
int | fuse_reply_statx (fuse_req_t req, int flags, struct statx *statx, double attr_timeout)
int | fuse_lowlevel_notify_poll (struct fuse_pollhandle *ph)
int | fuse_lowlevel_notify_inval_inode (struct fuse_session *se, fuse_ino_t ino, off_t off, off_t len)
int | fuse_lowlevel_notify_increment_epoch (struct fuse_session *se)
int | fuse_lowlevel_notify_inval_entry (struct fuse_session *se, fuse_ino_t parent, const char *name, size_t namelen)
int | fuse_lowlevel_notify_expire_entry (struct fuse_session *se, fuse_ino_t parent, const char *name, size_t namelen)
int | fuse_lowlevel_notify_delete (struct fuse_session *se, fuse_ino_t parent, fuse_ino_t child, const char *name, size_t namelen)
int | fuse_lowlevel_notify_store (struct fuse_session *se, fuse_ino_t ino, off_t offset, struct fuse_bufvec *bufv, enum fuse_buf_copy_flags flags)
int | fuse_lowlevel_notify_retrieve (struct fuse_session *se, fuse_ino_t ino, size_t size, off_t offset, void *cookie)
void * | fuse_req_userdata (fuse_req_t req)
const struct fuse_ctx * | fuse_req_ctx (fuse_req_t req)
int | fuse_req_getgroups (fuse_req_t req, int size, gid_t list[])
void | fuse_req_interrupt_func (fuse_req_t req, fuse_interrupt_func_t func, void *data)
int | fuse_req_interrupted (fuse_req_t req)
void | fuse_lowlevel_version (void)
void | fuse_lowlevel_help (void)
void | fuse_cmdline_help (void)
int | fuse_parse_cmdline_30 (struct fuse_args *args, struct fuse_cmdline_opts *opts)
int | fuse_session_mount (struct fuse_session *se, const char *mountpoint)
int | fuse_session_loop (struct fuse_session *se)
void | fuse_session_exit (struct fuse_session *se)
void | fuse_session_reset (struct fuse_session *se)
int | fuse_session_exited (struct fuse_session *se)
void | fuse_session_unmount (struct fuse_session *se)
void | fuse_session_destroy (struct fuse_session *se)
int | fuse_session_fd (struct fuse_session *se)
void | fuse_session_process_buf (struct fuse_session *se, const struct fuse_buf *buf)
int | fuse_session_receive_buf (struct fuse_session *se, struct fuse_buf *buf)
bool | fuse_req_is_uring (fuse_req_t req)
int | fuse_req_get_payload (fuse_req_t req, char **payload, size_t *payload_sz, void **mr)

## Detailed Description

Low level API

IMPORTANT: you should define FUSE_USE_VERSION before including this header. To use the newest API define it to 35 (recommended for any new application).

Definition in file fuse_lowlevel.h.

## Macro Definition Documentation

## ◆ FUSE_ROOT_ID

#define FUSE_ROOT_ID 1

The node ID of the root inode

Definition at line 44 of file fuse_lowlevel.h.

## Typedef Documentation

## ◆ fuse_ino_t

typedef uint64_t fuse_ino_t

Inode number type

Definition at line 47 of file fuse_lowlevel.h.

## ◆ fuse_interrupt_func_t

typedef void(* fuse_interrupt_func_t) (fuse_req_t req, void *data)

Callback function for an interrupt

Parameters

  req | interrupted request
  data | user data

Definition at line 1992 of file fuse_lowlevel.h.

## ◆ fuse_req_t

typedef struct fuse_req* fuse_req_t

Request pointer type

Definition at line 50 of file fuse_lowlevel.h.

## Enumeration Type Documentation

## ◆ fuse_notify_entry_flags

enum fuse_notify_entry_flags

Flags for fuse_lowlevel_notify_entry() 0 = invalidate entry FUSE_LL_EXPIRE_ONLY = expire entry

Definition at line 151 of file fuse_lowlevel.h.

## Function Documentation

## ◆ fuse_add_direntry()

size_t fuse_add_direntry | ( | fuse_req_t | req,
|  | char * | buf,
|  | size_t | bufsize,
|  | const char * | name,
|  | const struct stat * | stbuf,
|  | off_t | off
| ) |  |

Add a directory entry to the buffer

Buffer needs to be large enough to hold the entry. If it's not, then the entry is not filled in but the size of the entry is still returned. The caller can check this by comparing the bufsize parameter with the returned entry size. If the entry size is larger than the buffer size, the operation failed.

From the 'stbuf' argument the st_ino field and bits 12-15 of the st_mode field are used. The other fields are ignored.

off should be any non-zero value that the filesystem can use to identify the current point in the directory stream. It does not need to be the actual physical position. A value of zero is reserved to mean "from the beginning", and should therefore never be used (the first call to fuse_add_direntry should be passed the offset of the second directory entry).

Parameters

  req | request handle
  buf | the point where the new entry will be added to the buffer
  bufsize | remaining size of the buffer
  name | the name of the entry
  stbuf | the file attributes
  off | the offset of the next entry

Returns
  the space needed for the entry

Definition at line 286 of file fuse_lowlevel.c.

## ◆ fuse_add_direntry_plus()

size_t fuse_add_direntry_plus | ( | fuse_req_t | req,
|  | char * | buf,
|  | size_t | bufsize,
|  | const char * | name,
|  | const struct fuse_entry_param * | e,
|  | off_t | off
| ) |  |

Add a directory entry to the buffer with the attributes

See documentation of `fuse_add_direntry()` for more details.

Parameters

  req | request handle
  buf | the point where the new entry will be added to the buffer
  bufsize | remaining size of the buffer
  name | the name of the entry
  e | the directory entry
  off | the offset of the next entry

Returns
  the space needed for the entry

Definition at line 376 of file fuse_lowlevel.c.

## ◆ fuse_cmdline_help()

void fuse_cmdline_help | ( | void |  | ) |

Print available options for `fuse_parse_cmdline()`.

Definition at line 130 of file helper.c.

## ◆ fuse_lowlevel_help()

void fuse_lowlevel_help | ( | void |  | ) |

Print available low-level options to stdout. This is not an exhaustive list, but includes only those options that may be of interest to an end-user of a file system.

Definition at line 3000 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_notify_delete()

int fuse_lowlevel_notify_delete | ( | struct fuse_session * | se,
|  | fuse_ino_t | parent,
|  | fuse_ino_t | child,
|  | const char * | name,
|  | size_t | namelen
| ) |  |

This function behaves like fuse_lowlevel_notify_inval_entry() with the following additional effect (at least as of Linux kernel 4.8):

If the provided child inode matches the inode that is currently associated with the cached dentry, and if there are any inotify watches registered for the dentry, then the watchers are informed that the dentry has been deleted.

To avoid a deadlock this function must not be called while executing a related filesystem operation or while holding a lock that could be needed to execute such an operation (see the description of fuse_lowlevel_notify_inval_entry() for more details).

When called correctly, this function will never block.

Added in FUSE protocol version 7.18. If the kernel does not support this (or a newer) version, the function will return -ENOSYS and do nothing.

Parameters

  se | the session object
  parent | inode number
  child | inode number
  name | file name
  namelen | strlen() of file name

Returns
  zero for success, -errno for failure

Definition at line 2562 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_notify_expire_entry()

int fuse_lowlevel_notify_expire_entry | ( | struct fuse_session * | se,
|  | fuse_ino_t | parent,
|  | const char * | name,
|  | size_t | namelen
| ) |  |

Notify to expire parent attributes and the dentry matching parent/name

Same restrictions apply as for fuse_lowlevel_notify_inval_entry()

Compared to invalidating an entry, expiring the entry results not in a forceful removal of that entry from kernel cache but instead the next access to it forces a lookup from the filesystem.

This makes a difference for overmounted dentries, where plain invalidation would detach all submounts before dropping the dentry from the cache. If only expiry is set on the dentry, then any overmounts are left alone and until ->d_revalidate() is called.

Note: ->d_revalidate() is not called for the case of following a submount, so invalidation will only be triggered for the non-overmounted case. The dentry could also be mounted in a different mount instance, in which case any submounts will still be detached.

Added in FUSE protocol version 7.38. If the kernel does not support this (or a newer) version, the function will return -ENOSYS and do nothing.

Parameters

  se | the session object
  parent | inode number
  name | file name
  namelen | strlen() of file name

Returns
  zero for success, -errno for failure, -enosys if no kernel support

Definition at line 2549 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_notify_increment_epoch()

int fuse_lowlevel_notify_increment_epoch | ( | struct fuse_session * | se | ) |

Notify to increment the epoch for the current

Each fuse connection has an 'epoch', which is initialized during INIT. Caching will then be validated against the epoch value: if the current epoch is higher than an object being revalidated, the object is invalid.

This function simply increment the current epoch value.

Parameters

  se | the session object

Returns
  zero for success, -errno for failure

Definition at line 3116 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_notify_inval_entry()

int fuse_lowlevel_notify_inval_entry | ( | struct fuse_session * | se,
|  | fuse_ino_t | parent,
|  | const char * | name,
|  | size_t | namelen
| ) |  |

Notify to invalidate parent attributes and the dentry matching parent/name

To avoid a deadlock this function must not be called in the execution path of a related filesystem operation or within any code that could hold a lock that could be needed to execute such an operation. As of kernel 4.18, a "related operation" is a lookup(), symlink(), mknod(), mkdir(), unlink(), rename(), link() or create() request for the parent, and a setattr(), unlink(), rmdir(), rename(), setxattr(), removexattr(), readdir() or readdirplus() request for the inode itself.

When called correctly, this function will never block.

Added in FUSE protocol version 7.12. If the kernel does not support this (or a newer) version, the function will return -ENOSYS and do nothing.

Parameters

  se | the session object
  parent | inode number
  name | file name
  namelen | strlen() of file name

Returns
  zero for success, -errno for failure

Definition at line 2543 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_notify_inval_inode()

int fuse_lowlevel_notify_inval_inode | ( | struct fuse_session * | se,
|  | fuse_ino_t | ino,
|  | off_t | off,
|  | off_t | len
| ) |  |

Notify to invalidate cache for an inode.

Added in FUSE protocol version 7.12. If the kernel does not support this (or a newer) version, the function will return -ENOSYS and do nothing.

If the filesystem has writeback caching enabled, invalidating an inode will first trigger a writeback of all dirty pages. The call will block until all writeback requests have completed and the inode has been invalidated. It will, however, not wait for completion of pending writeback requests that have been issued before.

If there are no dirty pages, this function will never block.

Parameters

  se | the session object
  ino | the inode number
  off | the offset in the inode where to start invalidating or negative to invalidate attributes only
  len | the amount of cache to invalidate or 0 for all

Returns
  zero for success, -errno for failure

Definition at line 2475 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_notify_poll()

int fuse_lowlevel_notify_poll | ( | struct fuse_pollhandle * | ph | ) |

Notify IO readiness event

For more information, please read comment for poll operation.

Parameters

  ph | poll handle to notify IO readiness event for

Definition at line 2458 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_notify_retrieve()

int fuse_lowlevel_notify_retrieve | ( | struct fuse_session * | se,
|  | fuse_ino_t | ino,
|  | size_t | size,
|  | off_t | offset,
|  | void * | cookie
| ) |  |

Retrieve data from the kernel buffers

Retrieve data in the kernel buffers belonging to the given inode. If successful then the retrieve_reply() method will be called with the returned data.

Only present pages are returned in the retrieve reply. Retrieving stops when it finds a non-present page and only data prior to that is returned.

If this function returns an error, then the retrieve will not be completed and no reply will be sent.

This function doesn't change the dirty state of pages in the kernel buffer. For dirty pages the write() method will be called regardless of having been retrieved previously.

Added in FUSE protocol version 7.15. If the kernel does not support this (or a newer) version, the function will return -ENOSYS and do nothing.

Parameters

  se | the session object
  ino | the inode number
  size | the number of bytes to retrieve
  offset | the starting offset into the file to retrieve from
  cookie | user data to supply to the reply callback

Returns
  zero for success, -errno for failure

Definition at line 2668 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_notify_store()

int fuse_lowlevel_notify_store | ( | struct fuse_session * | se,
|  | fuse_ino_t | ino,
|  | off_t | offset,
|  | struct fuse_bufvec * | bufv,
|  | enum fuse_buf_copy_flags | flags
| ) |  |

Store data to the kernel buffers

Synchronously store data in the kernel buffers belonging to the given inode. The stored data is marked up-to-date (no read will be performed against it, unless it's invalidated or evicted from the cache).

If the stored data overflows the current file size, then the size is extended, similarly to a write(2) on the filesystem.

If this function returns an error, then the store wasn't fully completed, but it may have been partially completed.

Added in FUSE protocol version 7.15. If the kernel does not support this (or a newer) version, the function will return -ENOSYS and do nothing.

Parameters

  se | the session object
  ino | the inode number
  offset | the starting offset into the file to store to
  bufv | buffer vector
  flags | flags controlling the copy

Returns
  zero for success, -errno for failure

Definition at line 2588 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_version()

void fuse_lowlevel_version | ( | void |  | ) |

Print low-level version information to stdout.

Definition at line 2993 of file fuse_lowlevel.c.

## ◆ fuse_parse_cmdline_30()

int fuse_parse_cmdline_30 | ( | struct fuse_args * | args,
|  | struct fuse_cmdline_opts * | opts
| ) |  |

Utility function to parse common options for simple file systems using the low-level API. A help text that describes the available options can be printed with `fuse_cmdline_help`. A single non-option argument is treated as the mountpoint. Multiple non-option arguments will result in an error.

If neither -o subtype= or -o fsname= options are given, a new subtype option will be added and set to the basename of the program (the fsname will remain unset, and then defaults to "fuse").

Known options will be removed from args, unknown options will remain.

Parameters

  args | argument vector (input+output)
  opts | output argument for parsed options

Returns
  0 on success, -1 on failure

struct fuse_cmdline_opts got extended in libfuse-3.12

Definition at line 237 of file helper.c.

## ◆ fuse_passthrough_open()

int fuse_passthrough_open | ( | fuse_req_t | req,
|  | int | fd
| ) |  |

Setup passthrough backing file for open reply

Currently there should be only one backing id per node / backing file.

Possible requests: open, opendir, create

Parameters

  req | request handle
  fd | backing file descriptor

Returns
  positive backing id for success, 0 for failure

Definition at line 480 of file fuse_lowlevel.c.

## ◆ fuse_reply_attr()

int fuse_reply_attr | ( | fuse_req_t | req,
|  | const struct stat * | attr,
|  | double | attr_timeout
| ) |  |

Reply with attributes

Possible requests: getattr, setattr

Parameters

  req | request handle
  attr | the attributes
  attr_timeout | validity timeout (in seconds) for the attributes

Returns
  zero for success, -errno for failure to send reply

Definition at line 460 of file fuse_lowlevel.c.

## ◆ fuse_reply_bmap()

int fuse_reply_bmap | ( | fuse_req_t | req,
|  | uint64_t | idx
| ) |  |

Reply with block index

Possible requests: bmap

Parameters

  req | request handle
  idx | block index within device

Returns
  zero for success, -errno for failure to send reply

Definition at line 973 of file fuse_lowlevel.c.

## ◆ fuse_reply_buf()

int fuse_reply_buf | ( | fuse_req_t | req,
|  | const char * | buf,
|  | size_t | size
| ) |  |

Reply with data

Possible requests: read, readdir, getxattr, listxattr

Parameters

  req | request handle
  buf | buffer containing data
  size | the size of data in bytes

Returns
  zero for success, -errno for failure to send reply

Definition at line 524 of file fuse_lowlevel.c.

## ◆ fuse_reply_create()

int fuse_reply_create | ( | fuse_req_t | req,
|  | const struct fuse_entry_param * | e,
|  | const struct fuse_file_info * | fi
| ) |  |

Reply with a directory entry and open parameters

currently the following members of 'fi' are used: fh, direct_io, keep_cache, cache_readdir, nonseekable, noflush, parallel_direct_writes

Possible requests: create

Side effects: increments the lookup count on success

Parameters

  req | request handle
  e | the entry parameters
  fi | file information

Returns
  zero for success, -errno for failure to send reply

Definition at line 444 of file fuse_lowlevel.c.

## ◆ fuse_reply_data()

int fuse_reply_data | ( | fuse_req_t | req,
|  | struct fuse_bufvec * | bufv,
|  | enum fuse_buf_copy_flags | flags
| ) |  |

Reply with data copied/moved from buffer(s)

Zero copy data transfer ("splicing") will be used under the following circumstances:

1. FUSE_CAP_SPLICE_WRITE is set in fuse_conn_info.want, and
2. the kernel supports splicing from the fuse device (FUSE_CAP_SPLICE_WRITE is set in fuse_conn_info.capable), and
3. flags does not contain FUSE_BUF_NO_SPLICE
4. The amount of data that is provided in file-descriptor backed buffers (i.e., buffers for which bufv[n].flags == FUSE_BUF_FD) is at least twice the page size.

In order for SPLICE_F_MOVE to be used, the following additional conditions have to be fulfilled:

1. FUSE_CAP_SPLICE_MOVE is set in fuse_conn_info.want, and
2. the kernel supports it (i.e, FUSE_CAP_SPLICE_MOVE is set in fuse_conn_info.capable), and
3. flags contains FUSE_BUF_SPLICE_MOVE

Note that, if splice is used, the data is actually spliced twice: once into a temporary pipe (to prepend header data), and then again into the kernel. If some of the provided buffers are memory-backed, the data in them is copied in step one and spliced in step two.

The FUSE_BUF_SPLICE_FORCE_SPLICE and FUSE_BUF_SPLICE_NONBLOCK flags are silently ignored.

Possible requests: read, readdir, getxattr, listxattr

Side effects: when used to return data from a readdirplus() (but not readdir()) call, increments the lookup count of each returned entry by one on success.

Parameters

  req | request handle
  bufv | buffer vector
  flags | flags controlling the copy

Returns
  zero for success, -errno for failure to send reply

Definition at line 912 of file fuse_lowlevel.c.

## ◆ fuse_reply_entry()

int fuse_reply_entry | ( | fuse_req_t | req,
|  | const struct fuse_entry_param * | e
| ) |  |

Reply with a directory entry

Possible requests: lookup, mknod, mkdir, symlink, link

Side effects: increments the lookup count on success

Parameters

  req | request handle
  e | the entry parameters

Returns
  zero for success, -errno for failure to send reply

Definition at line 428 of file fuse_lowlevel.c.

## ◆ fuse_reply_err()

int fuse_reply_err | ( | fuse_req_t | req,
|  | int | err
| ) |  |

Reply with an error code or success.

Possible requests: all except forget, forget_multi, retrieve_reply

Wherever possible, error codes should be chosen from the list of documented error conditions in the corresponding system calls manpage.

An error code of ENOSYS is sometimes treated specially. This is indicated in the documentation of the affected handler functions.

The following requests may be answered with a zero error code: unlink, rmdir, rename, flush, release, fsync, fsyncdir, setxattr, removexattr, setlk.

Parameters

  req | request handle
  err | the positive error value, or zero for success

Returns
  zero for success, -errno for failure to send reply

Definition at line 331 of file fuse_lowlevel.c.

## ◆ fuse_reply_ioctl()

int fuse_reply_ioctl | ( | fuse_req_t | req,
|  | int | result,
|  | const void * | buf,
|  | size_t | size
| ) |  |

Reply to finish ioctl

Possible requests: ioctl

Parameters

  req | request handle
  result | result to be passed to the caller
  buf | buffer containing output data
  size | length of output data

Definition at line 1071 of file fuse_lowlevel.c.

## ◆ fuse_reply_ioctl_iov()

int fuse_reply_ioctl_iov | ( | fuse_req_t | req,
|  | int | result,
|  | const struct iovec * | iov,
|  | int | count
| ) |  |

Reply to finish ioctl with iov buffer

Possible requests: ioctl

Parameters

  req | request handle
  result | result to be passed to the caller
  iov | the vector containing the data
  count | the size of vector

Definition at line 1092 of file fuse_lowlevel.c.

## ◆ fuse_reply_ioctl_retry()

int fuse_reply_ioctl_retry | ( | fuse_req_t | req,
|  | const struct iovec * | in_iov,
|  | size_t | in_count,
|  | const struct iovec * | out_iov,
|  | size_t | out_count
| ) |  |

Reply to ask for data fetch and output buffer preparation. ioctl will be retried with the specified input data fetched and output buffer prepared.

Possible requests: ioctl

Parameters

  req | request handle
  in_iov | iovec specifying data to fetch from the caller
  in_count | number of entries in in_iov
  out_iov | iovec specifying addresses to write output to
  out_count | number of entries in out_iov

Returns
  zero for success, -errno for failure to send reply

Definition at line 1001 of file fuse_lowlevel.c.

## ◆ fuse_reply_iov()

int fuse_reply_iov | ( | fuse_req_t | req,
|  | const struct iovec * | iov,
|  | int | count
| ) |  |

Reply with data vector

Possible requests: read, readdir, getxattr, listxattr

Parameters

  req | request handle
  iov | the vector containing the data
  count | the size of vector

Returns
  zero for success, -errno for failure to send reply

Definition at line 265 of file fuse_lowlevel.c.

## ◆ fuse_reply_lock()

int fuse_reply_lock | ( | fuse_req_t | req,
|  | const struct flock * | lock
| ) |  |

Reply with file lock information

Possible requests: getlk

Parameters

  req | request handle
  lock | the lock information

Returns
  zero for success, -errno for failure to send reply

Definition at line 956 of file fuse_lowlevel.c.

## ◆ fuse_reply_lseek()

int fuse_reply_lseek | ( | fuse_req_t | req,
|  | off_t | off
| ) |  |

Reply with offset

Possible requests: lseek

Parameters

  req | request handle
  off | offset of next data or hole

Returns
  zero for success, -errno for failure to send reply

Definition at line 1126 of file fuse_lowlevel.c.

## ◆ fuse_reply_none()

void fuse_reply_none | ( | fuse_req_t | req | ) |

Don't send reply

Possible requests: forget forget_multi retrieve_reply

Parameters

  req | request handle

Definition at line 336 of file fuse_lowlevel.c.

## ◆ fuse_reply_open()

int fuse_reply_open | ( | fuse_req_t | req,
|  | const struct fuse_file_info * | fi
| ) |  |

Reply with open parameters

currently the following members of 'fi' are used: fh, direct_io, keep_cache, cache_readdir, nonseekable, noflush, parallel_direct_writes,

Possible requests: open, opendir

Parameters

  req | request handle
  fi | file information

Returns
  zero for success, -errno for failure to send reply

Definition at line 505 of file fuse_lowlevel.c.

## ◆ fuse_reply_poll()

int fuse_reply_poll | ( | fuse_req_t | req,
|  | unsigned | revents
| ) |  |

Reply with poll result event mask

Parameters

  req | request handle
  revents | poll result event mask

Definition at line 1116 of file fuse_lowlevel.c.

## ◆ fuse_reply_readlink()

int fuse_reply_readlink | ( | fuse_req_t | req,
|  | const char * | link
| ) |  |

Reply with the contents of a symbolic link

Possible requests: readlink

Parameters

  req | request handle
  link | symbolic link contents

Returns
  zero for success, -errno for failure to send reply

Definition at line 475 of file fuse_lowlevel.c.

## ◆ fuse_reply_statfs()

int fuse_reply_statfs | ( | fuse_req_t | req,
|  | const struct statvfs * | stbuf
| ) |  |

Reply with filesystem statistics

Possible requests: statfs

Parameters

  req | request handle
  stbuf | filesystem statistics

Returns
  zero for success, -errno for failure to send reply

Definition at line 934 of file fuse_lowlevel.c.

## ◆ fuse_reply_statx()

int fuse_reply_statx | ( | fuse_req_t | req,
|  | int | flags,
|  | struct statx * | statx,
|  | double | attr_timeout
| ) |  |

Reply with extended file attributes.

Possible requests: statx

Parameters

  req | request handle
  flags | statx flags
  statx | the attributes
  attr_timeout | validity timeout (in seconds) for the attributes

Returns
  zero for success, -errno for failure to send reply

Definition at line 1260 of file fuse_lowlevel.c.

## ◆ fuse_reply_write()

int fuse_reply_write | ( | fuse_req_t | req,
|  | size_t | count
| ) |  |

Reply with number of bytes written

Possible requests: write

Parameters

  req | request handle
  count | the number of bytes written

Returns
  zero for success, -errno for failure to send reply

Definition at line 514 of file fuse_lowlevel.c.

## ◆ fuse_reply_xattr()

int fuse_reply_xattr | ( | fuse_req_t | req,
|  | size_t | count
| ) |  |

Reply with needed buffer size

Possible requests: getxattr, listxattr

Parameters

  req | request handle
  count | the buffer size needed in bytes

Returns
  zero for success, -errno for failure to send reply

Definition at line 946 of file fuse_lowlevel.c.

## ◆ fuse_req_ctx()

const struct fuse_ctx * fuse_req_ctx | ( | fuse_req_t | req | ) |

Get the context from the request

The pointer returned by this function will only be valid for the request's lifetime

Parameters

  req | request handle

Returns
  the context structure

Definition at line 2718 of file fuse_lowlevel.c.

## ◆ fuse_req_get_payload()

int fuse_req_get_payload | ( | fuse_req_t | req,
|  | char ** | payload,
|  | size_t * | payload_sz,
|  | void ** | mr
| ) |  |

Get the payload of a request (for requests submitted through fuse-io-uring only)

This is useful for a file system that wants to write data directly to the request buffer. With io-uring the req is the buffer owner and the file system can write directly to the buffer and avoid extra copying. For example useful for network file systems.

Parameters

  req | the request
  payload | pointer to the payload
  payload_sz | size of the payload
  mr | memory registration handle, currently unused

Returns
  0 on success, -errno on failure

Definition at line 3386 of file fuse_lowlevel.c.

## ◆ fuse_req_getgroups()

int fuse_req_getgroups | ( | fuse_req_t | req,
|  | int | size,
|  | gid_t | list[]
| ) |  |

Get the current supplementary group IDs for the specified request

Similar to the getgroups(2) system call, except the return value is always the total number of group IDs, even if it is larger than the specified size.

The current fuse kernel module in linux (as of 2.6.30) doesn't pass the group list to userspace, hence this function needs to parse "/proc/$TID/task/$TID/status" to get the group IDs.

This feature may not be supported on all operating systems. In such a case this function will return -ENOSYS.

Parameters

  req | request handle
  size | size of given array
  list | array of group IDs to be filled in

Returns
  the total number of supplementary group IDs or -errno on failure

Definition at line 3614 of file fuse_lowlevel.c.

## ◆ fuse_req_interrupt_func()

void fuse_req_interrupt_func | ( | fuse_req_t | req,
|  | fuse_interrupt_func_t | func,
|  | void * | data
| ) |  |

Register/unregister callback for an interrupt

If an interrupt has already happened, then the callback function is called from within this function, hence it's not possible for interrupts to be lost.

Parameters

  req | request handle
  func | the callback function or NULL for unregister
  data | user data passed to the callback function

Definition at line 2723 of file fuse_lowlevel.c.

## ◆ fuse_req_interrupted()

int fuse_req_interrupted | ( | fuse_req_t | req | ) |

Check if a request has already been interrupted

Parameters

  req | request handle

Returns
  1 if the request has been interrupted, 0 otherwise

Definition at line 2736 of file fuse_lowlevel.c.

## ◆ fuse_req_is_uring()

bool fuse_req_is_uring | ( | fuse_req_t | req | ) |

Check if the request is submitted through fuse-io-uring

Definition at line 3380 of file fuse_lowlevel.c.

## ◆ fuse_req_userdata()

void * fuse_req_userdata | ( | fuse_req_t | req | ) |

Get the userdata from the request

Parameters

  req | request handle

Returns
  the user data passed to fuse_session_new()

Definition at line 2713 of file fuse_lowlevel.c.

## ◆ fuse_session_destroy()

void fuse_session_destroy | ( | struct fuse_session * | se | ) |

Destroy a session

Parameters

  se | the session

Definition at line 3010 of file fuse_lowlevel.c.

## ◆ fuse_session_exit()

void fuse_session_exit | ( | struct fuse_session * | se | ) |

Flag a session as terminated.

This will cause any running event loops to terminate on the next opportunity. If this function is called by a thread that is not a FUSE worker thread, the next opportunity will be when FUSE a request is received (which may be far in the future if the filesystem is not currently being used by any clients). One way to avoid this delay is to afterwards sent a signal to the main thread (if fuse_set_signal_handlers() is used, SIGPIPE will cause the main thread to wake-up but otherwise be ignored).

Parameters

  se | the session

## ◆ fuse_session_exited()

int fuse_session_exited | ( | struct fuse_session * | se | ) |

Query the terminated flag of a session

Parameters

  se | the session

Returns
  1 if exited, 0 if not exited

## ◆ fuse_session_fd()

int fuse_session_fd | ( | struct fuse_session * | se | ) |

Return file descriptor for communication with kernel.

The file selector can be used to integrate FUSE with a custom event loop. Whenever data is available for reading on the provided fd, the event loop should call `fuse_session_receive_buf` followed by `fuse_session_process_buf` to process the request.

The returned file descriptor is valid until `fuse_session_unmount` is called.

Parameters

  se | the session

Returns
  a file descriptor

Definition at line 3534 of file fuse_lowlevel.c.

## ◆ fuse_session_loop()

int fuse_session_loop | ( | struct fuse_session * | se | ) |

Enter a single threaded, blocking event loop.

When the event loop terminates because the connection to the FUSE kernel module has been closed, this function returns zero. This happens when the filesystem is unmounted regularly (by the filesystem owner or root running the umount(8) or fusermount(1) command), or if connection is explicitly severed by writing `1` to the`abort` file in `/sys/fs/fuse/connections/NNN`. The only way to distinguish between these two conditions is to check if the filesystem is still mounted after the session loop returns.

When some error occurs during request processing, the function returns a negated errno(3) value.

If the loop has been terminated because of a signal handler installed by fuse_set_signal_handlers(), this function returns the (positive) signal value that triggered the exit.

Parameters

  se | the session

Returns
  0, -errno, or a signal value

Definition at line 19 of file fuse_loop.c.

## ◆ fuse_session_mount()

int fuse_session_mount | ( | struct fuse_session * | se,
|  | const char * | mountpoint
| ) |  |

Mount a FUSE file system.

Parameters

  mountpoint | the mount point path
  se | session object

Returns
  0 on success, -1 on failure.

Definition at line 3473 of file fuse_lowlevel.c.

## ◆ fuse_session_process_buf()

void fuse_session_process_buf | ( | struct fuse_session * | se,
|  | const struct fuse_buf * | buf
| ) |  |

Process a raw request supplied in a generic buffer

The fuse_buf may contain a memory buffer or a pipe file descriptor.

Parameters

  se | the session
  buf | the fuse_buf containing the request

Definition at line 2830 of file fuse_lowlevel.c.

## ◆ fuse_session_receive_buf()

int fuse_session_receive_buf | ( | struct fuse_session * | se,
|  | struct fuse_buf * | buf
| ) |  |

Read a raw request from the kernel into the supplied buffer.

Depending on file system options, system capabilities, and request size the request is either read into a memory buffer or spliced into a temporary pipe.

Parameters

  se | the session
  buf | the fuse_buf to store the request in

Returns
  the actual size of the raw request, or -errno on error

Definition at line 3285 of file fuse_lowlevel.c.

## ◆ fuse_session_reset()

void fuse_session_reset | ( | struct fuse_session * | se | ) |

Reset the terminated flag of a session

Parameters

  se | the session

## ◆ fuse_session_unmount()

void fuse_session_unmount | ( | struct fuse_session * | se | ) |

Ensure that file system is unmounted.

In regular operation, the file system is typically unmounted by the user calling umount(8) or fusermount(1), which then terminates the FUSE session loop. However, the session loop may also terminate as a result of an explicit call to fuse_session_exit() (e.g. by a signal handler installed by fuse_set_signal_handler()). In this case the filesystem remains mounted, but any attempt to access it will block (while the filesystem process is still running) or give an ESHUTDOWN error (after the filesystem process has terminated).

If the communication channel with the FUSE kernel module is still open (i.e., if the session loop was terminated by an explicit call to fuse_session_exit()), this function will close it and unmount the filesystem. If the communication channel has been closed by the kernel, this method will do (almost) nothing.

NOTE: The above semantics mean that if the connection to the kernel is terminated via the `/sys/fs/fuse/connections/NNN/abort` file, this method will not unmount the filesystem.

Parameters

  se | the session

Definition at line 3539 of file fuse_lowlevel.c.