fuse_lowlevel.h File Reference
`#include "fuse_common.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

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

## 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_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_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_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 (struct fuse_args *args, struct fuse_cmdline_opts *opts)
struct fuse_session * | fuse_session_new (struct fuse_args *args, const struct fuse_lowlevel_ops *op, size_t op_size, void *userdata)
int | fuse_session_mount (struct fuse_session *se, const char *mountpoint)
int | fuse_session_loop (struct fuse_session *se)
int | fuse_session_loop_mt_31 (struct fuse_session *se, int clone_fd)
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 31 (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 43 of file fuse_lowlevel.h.

## Typedef Documentation

## fuse_ino_t

typedef uint64_t fuse_ino_t

Inode number type

Definition at line 46 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 1760 of file fuse_lowlevel.h.

## fuse_req_t

typedef struct fuse_req* fuse_req_t

Request pointer type

Definition at line 49 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 267 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 357 of file fuse_lowlevel.c.

## fuse_cmdline_help()

void fuse_cmdline_help | ( | void |  | ) |

Print available options for `fuse_parse_cmdline()`.

Definition at line 129 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 2611 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 filesytem 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 2187 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 while executing a related filesytem operation or while holding 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 2163 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 2141 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 2124 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 2293 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 2213 of file fuse_lowlevel.c.

## fuse_lowlevel_version()

void fuse_lowlevel_version | ( | void |  | ) |

Print low-level version information to stdout.

Definition at line 2604 of file fuse_lowlevel.c.

## fuse_parse_cmdline()

int fuse_parse_cmdline | ( | 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

Definition at line 202 of file helper.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 431 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 881 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 470 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

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 415 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 820 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 399 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

Whereever 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 312 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 979 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 1000 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 909 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 246 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 864 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 317 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

Possible requests: open, opendir

Parameters

  req | request handle
  fi | file information

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

Definition at line 451 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 1024 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 446 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 842 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 460 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 854 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 2343 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 3030 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 2348 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 2361 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 2338 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 2621 of file fuse_lowlevel.c.

## fuse_session_exit()

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

Flag a session as terminated.

This function is invoked by the POSIX signal handlers, when registered using fuse_set_signal_handlers(). It will cause any running event loops to terminate on the next opportunity.

Parameters

  se | the session

Definition at line 3037 of file fuse_lowlevel.c.

## 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

Definition at line 3048 of file fuse_lowlevel.c.

## 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 2953 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_loop_mt_31()

int fuse_session_loop_mt_31 | ( | struct fuse_session * | se,
|  | int | clone_fd
| ) |  |

Enter a multi-threaded event loop.

For a description of the return value and the conditions when the event loop exits, refer to the documentation of fuse_session_loop().

Parameters

  se | the session
  config | session loop configuration

Returns
  see fuse_session_loop()

Definition at line 356 of file fuse_loop_mt.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 2903 of file fuse_lowlevel.c.

## fuse_session_new()

struct fuse_session* fuse_session_new | ( | struct fuse_args * | args,
|  | const struct fuse_lowlevel_ops * | op,
|  | size_t | op_size,
|  | void * | userdata
| ) |  |

Create a low level session.

Returns a session structure suitable for passing to fuse_session_mount() and fuse_session_loop().

This function accepts most file-system independent mount options (like context, nodev, ro - see mount(8)), as well as the general fuse mount options listed in mount.fuse(8) (e.g. -o allow_root and -o default_permissions, but not `-o use_ino`). Instead of `-o debug`, debugging may also enabled with `-d` or `--debug`.

If not all options are known, an error message is written to stderr and the function returns NULL.

Option parsing skips argv[0], which is assumed to contain the program name. To prevent accidentally passing an option in argv[0], this element must always be present (even if no options are specified). It may be set to the empty string ('\0') if no reasonable value can be provided.

Parameters

  args | argument vector
  op | the (low-level) filesystem operations
  op_size | sizeof(struct fuse_lowlevel_ops)
  userdata | user data

Returns
  the fuse session on success, NULL on failure

Definition at line 2809 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 2448 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 2648 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

Definition at line 3042 of file fuse_lowlevel.c.

## 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 2958 of file fuse_lowlevel.c.