libfuse
|
#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 |
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_expire_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_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, enum fuse_expire_flags flags) |
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) |
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_custom_io (struct fuse_session *se, const struct fuse_custom_io *io, int fd) |
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) |
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.
#define FUSE_ROOT_ID 1 |
The node ID of the root inode
Definition at line 43 of file fuse_lowlevel.h.
typedef uint64_t fuse_ino_t |
Inode number type
Definition at line 46 of file fuse_lowlevel.h.
typedef void(* fuse_interrupt_func_t) (fuse_req_t req, void *data) |
Callback function for an interrupt
req | interrupted request |
data | user data |
Definition at line 1886 of file fuse_lowlevel.h.
typedef struct fuse_req* fuse_req_t |
Request pointer type
Definition at line 49 of file fuse_lowlevel.h.
enum fuse_expire_flags |
Flags for fuse_lowlevel_notify_expire_entry() 0 = invalidate entry FUSE_LL_EXPIRE_ONLY = expire entry
Definition at line 146 of file fuse_lowlevel.h.
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).
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 |
Definition at line 274 of file fuse_lowlevel.c.
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.
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 |
Definition at line 364 of file fuse_lowlevel.c.
void fuse_cmdline_help | ( | void | ) |
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 2753 of file fuse_lowlevel.c.
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.
se | the session object |
parent | inode number |
child | inode number |
name | file name |
namelen | strlen() of file name |
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.
se | the session object |
parent | inode number |
child | inode number |
name | file name |
namelen | strlen() of file name |
Definition at line 2328 of file fuse_lowlevel.c.
int fuse_lowlevel_notify_expire_entry | ( | struct fuse_session * | se, |
fuse_ino_t | parent, | ||
const char * | name, | ||
size_t | namelen, | ||
enum fuse_expire_flags | flags | ||
) |
Notify to expire or invalidate parent attributes and the dentry matching parent/name
Underlying function for fuse_lowlevel_notify_inval_entry().
In addition to invalidating an entry, it also allows to expire an entry. In that case, the entry is not forcefully removed 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.
se | the session object |
parent | inode number |
name | file name |
namelen | strlen() of file name |
flags | flags to control if the entry should be expired or invalidated |
Definition at line 2294 of file fuse_lowlevel.c.
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.
se | the session object |
parent | inode number |
name | file name |
namelen | strlen() of file name |
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 filesytem 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.
se | the session object |
parent | inode number |
name | file name |
namelen | strlen() of file name |
Definition at line 2321 of file fuse_lowlevel.c.
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.
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 |
Definition at line 2272 of file fuse_lowlevel.c.
int fuse_lowlevel_notify_poll | ( | struct fuse_pollhandle * | ph | ) |
Notify IO readiness event
For more information, please read comment for poll operation.
ph | poll handle to notify IO readiness event for |
Definition at line 2255 of file fuse_lowlevel.c.
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.
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 |
Definition at line 2434 of file fuse_lowlevel.c.
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.
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 |
Definition at line 2354 of file fuse_lowlevel.c.
void fuse_lowlevel_version | ( | void | ) |
Print low-level version information to stdout.
Definition at line 2746 of file fuse_lowlevel.c.
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.
args | argument vector (input+output) |
opts | output argument for parsed options |
struct fuse_cmdline_opts got extended in libfuse-3.12
int fuse_reply_attr | ( | fuse_req_t | req, |
const struct stat * | attr, | ||
double | attr_timeout | ||
) |
Reply with attributes
Possible requests: getattr, setattr
req | request handle |
attr | the attributes |
attr_timeout | validity timeout (in seconds) for the attributes |
Definition at line 444 of file fuse_lowlevel.c.
int fuse_reply_bmap | ( | fuse_req_t | req, |
uint64_t | idx | ||
) |
Reply with block index
Possible requests: bmap
req | request handle |
idx | block index within device |
Definition at line 930 of file fuse_lowlevel.c.
int fuse_reply_buf | ( | fuse_req_t | req, |
const char * | buf, | ||
size_t | size | ||
) |
Reply with data
Possible requests: read, readdir, getxattr, listxattr
req | request handle |
buf | buffer containing data |
size | the size of data in bytes |
Definition at line 483 of file fuse_lowlevel.c.
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
req | request handle |
e | the entry parameters |
fi | file information |
Definition at line 428 of file fuse_lowlevel.c.
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:
In order for SPLICE_F_MOVE to be used, the following additional conditions have to be fulfilled:
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.
req | request handle |
bufv | buffer vector |
flags | flags controlling the copy |
Definition at line 869 of file fuse_lowlevel.c.
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
req | request handle |
e | the entry parameters |
Definition at line 412 of file fuse_lowlevel.c.
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.
req | request handle |
err | the positive error value, or zero for success |
Definition at line 319 of file fuse_lowlevel.c.
int fuse_reply_ioctl | ( | fuse_req_t | req, |
int | result, | ||
const void * | buf, | ||
size_t | size | ||
) |
Reply to finish ioctl
Possible requests: ioctl
req | request handle |
result | result to be passed to the caller |
buf | buffer containing output data |
size | length of output data |
Definition at line 1028 of file fuse_lowlevel.c.
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
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 1049 of file fuse_lowlevel.c.
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
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 |
Definition at line 958 of file fuse_lowlevel.c.
int fuse_reply_iov | ( | fuse_req_t | req, |
const struct iovec * | iov, | ||
int | count | ||
) |
Reply with data vector
Possible requests: read, readdir, getxattr, listxattr
req | request handle |
iov | the vector containing the data |
count | the size of vector |
Definition at line 253 of file fuse_lowlevel.c.
int fuse_reply_lock | ( | fuse_req_t | req, |
const struct flock * | lock | ||
) |
Reply with file lock information
Possible requests: getlk
req | request handle |
lock | the lock information |
Definition at line 913 of file fuse_lowlevel.c.
int fuse_reply_lseek | ( | fuse_req_t | req, |
off_t | off | ||
) |
Reply with offset
Possible requests: lseek
req | request handle |
off | offset of next data or hole |
Definition at line 1083 of file fuse_lowlevel.c.
void fuse_reply_none | ( | fuse_req_t | req | ) |
Don't send reply
Possible requests: forget forget_multi retrieve_reply
req | request handle |
Definition at line 324 of file fuse_lowlevel.c.
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
req | request handle |
fi | file information |
Definition at line 464 of file fuse_lowlevel.c.
int fuse_reply_poll | ( | fuse_req_t | req, |
unsigned | revents | ||
) |
Reply with poll result event mask
req | request handle |
revents | poll result event mask |
Definition at line 1073 of file fuse_lowlevel.c.
int fuse_reply_readlink | ( | fuse_req_t | req, |
const char * | link | ||
) |
Reply with the contents of a symbolic link
Possible requests: readlink
req | request handle |
link | symbolic link contents |
Definition at line 459 of file fuse_lowlevel.c.
int fuse_reply_statfs | ( | fuse_req_t | req, |
const struct statvfs * | stbuf | ||
) |
Reply with filesystem statistics
Possible requests: statfs
req | request handle |
stbuf | filesystem statistics |
Definition at line 891 of file fuse_lowlevel.c.
int fuse_reply_write | ( | fuse_req_t | req, |
size_t | count | ||
) |
Reply with number of bytes written
Possible requests: write
req | request handle |
count | the number of bytes written |
Definition at line 473 of file fuse_lowlevel.c.
int fuse_reply_xattr | ( | fuse_req_t | req, |
size_t | count | ||
) |
Reply with needed buffer size
Possible requests: getxattr, listxattr
req | request handle |
count | the buffer size needed in bytes |
Definition at line 903 of file fuse_lowlevel.c.
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
req | request handle |
Definition at line 2484 of file fuse_lowlevel.c.
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.
req | request handle |
size | size of given array |
list | array of group IDs to be filled in |
Definition at line 3222 of file fuse_lowlevel.c.
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.
req | request handle |
func | the callback function or NULL for unregister |
data | user data passed to the callback function |
Definition at line 2489 of file fuse_lowlevel.c.
int fuse_req_interrupted | ( | fuse_req_t | req | ) |
Check if a request has already been interrupted
req | request handle |
Definition at line 2502 of file fuse_lowlevel.c.
void* fuse_req_userdata | ( | fuse_req_t | req | ) |
Get the userdata from the request
req | request handle |
Definition at line 2479 of file fuse_lowlevel.c.
int fuse_session_custom_io | ( | struct fuse_session * | se, |
const struct fuse_custom_io * | io, | ||
int | fd | ||
) |
Set a file descriptor for the session.
This function can be used if you want to have a custom communication interface instead of using a mountpoint. In practice, this means that instead of calling fuse_session_mount() and fuse_session_unmount(), one could call fuse_session_custom_io() where fuse_session_mount() would have otherwise been called.
In io
, implementations for read and writev MUST be provided. Otherwise -1 will be returned and fd
will not be used. Implementations for splice_send
and splice_receive
are optional. If they are not provided splice will not be used for send or receive respectively.
The provided file descriptor fd
will be closed when fuse_session_destroy() is called.
se | session object |
io | Custom io to use when retrieving/sending requests/responses |
fd | file descriptor for the session |
io
, io->read
or ìo->writev
are NULL fd
was smaller than 0 io
Definition at line 3060 of file fuse_lowlevel.c.
void fuse_session_destroy | ( | struct fuse_session * | se | ) |
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.
se | the session |
int fuse_session_exited | ( | struct fuse_session * | se | ) |
Query the terminated flag of a session
se | the session |
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.
se | the session |
Definition at line 3144 of file fuse_lowlevel.c.
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 theabort
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.
se | the session |
Definition at line 19 of file fuse_loop.c.
int fuse_session_mount | ( | struct fuse_session * | se, |
const char * | mountpoint | ||
) |
Mount a FUSE file system.
mountpoint | the mount point path |
se | session object |
Definition at line 3094 of file fuse_lowlevel.c.
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.
args | argument vector |
op | the (low-level) filesystem operations |
op_size | sizeof(struct fuse_lowlevel_ops) |
userdata | user data |
Definition at line 2964 of file fuse_lowlevel.c.
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.
se | the session |
buf | the fuse_buf containing the request |
Definition at line 2590 of file fuse_lowlevel.c.
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.
se | the session |
buf | the fuse_buf to store the request in |
Definition at line 2792 of file fuse_lowlevel.c.
void fuse_session_reset | ( | struct fuse_session * | se | ) |
Reset the terminated flag of a session
se | the session |
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.
se | the session |
Definition at line 3149 of file fuse_lowlevel.c.