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_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_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)

## 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 1946 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 148 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 289 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 379 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 2957 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 2519 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 2506 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 2500 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 2432 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 2415 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 2625 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 2545 of file fuse_lowlevel.c.

## ◆ fuse_lowlevel_version()

void fuse_lowlevel_version | ( | void |  | ) |

Print low-level version information to stdout.

Definition at line 2950 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

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 483 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 463 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 976 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 527 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 447 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 915 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 431 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 334 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 1074 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 1095 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 1004 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 268 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 959 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 1129 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 339 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 508 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 1119 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 478 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 937 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 517 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 949 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 2675 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 3553 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 2680 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 2693 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 2670 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 2967 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 3474 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 3419 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 2787 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 3234 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 3479 of file fuse_lowlevel.c.