14#include "fuse_config.h"
16#include "fuse_kernel.h"
19#include "mount_util.h"
21#include "fuse_uring_i.h"
45#ifndef F_LINUX_SPECIFIC_BASE
46#define F_LINUX_SPECIFIC_BASE 1024
49#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
52#define PARAM(inarg) (((char *)(inarg)) + sizeof(*(inarg)))
53#define OFFSET_MAX 0x7fffffffffffffffLL
55struct fuse_pollhandle {
57 struct fuse_session *se;
60static size_t pagesize;
62static __attribute__((constructor))
void fuse_ll_init_pagesize(
void)
64 pagesize = getpagesize();
69static void trace_request_receive(
int err)
71 USDT(libfuse, request_receive, err);
74static void trace_request_process(
unsigned int opcode,
unsigned int unique)
76 USDT(libfuse, request_process, opcode, unique);
79static void trace_request_reply(uint64_t unique,
unsigned int len,
80 int error,
int reply_err)
82 USDT(libfuse, request_reply, unique, len, error, reply_err);
85static void trace_request_receive(
int err)
90static void trace_request_process(
unsigned int opcode,
unsigned int unique)
96static void trace_request_reply(uint64_t unique,
unsigned int len,
97 int error,
int reply_err)
106static void convert_stat(
const struct stat *stbuf,
struct fuse_attr *attr)
108 attr->ino = stbuf->st_ino;
109 attr->mode = stbuf->st_mode;
110 attr->nlink = stbuf->st_nlink;
111 attr->uid = stbuf->st_uid;
112 attr->gid = stbuf->st_gid;
113 attr->rdev = stbuf->st_rdev;
114 attr->size = stbuf->st_size;
115 attr->blksize = stbuf->st_blksize;
116 attr->blocks = stbuf->st_blocks;
117 attr->atime = stbuf->st_atime;
118 attr->mtime = stbuf->st_mtime;
119 attr->ctime = stbuf->st_ctime;
120 attr->atimensec = ST_ATIM_NSEC(stbuf);
121 attr->mtimensec = ST_MTIM_NSEC(stbuf);
122 attr->ctimensec = ST_CTIM_NSEC(stbuf);
125static void convert_attr(
const struct fuse_setattr_in *attr,
struct stat *stbuf)
127 stbuf->st_mode = attr->mode;
128 stbuf->st_uid = attr->uid;
129 stbuf->st_gid = attr->gid;
130 stbuf->st_size = attr->size;
131 stbuf->st_atime = attr->atime;
132 stbuf->st_mtime = attr->mtime;
133 stbuf->st_ctime = attr->ctime;
134 ST_ATIM_NSEC_SET(stbuf, attr->atimensec);
135 ST_MTIM_NSEC_SET(stbuf, attr->mtimensec);
136 ST_CTIM_NSEC_SET(stbuf, attr->ctimensec);
139static size_t iov_length(
const struct iovec *iov,
size_t count)
144 for (seg = 0; seg < count; seg++)
145 ret += iov[seg].iov_len;
149void list_init_req(
struct fuse_req *req)
155static void list_del_req(
struct fuse_req *req)
157 struct fuse_req *prev = req->prev;
158 struct fuse_req *next = req->next;
163static void list_add_req(
struct fuse_req *req,
struct fuse_req *next)
165 struct fuse_req *prev = next->prev;
174 if (req->flags.is_uring) {
175 fuse_log(FUSE_LOG_ERR,
"Refusing to destruct uring req\n");
178 assert(req->ch == NULL);
179 pthread_mutex_destroy(&req->lock);
186 struct fuse_session *se = req->se;
192 if (se->conn.no_interrupt || req->flags.is_uring) {
193 ctr = --req->ref_cnt;
194 fuse_chan_put(req->ch);
197 pthread_mutex_lock(&se->lock);
198 req->u.ni.func = NULL;
199 req->u.ni.data = NULL;
201 ctr = --req->ref_cnt;
202 fuse_chan_put(req->ch);
204 pthread_mutex_unlock(&se->lock);
210static struct fuse_req *fuse_ll_alloc_req(
struct fuse_session *se)
212 struct fuse_req *req;
214 req = (
struct fuse_req *) calloc(1,
sizeof(
struct fuse_req));
216 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate request\n");
221 pthread_mutex_init(&req->lock, NULL);
230static int fuse_write_msg_dev(
struct fuse_session *se,
struct fuse_chan *ch,
231 struct iovec *iov,
int count)
241 res = se->io->writev(ch ? ch->fd : se->fd, iov, count,
244 res = writev(ch ? ch->fd : se->fd, iov, count);
250 perror(
"fuse: writing device");
257static int fuse_send_msg(
struct fuse_session *se,
struct fuse_chan *ch,
260 struct fuse_out_header *out = iov[0].iov_base;
262 bool is_uring = req && req->flags.is_uring ? true :
false;
266 out->len = iov_length(iov, count);
269 if (out->unique == 0) {
270 fuse_log(FUSE_LOG_DEBUG,
"NOTIFY: code=%d length=%u\n",
271 out->error, out->len);
272 }
else if (out->error) {
274 " unique: %llu, error: %i (%s), outsize: %i\n",
275 (
unsigned long long) out->unique, out->error,
276 strerror(-out->error), out->len);
279 " unique: %llu, success, outsize: %i\n",
280 (
unsigned long long) out->unique, out->len);
285 err = fuse_send_msg_uring(req, iov, count);
287 err = fuse_write_msg_dev(se, ch, iov, count);
289 trace_request_reply(out->unique, out->len, out->error, err);
293int fuse_send_reply_iov_nofree(
fuse_req_t req,
int error,
struct iovec *iov,
296 struct fuse_out_header out;
298#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 32
299 const char *str = strerrordesc_np(error * -1);
300 if ((str == NULL && error != 0) || error > 0) {
302 if (error <= -1000 || error > 0) {
304 fuse_log(FUSE_LOG_ERR,
"fuse: bad error value: %i\n", error);
308 out.unique = req->unique;
311 iov[0].iov_base = &out;
312 iov[0].iov_len =
sizeof(
struct fuse_out_header);
314 return fuse_send_msg(req->se, req->ch, iov, count, req);
317static int send_reply_iov(
fuse_req_t req,
int error,
struct iovec *iov,
322 res = fuse_send_reply_iov_nofree(req, error, iov, count);
327static int send_reply(
fuse_req_t req,
int error,
const void *arg,
330 if (req->flags.is_uring)
331 return send_reply_uring(req, error, arg, argsize);
336 iov[1].iov_base = (
void *) arg;
337 iov[1].iov_len = argsize;
340 return send_reply_iov(req, error, iov, count);
346 struct iovec *padded_iov;
348 padded_iov = malloc((count + 1) *
sizeof(
struct iovec));
349 if (padded_iov == NULL)
352 memcpy(padded_iov + 1, iov, count *
sizeof(
struct iovec));
355 res = send_reply_iov(req, 0, padded_iov, count);
365 const char *name,
const struct stat *stbuf, off_t off)
370 size_t entlen_padded;
371 struct fuse_dirent *dirent;
373 namelen = strlen(name);
374 entlen = FUSE_NAME_OFFSET + namelen;
375 entlen_padded = FUSE_DIRENT_ALIGN(entlen);
377 if ((buf == NULL) || (entlen_padded > bufsize))
378 return entlen_padded;
380 dirent = (
struct fuse_dirent*) buf;
381 dirent->ino = stbuf->st_ino;
383 dirent->namelen = namelen;
384 dirent->type = (stbuf->st_mode & S_IFMT) >> 12;
385 memcpy(dirent->name, name, namelen);
386 memset(dirent->name + namelen, 0, entlen_padded - entlen);
388 return entlen_padded;
391static void convert_statfs(
const struct statvfs *stbuf,
392 struct fuse_kstatfs *kstatfs)
394 kstatfs->bsize = stbuf->f_bsize;
395 kstatfs->frsize = stbuf->f_frsize;
396 kstatfs->blocks = stbuf->f_blocks;
397 kstatfs->bfree = stbuf->f_bfree;
398 kstatfs->bavail = stbuf->f_bavail;
399 kstatfs->files = stbuf->f_files;
400 kstatfs->ffree = stbuf->f_ffree;
401 kstatfs->namelen = stbuf->f_namemax;
404static int send_reply_ok(
fuse_req_t req,
const void *arg,
size_t argsize)
406 return send_reply(req, 0, arg, argsize);
411 return send_reply(req, -err, NULL, 0);
419static unsigned long calc_timeout_sec(
double t)
421 if (t > (
double) ULONG_MAX)
426 return (
unsigned long) t;
429static unsigned int calc_timeout_nsec(
double t)
431 double f = t - (double) calc_timeout_sec(t);
434 else if (f >= 0.999999999)
437 return (
unsigned int) (f * 1.0e9);
440static void fill_entry(
struct fuse_entry_out *arg,
443 arg->nodeid = e->
ino;
448 arg->attr_valid_nsec = calc_timeout_nsec(e->
attr_timeout);
449 convert_stat(&e->
attr, &arg->attr);
461 size_t entlen_padded;
463 namelen = strlen(name);
464 entlen = FUSE_NAME_OFFSET_DIRENTPLUS + namelen;
465 entlen_padded = FUSE_DIRENT_ALIGN(entlen);
466 if ((buf == NULL) || (entlen_padded > bufsize))
467 return entlen_padded;
469 struct fuse_direntplus *dp = (
struct fuse_direntplus *) buf;
470 memset(&dp->entry_out, 0,
sizeof(dp->entry_out));
471 fill_entry(&dp->entry_out, e);
473 struct fuse_dirent *dirent = &dp->dirent;
474 dirent->ino = e->
attr.st_ino;
476 dirent->namelen = namelen;
477 dirent->type = (e->
attr.st_mode & S_IFMT) >> 12;
478 memcpy(dirent->name, name, namelen);
479 memset(dirent->name + namelen, 0, entlen_padded - entlen);
481 return entlen_padded;
484static void fill_open(
struct fuse_open_out *arg,
490 arg->open_flags |= FOPEN_PASSTHROUGH;
493 arg->open_flags |= FOPEN_DIRECT_IO;
495 arg->open_flags |= FOPEN_KEEP_CACHE;
497 arg->open_flags |= FOPEN_CACHE_DIR;
499 arg->open_flags |= FOPEN_NONSEEKABLE;
501 arg->open_flags |= FOPEN_NOFLUSH;
503 arg->open_flags |= FOPEN_PARALLEL_DIRECT_WRITES;
508 struct fuse_entry_out arg;
509 size_t size = req->se->conn.proto_minor < 9 ?
510 FUSE_COMPAT_ENTRY_OUT_SIZE :
sizeof(arg);
514 if (!e->
ino && req->se->conn.proto_minor < 4)
517 memset(&arg, 0,
sizeof(arg));
519 return send_reply_ok(req, &arg, size);
525 alignas(uint64_t)
char buf[
sizeof(
struct fuse_entry_out) +
sizeof(
struct fuse_open_out)];
526 size_t entrysize = req->se->conn.proto_minor < 9 ?
527 FUSE_COMPAT_ENTRY_OUT_SIZE :
sizeof(
struct fuse_entry_out);
528 struct fuse_entry_out *earg = (
struct fuse_entry_out *) buf;
529 struct fuse_open_out *oarg = (
struct fuse_open_out *) (buf + entrysize);
531 memset(buf, 0,
sizeof(buf));
534 return send_reply_ok(req, buf,
535 entrysize +
sizeof(
struct fuse_open_out));
541 struct fuse_attr_out arg;
542 size_t size = req->se->conn.proto_minor < 9 ?
543 FUSE_COMPAT_ATTR_OUT_SIZE :
sizeof(arg);
545 memset(&arg, 0,
sizeof(arg));
546 arg.attr_valid = calc_timeout_sec(attr_timeout);
547 arg.attr_valid_nsec = calc_timeout_nsec(attr_timeout);
548 convert_stat(attr, &arg.attr);
550 return send_reply_ok(req, &arg, size);
555 return send_reply_ok(req, linkname, strlen(linkname));
560 struct fuse_backing_map map = { .fd = fd };
563 ret = ioctl(req->se->fd, FUSE_DEV_IOC_BACKING_OPEN, &map);
565 fuse_log(FUSE_LOG_ERR,
"fuse: passthrough_open: %s\n", strerror(errno));
572int fuse_passthrough_close(
fuse_req_t req,
int backing_id)
576 ret = ioctl(req->se->fd, FUSE_DEV_IOC_BACKING_CLOSE, &backing_id);
578 fuse_log(FUSE_LOG_ERR,
"fuse: passthrough_close: %s\n", strerror(errno));
585 struct fuse_open_out arg;
587 memset(&arg, 0,
sizeof(arg));
589 return send_reply_ok(req, &arg,
sizeof(arg));
592static int do_fuse_reply_write(
fuse_req_t req,
size_t count)
594 struct fuse_write_out arg;
596 memset(&arg, 0,
sizeof(arg));
599 return send_reply_ok(req, &arg,
sizeof(arg));
602static int do_fuse_reply_copy(
fuse_req_t req,
size_t count)
604 struct fuse_copy_file_range_out arg;
606 memset(&arg, 0,
sizeof(arg));
607 arg.bytes_copied = count;
609 return send_reply_ok(req, &arg,
sizeof(arg));
618 if (req->flags.is_copy_file_range_64)
619 return do_fuse_reply_copy(req, count);
621 return do_fuse_reply_write(req, count);
626 return send_reply_ok(req, buf, size);
629static int fuse_send_data_iov_fallback(
struct fuse_session *se,
630 struct fuse_chan *ch,
631 struct iovec *iov,
int iov_count,
635 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
640 if (
buf->count == 1 &&
buf->idx == 0 &&
buf->off == 0 &&
645 iov[iov_count].iov_base =
buf->buf[0].
mem;
646 iov[iov_count].iov_len = len;
648 return fuse_send_msg(se, ch, iov, iov_count, req);
651 res = posix_memalign(&mbuf, pagesize, len);
655 mem_buf.
buf[0].
mem = mbuf;
663 iov[iov_count].iov_base = mbuf;
664 iov[iov_count].iov_len = len;
666 res = fuse_send_msg(se, ch, iov, iov_count, req);
678static void fuse_ll_pipe_free(
struct fuse_ll_pipe *llp)
686#if !defined(HAVE_PIPE2) || !defined(O_CLOEXEC)
687static int fuse_pipe(
int fds[2])
694 if (fcntl(fds[0], F_SETFL, O_NONBLOCK) == -1 ||
695 fcntl(fds[1], F_SETFL, O_NONBLOCK) == -1 ||
696 fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
697 fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
705static int fuse_pipe(
int fds[2])
707 return pipe2(fds, O_CLOEXEC | O_NONBLOCK);
711static struct fuse_ll_pipe *fuse_ll_get_pipe(
struct fuse_session *se)
713 struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
717 llp = malloc(
sizeof(
struct fuse_ll_pipe));
721 res = fuse_pipe(llp->pipe);
730 llp->size = pagesize * 16;
733 pthread_setspecific(se->pipe_key, llp);
740static void fuse_ll_clear_pipe(
struct fuse_session *se)
742 struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
744 pthread_setspecific(se->pipe_key, NULL);
745 fuse_ll_pipe_free(llp);
749#if defined(HAVE_SPLICE) && defined(HAVE_VMSPLICE)
750static int read_back(
int fd,
char *buf,
size_t len)
754 res = read(fd, buf, len);
757 "fuse: internal error: failed to read back from pipe: %s\n",
763 "fuse: internal error: short read back from pipe: %i from %zd\n",
770static int grow_pipe_to_max(
int pipefd)
777 maxfd = open(
"/proc/sys/fs/pipe-max-size", O_RDONLY);
781 res = read(maxfd, buf,
sizeof(buf) - 1);
792 res = libfuse_strtol(buf, &max);
795 res = fcntl(pipefd, F_SETPIPE_SZ, max);
801static int fuse_send_data_iov(
struct fuse_session *se,
struct fuse_chan *ch,
802 struct iovec *iov,
int iov_count,
808 struct fuse_out_header *out = iov[0].iov_base;
809 struct fuse_ll_pipe *llp;
812 size_t total_buf_size;
815 struct fuse_bufvec pipe_buf = FUSE_BUFVEC_INIT(len);
817 if (se->broken_splice_nonblock)
827 total_buf_size -=
buf->off;
829 if (total_buf_size < 2 * pagesize)
832 if (se->conn.proto_minor < 14 ||
836 llp = fuse_ll_get_pipe(se);
841 headerlen = iov_length(iov, iov_count);
843 out->len = headerlen + len;
849 pipesize = pagesize * (iov_count +
buf->count + 1) + out->len;
851 if (llp->size < pipesize) {
853 res = fcntl(llp->pipe[0], F_SETPIPE_SZ, pipesize);
855 res = grow_pipe_to_max(llp->pipe[0]);
863 if (llp->size < pipesize)
868 res = vmsplice(llp->pipe[1], iov, iov_count, SPLICE_F_NONBLOCK);
872 if (res != headerlen) {
874 fuse_log(FUSE_LOG_ERR,
"fuse: short vmsplice to pipe: %u/%zu\n", res,
880 pipe_buf.
buf[0].
fd = llp->pipe[1];
885 if (res == -EAGAIN || res == -EINVAL) {
897 se->broken_splice_nonblock = 1;
899 pthread_setspecific(se->pipe_key, NULL);
900 fuse_ll_pipe_free(llp);
907 if (res != 0 && res < len) {
908 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
910 size_t now_len = res;
920 res = posix_memalign(&mbuf, pagesize, len);
924 mem_buf.
buf[0].
mem = mbuf;
925 mem_buf.
off = now_len;
929 size_t extra_len = res;
935 tmpbuf = malloc(headerlen);
936 if (tmpbuf == NULL) {
941 res = read_back(llp->pipe[0], tmpbuf, headerlen);
947 res = read_back(llp->pipe[0], mbuf, now_len);
952 len = now_len + extra_len;
953 iov[iov_count].iov_base = mbuf;
954 iov[iov_count].iov_len = len;
956 res = fuse_send_msg(se, ch, iov, iov_count, req);
964 out->len = headerlen + len;
968 " unique: %llu, success, outsize: %i (splice)\n",
969 (
unsigned long long) out->unique, out->len);
975 splice_flags |= SPLICE_F_MOVE;
977 if (se->io != NULL && se->io->splice_send != NULL) {
978 res = se->io->splice_send(llp->pipe[0], NULL,
979 ch ? ch->fd : se->fd, NULL, out->len,
980 splice_flags, se->userdata);
982 res = splice(llp->pipe[0], NULL, ch ? ch->fd : se->fd, NULL,
983 out->len, splice_flags);
987 perror(
"fuse: splice from pipe");
990 if (res != out->len) {
992 fuse_log(FUSE_LOG_ERR,
"fuse: short splice from pipe: %u/%u\n",
999 fuse_ll_clear_pipe(se);
1003 return fuse_send_data_iov_fallback(se, ch, iov, iov_count,
buf, len, req);
1006static int fuse_send_data_iov(
struct fuse_session *se,
struct fuse_chan *ch,
1007 struct iovec *iov,
int iov_count,
1014 return fuse_send_data_iov_fallback(se, ch, iov, iov_count, req_data, len, req);
1021 struct iovec iov[2];
1022 struct fuse_out_header out;
1025 if (req->flags.is_uring)
1026 return fuse_reply_data_uring(req, bufv, flags);
1028 iov[0].iov_base = &out;
1029 iov[0].iov_len =
sizeof(
struct fuse_out_header);
1031 out.unique = req->unique;
1034 res = fuse_send_data_iov(req->se, req->ch, iov, 1, bufv, flags, req);
1045 struct fuse_statfs_out arg;
1046 size_t size = req->se->conn.proto_minor < 4 ?
1047 FUSE_COMPAT_STATFS_SIZE :
sizeof(arg);
1049 memset(&arg, 0,
sizeof(arg));
1050 convert_statfs(stbuf, &arg.st);
1052 return send_reply_ok(req, &arg, size);
1057 struct fuse_getxattr_out arg;
1059 memset(&arg, 0,
sizeof(arg));
1062 return send_reply_ok(req, &arg,
sizeof(arg));
1067 struct fuse_lk_out arg;
1069 memset(&arg, 0,
sizeof(arg));
1070 arg.lk.type = lock->l_type;
1071 if (lock->l_type != F_UNLCK) {
1072 arg.lk.start = lock->l_start;
1073 if (lock->l_len == 0)
1074 arg.lk.end = OFFSET_MAX;
1076 arg.lk.end = lock->l_start + lock->l_len - 1;
1078 arg.lk.pid = lock->l_pid;
1079 return send_reply_ok(req, &arg,
sizeof(arg));
1084 struct fuse_bmap_out arg;
1086 memset(&arg, 0,
sizeof(arg));
1089 return send_reply_ok(req, &arg,
sizeof(arg));
1092static struct fuse_ioctl_iovec *fuse_ioctl_iovec_copy(
const struct iovec *iov,
1095 struct fuse_ioctl_iovec *fiov;
1098 fiov = malloc(
sizeof(fiov[0]) * count);
1102 for (i = 0; i < count; i++) {
1103 fiov[i].base = (uintptr_t) iov[i].iov_base;
1104 fiov[i].len = iov[i].iov_len;
1111 const struct iovec *in_iov,
size_t in_count,
1112 const struct iovec *out_iov,
size_t out_count)
1114 struct fuse_ioctl_out arg;
1115 struct fuse_ioctl_iovec *in_fiov = NULL;
1116 struct fuse_ioctl_iovec *out_fiov = NULL;
1117 struct iovec iov[4];
1121 memset(&arg, 0,
sizeof(arg));
1122 arg.flags |= FUSE_IOCTL_RETRY;
1123 arg.in_iovs = in_count;
1124 arg.out_iovs = out_count;
1125 iov[count].iov_base = &arg;
1126 iov[count].iov_len =
sizeof(arg);
1129 if (req->se->conn.proto_minor < 16) {
1131 iov[count].iov_base = (
void *)in_iov;
1132 iov[count].iov_len =
sizeof(in_iov[0]) * in_count;
1137 iov[count].iov_base = (
void *)out_iov;
1138 iov[count].iov_len =
sizeof(out_iov[0]) * out_count;
1143 if (
sizeof(
void *) == 4 && req->flags.ioctl_64bit) {
1149 in_fiov = fuse_ioctl_iovec_copy(in_iov, in_count);
1153 iov[count].iov_base = (
void *)in_fiov;
1154 iov[count].iov_len =
sizeof(in_fiov[0]) * in_count;
1158 out_fiov = fuse_ioctl_iovec_copy(out_iov, out_count);
1162 iov[count].iov_base = (
void *)out_fiov;
1163 iov[count].iov_len =
sizeof(out_fiov[0]) * out_count;
1168 res = send_reply_iov(req, 0, iov, count);
1182 struct fuse_ioctl_out arg;
1183 struct iovec iov[3];
1186 memset(&arg, 0,
sizeof(arg));
1187 arg.result = result;
1188 iov[count].iov_base = &arg;
1189 iov[count].iov_len =
sizeof(arg);
1193 iov[count].iov_base = (
char *) buf;
1194 iov[count].iov_len = size;
1198 return send_reply_iov(req, 0, iov, count);
1204 struct iovec *padded_iov;
1205 struct fuse_ioctl_out arg;
1208 padded_iov = malloc((count + 2) *
sizeof(
struct iovec));
1209 if (padded_iov == NULL)
1212 memset(&arg, 0,
sizeof(arg));
1213 arg.result = result;
1214 padded_iov[1].iov_base = &arg;
1215 padded_iov[1].iov_len =
sizeof(arg);
1217 memcpy(&padded_iov[2], iov, count *
sizeof(
struct iovec));
1219 res = send_reply_iov(req, 0, padded_iov, count + 2);
1227 struct fuse_poll_out arg;
1229 memset(&arg, 0,
sizeof(arg));
1230 arg.revents = revents;
1232 return send_reply_ok(req, &arg,
sizeof(arg));
1237 struct fuse_lseek_out arg;
1239 memset(&arg, 0,
sizeof(arg));
1242 return send_reply_ok(req, &arg,
sizeof(arg));
1247 double attr_timeout)
1249 struct fuse_statx_out arg;
1251 memset(&arg, 0,
sizeof(arg));
1253 arg.attr_valid = calc_timeout_sec(attr_timeout);
1254 arg.attr_valid_nsec = calc_timeout_nsec(attr_timeout);
1255 memcpy(&arg.stat, statx,
sizeof(arg.stat));
1257 return send_reply_ok(req, &arg,
sizeof(arg));
1261 double attr_timeout)
1273 const void *op_in,
const void *in_payload)
1277 char *name = (
char *)in_payload;
1279 if (req->se->op.lookup)
1280 req->se->op.lookup(req, nodeid, name);
1288 _do_lookup(req, nodeid, NULL, inarg);
1292 const void *op_in,
const void *in_payload)
1296 struct fuse_forget_in *arg = (
struct fuse_forget_in *)op_in;
1298 if (req->se->op.forget)
1299 req->se->op.forget(req, nodeid, arg->nlookup);
1307 _do_forget(req, nodeid, inarg, NULL);
1311 const void *op_in,
const void *in_payload)
1316 const struct fuse_batch_forget_in *arg = op_in;
1317 const struct fuse_forget_one *forgets = in_payload;
1319 if (req->se->op.forget_multi) {
1320 req->se->op.forget_multi(req, arg->count,
1321 (
struct fuse_forget_data *)in_payload);
1322 }
else if (req->se->op.forget) {
1323 for (i = 0; i < arg->count; i++) {
1324 const struct fuse_forget_one *forget = &forgets[i];
1325 struct fuse_req *dummy_req;
1327 dummy_req = fuse_ll_alloc_req(req->se);
1328 if (dummy_req == NULL)
1331 dummy_req->unique = req->unique;
1332 dummy_req->ctx = req->ctx;
1333 dummy_req->ch = NULL;
1335 req->se->op.forget(dummy_req, forget->nodeid,
1347 struct fuse_batch_forget_in *arg = (
void *)inarg;
1348 struct fuse_forget_one *param = (
void *)PARAM(arg);
1350 _do_batch_forget(req, nodeid, inarg, param);
1354 const void *op_in,
const void *in_payload)
1356 struct fuse_getattr_in *arg = (
struct fuse_getattr_in *)op_in;
1362 if (req->se->conn.proto_minor >= 9) {
1363 if (arg->getattr_flags & FUSE_GETATTR_FH) {
1364 memset(&fi, 0,
sizeof(fi));
1370 if (req->se->op.getattr)
1371 req->se->op.getattr(req, nodeid, fip);
1379 _do_getattr(req, nodeid, inarg, NULL);
1383 const void *op_in,
const void *in_payload)
1386 const struct fuse_setattr_in *arg = op_in;
1387 uint32_t valid = arg->valid;
1389 if (req->se->op.setattr) {
1393 memset(&stbuf, 0,
sizeof(stbuf));
1394 convert_attr(arg, &stbuf);
1395 if (arg->valid & FATTR_FH) {
1397 memset(&fi_store, 0,
sizeof(fi_store));
1401 valid &= FUSE_SET_ATTR_MODE | FUSE_SET_ATTR_UID |
1402 FUSE_SET_ATTR_GID | FUSE_SET_ATTR_SIZE |
1403 FUSE_SET_ATTR_ATIME | FUSE_SET_ATTR_MTIME |
1404 FUSE_SET_ATTR_KILL_SUID | FUSE_SET_ATTR_KILL_SGID |
1405 FUSE_SET_ATTR_ATIME_NOW | FUSE_SET_ATTR_MTIME_NOW |
1406 FUSE_SET_ATTR_CTIME;
1408 req->se->op.setattr(req, nodeid, &stbuf, valid, fi);
1416 _do_setattr(req, nodeid, inarg, NULL);
1420 const void *op_in,
const void *in_payload)
1423 const struct fuse_access_in *arg = op_in;
1425 if (req->se->op.access)
1426 req->se->op.access(req, nodeid, arg->mask);
1434 _do_access(req, nodeid, inarg, NULL);
1438 const void *op_in,
const void *in_payload)
1443 if (req->se->op.readlink)
1444 req->se->op.readlink(req, nodeid);
1452 _do_readlink(req, nodeid, inarg, NULL);
1456 const void *op_in,
const void *in_payload)
1458 const struct fuse_mknod_in *arg = (
struct fuse_mknod_in *)op_in;
1459 const char *name = in_payload;
1461 if (req->se->conn.proto_minor >= 12)
1462 req->ctx.umask = arg->umask;
1464 if (req->se->op.mknod)
1465 req->se->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
1472 struct fuse_mknod_in *arg = (
struct fuse_mknod_in *)inarg;
1473 char *name = PARAM(arg);
1475 if (req->se->conn.proto_minor < 12)
1476 name = (
char *)inarg + FUSE_COMPAT_MKNOD_IN_SIZE;
1478 _do_mknod(req, nodeid, inarg, name);
1482 const void *op_in,
const void *in_payload)
1484 const char *name = in_payload;
1485 const struct fuse_mkdir_in *arg = op_in;
1487 if (req->se->conn.proto_minor >= 12)
1488 req->ctx.umask = arg->umask;
1490 if (req->se->op.mkdir)
1491 req->se->op.mkdir(req, nodeid, name, arg->mode);
1498 const struct fuse_mkdir_in *arg = inarg;
1499 const char *name = PARAM(arg);
1501 _do_mkdir(req, nodeid, inarg, name);
1505 const void *op_in,
const void *in_payload)
1508 const char *name = in_payload;
1510 if (req->se->op.unlink)
1511 req->se->op.unlink(req, nodeid, name);
1519 _do_unlink(req, nodeid, NULL, inarg);
1523 const void *op_in,
const void *in_payload)
1526 const char *name = in_payload;
1528 if (req->se->op.rmdir)
1529 req->se->op.rmdir(req, nodeid, name);
1536 _do_rmdir(req, nodeid, NULL, inarg);
1540 const void *op_in,
const void *in_payload)
1543 const char *name = (
char *)in_payload;
1544 const char *linkname = name + strlen(name) + 1;
1546 if (req->se->op.symlink)
1547 req->se->op.symlink(req, linkname, nodeid, name);
1555 _do_symlink(req, nodeid, NULL, inarg);
1559 const void *op_in,
const void *in_payload)
1561 const struct fuse_rename_in *arg = (
struct fuse_rename_in *)op_in;
1562 const char *oldname = in_payload;
1563 const char *newname = oldname + strlen(oldname) + 1;
1565 if (req->se->op.rename)
1566 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1575 const struct fuse_rename_in *arg = inarg;
1576 const void *payload = PARAM(arg);
1578 _do_rename(req, nodeid, arg, payload);
1582 const void *op_in,
const void *in_payload)
1584 const struct fuse_rename2_in *arg = op_in;
1585 const char *oldname = in_payload;
1586 const char *newname = oldname + strlen(oldname) + 1;
1588 if (req->se->op.rename)
1589 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1598 const struct fuse_rename2_in *arg = inarg;
1599 const void *payload = PARAM(arg);
1601 _do_rename2(req, nodeid, arg, payload);
1605 const void *in_payload)
1608 const struct fuse_create_in *arg = op_in;
1610 if (req->se->op.tmpfile) {
1613 memset(&fi, 0,
sizeof(fi));
1614 fi.
flags = arg->flags;
1616 if (req->se->conn.proto_minor >= 12)
1617 req->ctx.umask = arg->umask;
1619 req->se->op.tmpfile(req, nodeid, arg->mode, &fi);
1626 struct fuse_create_in *arg = (
struct fuse_create_in *) inarg;
1628 _do_tmpfile(req, nodeid, arg, NULL);
1632 const void *in_payload)
1634 struct fuse_link_in *arg = (
struct fuse_link_in *)op_in;
1636 if (req->se->op.link)
1637 req->se->op.link(req, arg->oldnodeid, nodeid, in_payload);
1644 const struct fuse_link_in *arg = inarg;
1645 const void *name = PARAM(arg);
1647 _do_link(req, nodeid, inarg, name);
1651 const void *op_in,
const void *in_payload)
1653 const struct fuse_create_in *arg = op_in;
1654 const char *name = in_payload;
1656 if (req->se->op.create) {
1659 memset(&fi, 0,
sizeof(fi));
1660 fi.
flags = arg->flags;
1662 if (req->se->conn.proto_minor >= 12)
1663 req->ctx.umask = arg->umask;
1667 req->se->op.create(req, nodeid, name, arg->mode, &fi);
1676 const struct fuse_create_in *arg = (
struct fuse_create_in *)inarg;
1677 void *payload = PARAM(arg);
1679 if (req->se->conn.proto_minor < 12)
1680 payload = (
char *)inarg +
sizeof(
struct fuse_open_in);
1682 _do_create(req, nodeid, arg, payload);
1686 const void *in_payload)
1689 struct fuse_open_in *arg = (
struct fuse_open_in *)op_in;
1692 memset(&fi, 0,
sizeof(fi));
1693 fi.
flags = arg->flags;
1697 if (req->se->op.open)
1698 req->se->op.open(req, nodeid, &fi);
1707 _do_open(req, nodeid, inarg, NULL);
1711 const void *in_payload)
1714 struct fuse_read_in *arg = (
struct fuse_read_in *)op_in;
1716 if (req->se->op.read) {
1719 memset(&fi, 0,
sizeof(fi));
1721 if (req->se->conn.proto_minor >= 9) {
1723 fi.
flags = arg->flags;
1725 req->se->op.read(req, nodeid, arg->size, arg->offset, &fi);
1732 _do_read(req, nodeid, inarg, NULL);
1736 const void *op_in,
const void *in_payload)
1738 struct fuse_write_in *arg = (
struct fuse_write_in *)op_in;
1739 const char *buf = in_payload;
1742 memset(&fi, 0,
sizeof(fi));
1744 fi.
writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
1746 if (req->se->conn.proto_minor >= 9) {
1748 fi.
flags = arg->flags;
1751 if (req->se->op.write)
1752 req->se->op.write(req, nodeid, buf, arg->size, arg->offset,
1760 struct fuse_write_in *arg = (
struct fuse_write_in *)inarg;
1761 const void *payload;
1763 if (req->se->conn.proto_minor < 9)
1764 payload = ((
char *)arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1766 payload = PARAM(arg);
1768 _do_write(req, nodeid, arg, payload);
1774 struct fuse_session *se = req->se;
1775 struct fuse_write_in *arg = (
struct fuse_write_in *)op_in;
1778 memset(&fi, 0,
sizeof(fi));
1780 fi.
writepage = arg->write_flags & FUSE_WRITE_CACHE;
1782 if (se->conn.proto_minor >= 9) {
1784 fi.
flags = arg->flags;
1787 se->op.write_buf(req, nodeid, bufv, arg->offset, &fi);
1791 const void *inarg,
const struct fuse_buf *ibuf)
1793 struct fuse_session *se = req->se;
1798 struct fuse_write_in *arg = (
struct fuse_write_in *)inarg;
1800 if (se->conn.proto_minor < 9) {
1801 bufv.
buf[0].
mem = ((
char *)arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1802 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1803 FUSE_COMPAT_WRITE_IN_SIZE;
1807 bufv.
buf[0].
mem = PARAM(arg);
1809 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1810 sizeof(struct fuse_write_in);
1812 if (bufv.
buf[0].
size < arg->size) {
1814 "fuse: %s: buffer size too small\n", __func__);
1820 _do_write_buf(req, nodeid, inarg, &bufv);
1825 fuse_ll_clear_pipe(se);
1829 const void *op_in,
const void *in_payload)
1832 struct fuse_flush_in *arg = (
struct fuse_flush_in *)op_in;
1835 memset(&fi, 0,
sizeof(fi));
1838 if (req->se->conn.proto_minor >= 7)
1841 if (req->se->op.flush)
1842 req->se->op.flush(req, nodeid, &fi);
1849 _do_flush(req, nodeid, inarg, NULL);
1853 const void *op_in,
const void *in_payload)
1856 const struct fuse_release_in *arg = op_in;
1859 memset(&fi, 0,
sizeof(fi));
1860 fi.
flags = arg->flags;
1862 if (req->se->conn.proto_minor >= 8) {
1863 fi.
flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
1866 if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) {
1867 fi.flock_release = 1;
1871 if (req->se->op.release)
1872 req->se->op.release(req, nodeid, &fi);
1880 _do_release(req, nodeid, inarg, NULL);
1884 const void *op_in,
const void *in_payload)
1887 const struct fuse_fsync_in *arg = op_in;
1889 int datasync = arg->fsync_flags & 1;
1891 memset(&fi, 0,
sizeof(fi));
1894 if (req->se->op.fsync)
1895 req->se->op.fsync(req, nodeid, datasync, &fi);
1902 _do_fsync(req, nodeid, inarg, NULL);
1906 const void *op_in,
const void *in_payload)
1909 const struct fuse_open_in *arg = op_in;
1912 memset(&fi, 0,
sizeof(fi));
1913 fi.
flags = arg->flags;
1916 if (req->se->op.opendir)
1917 req->se->op.opendir(req, nodeid, &fi);
1927 _do_opendir(req, nodeid, inarg, NULL);
1931 const void *op_in,
const void *in_payload)
1934 struct fuse_read_in *arg = (
struct fuse_read_in *)op_in;
1937 memset(&fi, 0,
sizeof(fi));
1940 if (req->se->op.readdir)
1941 req->se->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
1949 _do_readdir(req, nodeid, inarg, NULL);
1953 const void *op_in,
const void *in_payload)
1956 struct fuse_read_in *arg = (
struct fuse_read_in *)op_in;
1959 memset(&fi, 0,
sizeof(fi));
1962 if (req->se->op.readdirplus)
1963 req->se->op.readdirplus(req, nodeid, arg->size, arg->offset, &fi);
1971 _do_readdirplus(req, nodeid, inarg, NULL);
1975 const void *op_in,
const void *in_payload)
1978 struct fuse_release_in *arg = (
struct fuse_release_in *)op_in;
1981 memset(&fi, 0,
sizeof(fi));
1982 fi.
flags = arg->flags;
1985 if (req->se->op.releasedir)
1986 req->se->op.releasedir(req, nodeid, &fi);
1994 _do_releasedir(req, nodeid, inarg, NULL);
1998 const void *op_in,
const void *in_payload)
2001 struct fuse_fsync_in *arg = (
struct fuse_fsync_in *)op_in;
2003 int datasync = arg->fsync_flags & 1;
2005 memset(&fi, 0,
sizeof(fi));
2008 if (req->se->op.fsyncdir)
2009 req->se->op.fsyncdir(req, nodeid, datasync, &fi);
2016 _do_fsyncdir(req, nodeid, inarg, NULL);
2020 const void *op_in,
const void *in_payload)
2026 if (req->se->op.statfs)
2027 req->se->op.statfs(req, nodeid);
2029 struct statvfs buf = {
2039 _do_statfs(req, nodeid, inarg, NULL);
2043 const void *op_in,
const void *in_payload)
2045 struct fuse_setxattr_in *arg = (
struct fuse_setxattr_in *)op_in;
2046 const char *name = in_payload;
2047 const char *value = name + strlen(name) + 1;
2051 if (req->se->op.setxattr)
2052 req->se->op.setxattr(req, nodeid, name, value, arg->size,
2060 struct fuse_session *se = req->se;
2062 const struct fuse_setxattr_in *arg = inarg;
2063 char *payload = xattr_ext ? PARAM(arg) :
2064 (char *)arg + FUSE_COMPAT_SETXATTR_IN_SIZE;
2066 _do_setxattr(req, nodeid, arg, payload);
2070 const void *op_in,
const void *in_payload)
2072 const struct fuse_getxattr_in *arg = op_in;
2074 if (req->se->op.getxattr)
2075 req->se->op.getxattr(req, nodeid, in_payload, arg->size);
2083 const struct fuse_getxattr_in *arg = inarg;
2084 const void *payload = PARAM(arg);
2086 _do_getxattr(req, nodeid, arg, payload);
2090 const void *inarg,
const void *in_payload)
2093 const struct fuse_getxattr_in *arg = inarg;
2095 if (req->se->op.listxattr)
2096 req->se->op.listxattr(req, nodeid, arg->size);
2103 _do_listxattr(req, nodeid, inarg, NULL);
2107 const void *inarg,
const void *in_payload)
2110 const char *name = in_payload;
2112 if (req->se->op.removexattr)
2113 req->se->op.removexattr(req, nodeid, name);
2119 _do_removexattr(req, nodeid, NULL, inarg);
2122static void convert_fuse_file_lock(
const struct fuse_file_lock *fl,
2123 struct flock *flock)
2125 memset(flock, 0,
sizeof(
struct flock));
2126 flock->l_type = fl->type;
2127 flock->l_whence = SEEK_SET;
2128 flock->l_start = fl->start;
2129 if (fl->end == OFFSET_MAX)
2132 flock->l_len = fl->end - fl->start + 1;
2133 flock->l_pid = fl->pid;
2137 const void *op_in,
const void *in_payload)
2140 const struct fuse_lk_in *arg = op_in;
2144 memset(&fi, 0,
sizeof(fi));
2148 convert_fuse_file_lock(&arg->lk, &flock);
2149 if (req->se->op.getlk)
2150 req->se->op.getlk(req, nodeid, &fi, &flock);
2156 _do_getlk(req, nodeid, inarg, NULL);
2160 const void *op_in,
int sleep)
2162 const struct fuse_lk_in *arg = op_in;
2166 memset(&fi, 0,
sizeof(fi));
2170 if (arg->lk_flags & FUSE_LK_FLOCK) {
2173 switch (arg->lk.type) {
2187 if (req->se->op.flock)
2188 req->se->op.flock(req, nodeid, &fi, op);
2192 convert_fuse_file_lock(&arg->lk, &flock);
2193 if (req->se->op.setlk)
2194 req->se->op.setlk(req, nodeid, &fi, &flock, sleep);
2201 const void *op_in,
const void *in_payload)
2204 do_setlk_common(req, nodeid, op_in, 0);
2209 _do_setlk(req, nodeid, inarg, NULL);
2213 const void *op_in,
const void *in_payload)
2216 do_setlk_common(req, nodeid, op_in, 1);
2220 _do_setlkw(req, nodeid, inarg, NULL);
2223static int find_interrupted(
struct fuse_session *se,
struct fuse_req *req)
2225 struct fuse_req *curr;
2227 for (curr = se->list.next; curr != &se->list; curr = curr->next) {
2228 if (curr->unique == req->u.i.unique) {
2233 pthread_mutex_unlock(&se->lock);
2236 pthread_mutex_lock(&curr->lock);
2237 pthread_mutex_lock(&se->lock);
2238 curr->interrupted = 1;
2239 func = curr->u.ni.func;
2240 data = curr->u.ni.data;
2241 pthread_mutex_unlock(&se->lock);
2244 pthread_mutex_unlock(&curr->lock);
2246 pthread_mutex_lock(&se->lock);
2248 if (!curr->ref_cnt) {
2255 for (curr = se->interrupts.next; curr != &se->interrupts;
2256 curr = curr->next) {
2257 if (curr->u.i.unique == req->u.i.unique)
2264 const void *op_in,
const void *in_payload)
2267 const struct fuse_interrupt_in *arg = op_in;
2268 struct fuse_session *se = req->se;
2272 fuse_log(FUSE_LOG_DEBUG,
"INTERRUPT: %llu\n",
2273 (
unsigned long long) arg->unique);
2275 req->u.i.unique = arg->unique;
2277 pthread_mutex_lock(&se->lock);
2278 if (find_interrupted(se, req)) {
2279 fuse_chan_put(req->ch);
2283 list_add_req(req, &se->interrupts);
2284 pthread_mutex_unlock(&se->lock);
2288 _do_interrupt(req, nodeid, inarg, NULL);
2291static struct fuse_req *check_interrupt(
struct fuse_session *se,
2292 struct fuse_req *req)
2294 struct fuse_req *curr;
2296 for (curr = se->interrupts.next; curr != &se->interrupts;
2297 curr = curr->next) {
2298 if (curr->u.i.unique == req->unique) {
2299 req->interrupted = 1;
2301 fuse_chan_put(curr->ch);
2307 curr = se->interrupts.next;
2308 if (curr != &se->interrupts) {
2310 list_init_req(curr);
2317 const void *in_payload)
2320 const struct fuse_bmap_in *arg = op_in;
2322 if (req->se->op.bmap)
2323 req->se->op.bmap(req, nodeid, arg->blocksize, arg->block);
2329 _do_bmap(req, nodeid, inarg, NULL);
2333 const void *op_in,
const void *in_payload)
2335 struct fuse_ioctl_in *arg = (
struct fuse_ioctl_in *)op_in;
2336 unsigned int flags = arg->flags;
2337 const void *in_buf = in_payload;
2340 if (
flags & FUSE_IOCTL_DIR &&
2346 memset(&fi, 0,
sizeof(fi));
2349 if (
sizeof(
void *) == 4 && req->se->conn.proto_minor >= 16 &&
2350 !(
flags & FUSE_IOCTL_32BIT)) {
2351 req->flags.ioctl_64bit = 1;
2354 if (req->se->op.ioctl)
2355 req->se->op.ioctl(req, nodeid, arg->cmd,
2356 (
void *)(uintptr_t)arg->arg, &fi,
flags,
2357 in_buf, arg->in_size, arg->out_size);
2363 const struct fuse_ioctl_in *arg = inarg;
2364 void *in_buf = arg->in_size ? PARAM(arg) : NULL;
2366 _do_ioctl(req, nodeid, arg, in_buf);
2375 const void *in_payload)
2378 struct fuse_poll_in *arg = (
struct fuse_poll_in *)op_in;
2381 memset(&fi, 0,
sizeof(fi));
2385 if (req->se->op.poll) {
2386 struct fuse_pollhandle *ph = NULL;
2388 if (arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) {
2389 ph = malloc(
sizeof(
struct fuse_pollhandle));
2398 req->se->op.poll(req, nodeid, &fi, ph);
2406 _do_poll(req, nodeid, inarg, NULL);
2410 const void *op_in,
const void *in_payload)
2413 const struct fuse_fallocate_in *arg = op_in;
2416 memset(&fi, 0,
sizeof(fi));
2419 if (req->se->op.fallocate)
2420 req->se->op.fallocate(req, nodeid, arg->mode, arg->offset,
2429 _do_fallocate(req, nodeid, inarg, NULL);
2433 const struct fuse_copy_file_range_in *arg)
2437 memset(&fi_in, 0,
sizeof(fi_in));
2438 fi_in.fh = arg->fh_in;
2440 memset(&fi_out, 0,
sizeof(fi_out));
2441 fi_out.fh = arg->fh_out;
2443 if (req->se->op.copy_file_range)
2444 req->se->op.copy_file_range(req, nodeid_in, arg->off_in, &fi_in,
2445 arg->nodeid_out, arg->off_out,
2446 &fi_out, arg->len, arg->flags);
2452 const void *op_in,
const void *in_payload)
2454 const struct fuse_copy_file_range_in *arg = op_in;
2455 struct fuse_copy_file_range_in arg_tmp;
2459 if (arg->len > 0xfffff000) {
2461 arg_tmp.len = 0xfffff000;
2464 copy_file_range_common(req, nodeid_in, arg);
2470 _do_copy_file_range(req, nodeid_in, inarg, NULL);
2474 const void *op_in,
const void *in_payload)
2477 req->flags.is_copy_file_range_64 = 1;
2479 if (
sizeof(
size_t) == 4)
2480 _do_copy_file_range(req, nodeid_in, op_in, NULL);
2482 copy_file_range_common(req, nodeid_in, op_in);
2488 _do_copy_file_range_64(req, nodeid_in, inarg, NULL);
2496 const void *op_in,
const void *in_payload)
2499 const struct fuse_lseek_in *arg = op_in;
2502 memset(&fi, 0,
sizeof(fi));
2505 if (req->se->op.lseek)
2506 req->se->op.lseek(req, nodeid, arg->offset, arg->whence, &fi);
2513 _do_lseek(req, nodeid, inarg, NULL);
2518 const void *op_in,
const void *in_payload)
2521 const struct fuse_statx_in *arg = op_in;
2525 if (arg->getattr_flags & FUSE_GETATTR_FH) {
2526 memset(&fi, 0,
sizeof(fi));
2531 if (req->se->op.statx)
2532 req->se->op.statx(req, nodeid, arg->sx_flags, arg->sx_mask, fip);
2538 const void *op_in,
const void *in_payload)
2549 _do_statx(req, nodeid, inarg, NULL);
2552static bool want_flags_valid(uint64_t capable, uint64_t want)
2554 uint64_t unknown_flags = want & (~capable);
2555 if (unknown_flags != 0) {
2557 "fuse: unknown connection 'want' flags: 0x%08llx\n",
2558 (
unsigned long long)unknown_flags);
2569 struct fuse_session *se = container_of(conn,
struct fuse_session, conn);
2580 if (conn->
want != se->conn_want &&
2582 if (conn->
want_ext != se->conn_want_ext) {
2584 "%s: Both conn->want_ext and conn->want are set.\n"
2585 "want=%x want_ext=%llx, se->want=%x se->want_ext=%llx\n",
2586 __func__, conn->
want,
2587 (
unsigned long long)conn->
want_ext,
2589 (
unsigned long long)se->conn_want_ext);
2607 struct fuse_session *se = container_of(conn,
struct fuse_session, conn);
2611 se->conn_want_ext |= flag;
2613 se->conn_want |= flag;
2622 struct fuse_session *se = container_of(conn,
struct fuse_session, conn);
2625 se->conn_want_ext &= ~flag;
2626 conn->
want &= ~flag;
2627 se->conn_want &= ~flag;
2638static __attribute__((no_sanitize(
"thread"))) void
2640 const
void *in_payload)
2643 const struct fuse_init_in *arg = op_in;
2644 struct fuse_init_out outarg;
2645 struct fuse_session *se = req->se;
2646 size_t bufsize = se->bufsize;
2647 size_t outargsize =
sizeof(outarg);
2648 uint64_t inargflags = 0;
2649 uint64_t outargflags = 0;
2650 bool buf_reallocable = se->buf_reallocable;
2652 bool enable_io_uring =
false;
2655 fuse_log(FUSE_LOG_DEBUG,
"INIT: %u.%u\n", arg->major, arg->minor);
2656 if (arg->major == 7 && arg->minor >= 6) {
2657 fuse_log(FUSE_LOG_DEBUG,
"flags=0x%08x\n", arg->flags);
2658 fuse_log(FUSE_LOG_DEBUG,
"max_readahead=0x%08x\n",
2659 arg->max_readahead);
2662 se->conn.proto_major = arg->major;
2663 se->conn.proto_minor = arg->minor;
2664 se->conn.capable_ext = 0;
2665 se->conn.want_ext = 0;
2667 memset(&outarg, 0,
sizeof(outarg));
2668 outarg.major = FUSE_KERNEL_VERSION;
2669 outarg.minor = FUSE_KERNEL_MINOR_VERSION;
2671 if (arg->major < 7) {
2672 fuse_log(FUSE_LOG_ERR,
"fuse: unsupported protocol version: %u.%u\n",
2673 arg->major, arg->minor);
2678 if (arg->major > 7) {
2680 send_reply_ok(req, &outarg,
sizeof(outarg));
2684 if (arg->minor >= 6) {
2685 if (arg->max_readahead < se->conn.max_readahead)
2686 se->conn.max_readahead = arg->max_readahead;
2687 inargflags = arg->flags;
2688 if (inargflags & FUSE_INIT_EXT)
2689 inargflags = inargflags | (uint64_t) arg->flags2 << 32;
2690 if (inargflags & FUSE_ASYNC_READ)
2692 if (inargflags & FUSE_POSIX_LOCKS)
2694 if (inargflags & FUSE_ATOMIC_O_TRUNC)
2696 if (inargflags & FUSE_EXPORT_SUPPORT)
2698 if (inargflags & FUSE_DONT_MASK)
2700 if (inargflags & FUSE_FLOCK_LOCKS)
2702 if (inargflags & FUSE_AUTO_INVAL_DATA)
2704 if (inargflags & FUSE_DO_READDIRPLUS)
2706 if (inargflags & FUSE_READDIRPLUS_AUTO)
2708 if (inargflags & FUSE_ASYNC_DIO)
2710 if (inargflags & FUSE_WRITEBACK_CACHE)
2712 if (inargflags & FUSE_NO_OPEN_SUPPORT)
2714 if (inargflags & FUSE_PARALLEL_DIROPS)
2716 if (inargflags & FUSE_POSIX_ACL)
2718 if (inargflags & FUSE_HANDLE_KILLPRIV)
2720 if (inargflags & FUSE_HANDLE_KILLPRIV_V2)
2722 if (inargflags & FUSE_CACHE_SYMLINKS)
2724 if (inargflags & FUSE_NO_OPENDIR_SUPPORT)
2726 if (inargflags & FUSE_EXPLICIT_INVAL_DATA)
2728 if (inargflags & FUSE_SETXATTR_EXT)
2730 if (!(inargflags & FUSE_MAX_PAGES)) {
2731 size_t max_bufsize =
2732 FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
2733 + FUSE_BUFFER_HEADER_SIZE;
2734 if (bufsize > max_bufsize) {
2735 bufsize = max_bufsize;
2737 buf_reallocable =
false;
2739 if (inargflags & FUSE_DIRECT_IO_ALLOW_MMAP)
2741 if (arg->minor >= 38 || (inargflags & FUSE_HAS_EXPIRE_ONLY))
2743 if (inargflags & FUSE_PASSTHROUGH)
2745 if (inargflags & FUSE_NO_EXPORT_SUPPORT)
2747 if (inargflags & FUSE_OVER_IO_URING)
2751 se->conn.max_readahead = 0;
2754 if (se->conn.proto_minor >= 14) {
2757 if ((se->io == NULL) || (se->io->splice_send != NULL)) {
2762 if ((se->io == NULL) || (se->io->splice_receive != NULL)) {
2767 if (se->conn.proto_minor >= 18)
2777#define LL_SET_DEFAULT(cond, cap) \
2779 fuse_set_feature_flag(&se->conn, cap)
2787 LL_SET_DEFAULT(se->op.getlk && se->op.setlk,
2791 LL_SET_DEFAULT(se->op.readdirplus && se->op.readdir,
2800 se->conn.time_gran = 1;
2804 se->conn.capable = fuse_lower_32_bits(se->conn.capable_ext);
2806 se->op.init(se->userdata, &se->conn);
2816 if (!want_flags_valid(se->conn.capable_ext, se->conn.want_ext)) {
2818 se->error = -EPROTO;
2823 unsigned max_read_mo = get_max_read(se->mo);
2824 if (se->conn.max_read != max_read_mo) {
2825 fuse_log(FUSE_LOG_ERR,
"fuse: error: init() and fuse_session_new() "
2826 "requested different maximum read size (%u vs %u)\n",
2827 se->conn.max_read, max_read_mo);
2829 se->error = -EPROTO;
2834 if (bufsize < FUSE_MIN_READ_BUFFER) {
2836 "fuse: warning: buffer size too small: %zu\n",
2838 bufsize = FUSE_MIN_READ_BUFFER;
2841 if (buf_reallocable)
2843 se->conn.max_write = MIN(se->conn.max_write, bufsize - FUSE_BUFFER_HEADER_SIZE);
2844 se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
2846 if (arg->flags & FUSE_MAX_PAGES) {
2847 outarg.flags |= FUSE_MAX_PAGES;
2848 outarg.max_pages = (se->conn.max_write - 1) / getpagesize() + 1;
2850 outargflags = outarg.flags;
2853 outargflags |= FUSE_BIG_WRITES;
2856 outargflags |= FUSE_ASYNC_READ;
2858 outargflags |= FUSE_POSIX_LOCKS;
2860 outargflags |= FUSE_ATOMIC_O_TRUNC;
2862 outargflags |= FUSE_EXPORT_SUPPORT;
2864 outargflags |= FUSE_DONT_MASK;
2866 outargflags |= FUSE_FLOCK_LOCKS;
2868 outargflags |= FUSE_AUTO_INVAL_DATA;
2870 outargflags |= FUSE_DO_READDIRPLUS;
2872 outargflags |= FUSE_READDIRPLUS_AUTO;
2874 outargflags |= FUSE_ASYNC_DIO;
2876 outargflags |= FUSE_WRITEBACK_CACHE;
2878 outargflags |= FUSE_PARALLEL_DIROPS;
2880 outargflags |= FUSE_POSIX_ACL;
2882 outargflags |= FUSE_HANDLE_KILLPRIV;
2884 outargflags |= FUSE_HANDLE_KILLPRIV_V2;
2886 outargflags |= FUSE_CACHE_SYMLINKS;
2888 outargflags |= FUSE_EXPLICIT_INVAL_DATA;
2890 outargflags |= FUSE_SETXATTR_EXT;
2892 outargflags |= FUSE_DIRECT_IO_ALLOW_MMAP;
2894 outargflags |= FUSE_PASSTHROUGH;
2899 outarg.max_stack_depth = se->conn.max_backing_stack_depth + 1;
2902 outargflags |= FUSE_NO_EXPORT_SUPPORT;
2904 outargflags |= FUSE_OVER_IO_URING;
2905 enable_io_uring =
true;
2908 if ((inargflags & FUSE_REQUEST_TIMEOUT) && se->conn.request_timeout) {
2909 outargflags |= FUSE_REQUEST_TIMEOUT;
2910 outarg.request_timeout = se->conn.request_timeout;
2913 outarg.max_readahead = se->conn.max_readahead;
2914 outarg.max_write = se->conn.max_write;
2915 if (se->conn.proto_minor >= 13) {
2916 if (se->conn.max_background >= (1 << 16))
2917 se->conn.max_background = (1 << 16) - 1;
2918 if (se->conn.congestion_threshold > se->conn.max_background)
2919 se->conn.congestion_threshold = se->conn.max_background;
2920 if (!se->conn.congestion_threshold) {
2921 se->conn.congestion_threshold =
2922 se->conn.max_background * 3 / 4;
2925 outarg.max_background = se->conn.max_background;
2926 outarg.congestion_threshold = se->conn.congestion_threshold;
2928 if (se->conn.proto_minor >= 23)
2929 outarg.time_gran = se->conn.time_gran;
2932 fuse_log(FUSE_LOG_DEBUG,
" INIT: %u.%u\n", outarg.major, outarg.minor);
2933 fuse_log(FUSE_LOG_DEBUG,
" flags=0x%08x\n", outarg.flags);
2934 fuse_log(FUSE_LOG_DEBUG,
" max_readahead=0x%08x\n",
2935 outarg.max_readahead);
2936 fuse_log(FUSE_LOG_DEBUG,
" max_write=0x%08x\n", outarg.max_write);
2937 fuse_log(FUSE_LOG_DEBUG,
" max_background=%i\n",
2938 outarg.max_background);
2939 fuse_log(FUSE_LOG_DEBUG,
" congestion_threshold=%i\n",
2940 outarg.congestion_threshold);
2941 fuse_log(FUSE_LOG_DEBUG,
" time_gran=%u\n",
2944 fuse_log(FUSE_LOG_DEBUG,
" max_stack_depth=%u\n",
2945 outarg.max_stack_depth);
2948 outargsize = FUSE_COMPAT_INIT_OUT_SIZE;
2949 else if (arg->minor < 23)
2950 outargsize = FUSE_COMPAT_22_INIT_OUT_SIZE;
2953 if (enable_io_uring) {
2954 int ring_rc = fuse_uring_start(se);
2958 "fuse: failed to start io-uring: %s\n",
2960 outargflags &= ~FUSE_OVER_IO_URING;
2961 enable_io_uring =
false;
2965 if (inargflags & FUSE_INIT_EXT) {
2966 outargflags |= FUSE_INIT_EXT;
2967 outarg.flags2 = outargflags >> 32;
2969 outarg.flags = outargflags;
2978 send_reply_ok(req, &outarg, outargsize);
2979 if (enable_io_uring)
2980 fuse_uring_wake_ring_threads(se);
2983static __attribute__((no_sanitize(
"thread"))) void
2986 _do_init(req, nodeid, inarg, NULL);
2990 const void *op_in,
const void *in_payload)
2992 struct fuse_session *se = req->se;
2999 mountpoint = atomic_exchange(&se->mountpoint, NULL);
3002 se->got_destroy = 1;
3005 se->op.destroy(se->userdata);
3007 send_reply_ok(req, NULL, 0);
3012 _do_destroy(req, nodeid, inarg, NULL);
3015static void list_del_nreq(
struct fuse_notify_req *nreq)
3017 struct fuse_notify_req *prev = nreq->prev;
3018 struct fuse_notify_req *next = nreq->next;
3023static void list_add_nreq(
struct fuse_notify_req *nreq,
3024 struct fuse_notify_req *next)
3026 struct fuse_notify_req *prev = next->prev;
3033static void list_init_nreq(
struct fuse_notify_req *nreq)
3040 const void *inarg,
const struct fuse_buf *buf)
3042 struct fuse_session *se = req->se;
3043 struct fuse_notify_req *nreq;
3044 struct fuse_notify_req *head;
3046 pthread_mutex_lock(&se->lock);
3047 head = &se->notify_list;
3048 for (nreq = head->next; nreq != head; nreq = nreq->next) {
3049 if (nreq->unique == req->unique) {
3050 list_del_nreq(nreq);
3054 pthread_mutex_unlock(&se->lock);
3057 nreq->reply(nreq, req, nodeid, inarg, buf);
3060static int send_notify_iov(
struct fuse_session *se,
int notify_code,
3061 struct iovec *iov,
int count)
3063 struct fuse_out_header out;
3064 struct fuse_req *req = NULL;
3070 out.error = notify_code;
3071 iov[0].iov_base = &out;
3072 iov[0].iov_len =
sizeof(
struct fuse_out_header);
3074 return fuse_send_msg(se, NULL, iov, count, req);
3080 struct fuse_notify_poll_wakeup_out outarg;
3081 struct iovec iov[2];
3085 iov[1].iov_base = &outarg;
3086 iov[1].iov_len =
sizeof(outarg);
3088 return send_notify_iov(ph->se, FUSE_NOTIFY_POLL, iov, 2);
3095 off_t off, off_t len)
3097 struct fuse_notify_inval_inode_out outarg;
3098 struct iovec iov[2];
3103 if (se->conn.proto_minor < 12)
3110 iov[1].iov_base = &outarg;
3111 iov[1].iov_len =
sizeof(outarg);
3113 return send_notify_iov(se, FUSE_NOTIFY_INVAL_INODE, iov, 2);
3118 struct iovec iov[1];
3123 if (se->conn.proto_minor < 44)
3126 return send_notify_iov(se, FUSE_NOTIFY_INC_EPOCH, iov, 1);
3148static int fuse_lowlevel_notify_entry(
struct fuse_session *se,
fuse_ino_t parent,
3149 const char *name,
size_t namelen,
3152 struct fuse_notify_inval_entry_out outarg;
3153 struct iovec iov[3];
3158 if (se->conn.proto_minor < 12)
3161 outarg.parent = parent;
3162 outarg.namelen = namelen;
3164 if (flags & FUSE_LL_EXPIRE_ONLY)
3165 outarg.flags |= FUSE_EXPIRE_ONLY;
3167 iov[1].iov_base = &outarg;
3168 iov[1].iov_len =
sizeof(outarg);
3169 iov[2].iov_base = (
void *)name;
3170 iov[2].iov_len = namelen + 1;
3172 return send_notify_iov(se, FUSE_NOTIFY_INVAL_ENTRY, iov, 3);
3176 const char *name,
size_t namelen)
3178 return fuse_lowlevel_notify_entry(se, parent, name, namelen, FUSE_LL_INVALIDATE);
3182 const char *name,
size_t namelen)
3190 return fuse_lowlevel_notify_entry(se, parent, name, namelen, FUSE_LL_EXPIRE_ONLY);
3196 const char *name,
size_t namelen)
3198 struct fuse_notify_delete_out outarg;
3199 struct iovec iov[3];
3204 if (se->conn.proto_minor < 18)
3207 outarg.parent = parent;
3208 outarg.child = child;
3209 outarg.namelen = namelen;
3212 iov[1].iov_base = &outarg;
3213 iov[1].iov_len =
sizeof(outarg);
3214 iov[2].iov_base = (
void *)name;
3215 iov[2].iov_len = namelen + 1;
3217 return send_notify_iov(se, FUSE_NOTIFY_DELETE, iov, 3);
3224 struct fuse_out_header out;
3225 struct fuse_notify_store_out outarg;
3226 struct iovec iov[3];
3229 struct fuse_req *req = NULL;
3234 if (se->conn.proto_minor < 15)
3238 out.error = FUSE_NOTIFY_STORE;
3240 outarg.nodeid = ino;
3241 outarg.offset = offset;
3245 iov[0].iov_base = &out;
3246 iov[0].iov_len =
sizeof(out);
3247 iov[1].iov_base = &outarg;
3248 iov[1].iov_len =
sizeof(outarg);
3250 res = fuse_send_data_iov(se, NULL, iov, 2, bufv, flags, req);
3257struct fuse_retrieve_req {
3258 struct fuse_notify_req nreq;
3262static void fuse_ll_retrieve_reply(
struct fuse_notify_req *nreq,
3267 struct fuse_session *se = req->se;
3268 struct fuse_retrieve_req *rreq =
3269 container_of(nreq,
struct fuse_retrieve_req, nreq);
3270 const struct fuse_notify_retrieve_in *arg = inarg;
3277 bufv.
buf[0].
mem = PARAM(arg);
3279 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
3280 sizeof(struct fuse_notify_retrieve_in);
3282 if (bufv.
buf[0].
size < arg->size) {
3283 fuse_log(FUSE_LOG_ERR,
"fuse: retrieve reply: buffer size too small\n");
3289 if (se->op.retrieve_reply) {
3290 se->op.retrieve_reply(req, rreq->cookie, ino,
3291 arg->offset, &bufv);
3298 fuse_ll_clear_pipe(se);
3302 size_t size, off_t offset,
void *cookie)
3304 struct fuse_notify_retrieve_out outarg;
3305 struct iovec iov[2];
3306 struct fuse_retrieve_req *rreq;
3312 if (se->conn.proto_minor < 15)
3315 rreq = malloc(
sizeof(*rreq));
3319 pthread_mutex_lock(&se->lock);
3320 rreq->cookie = cookie;
3321 rreq->nreq.unique = se->notify_ctr++;
3322 rreq->nreq.reply = fuse_ll_retrieve_reply;
3323 list_add_nreq(&rreq->nreq, &se->notify_list);
3324 pthread_mutex_unlock(&se->lock);
3326 outarg.notify_unique = rreq->nreq.unique;
3327 outarg.nodeid = ino;
3328 outarg.offset = offset;
3332 iov[1].iov_base = &outarg;
3333 iov[1].iov_len =
sizeof(outarg);
3335 err = send_notify_iov(se, FUSE_NOTIFY_RETRIEVE, iov, 2);
3337 pthread_mutex_lock(&se->lock);
3338 list_del_nreq(&rreq->nreq);
3339 pthread_mutex_unlock(&se->lock);
3348 return req->se->userdata;
3359 pthread_mutex_lock(&req->lock);
3360 pthread_mutex_lock(&req->se->lock);
3361 req->u.ni.func = func;
3362 req->u.ni.data = data;
3363 pthread_mutex_unlock(&req->se->lock);
3364 if (req->interrupted && func)
3366 pthread_mutex_unlock(&req->lock);
3373 pthread_mutex_lock(&req->se->lock);
3374 interrupted = req->interrupted;
3375 pthread_mutex_unlock(&req->se->lock);
3382 return req->flags.is_uring;
3401 [FUSE_LOOKUP] = { do_lookup,
"LOOKUP" },
3402 [FUSE_FORGET] = { do_forget,
"FORGET" },
3403 [FUSE_GETATTR] = { do_getattr,
"GETATTR" },
3404 [FUSE_SETATTR] = { do_setattr,
"SETATTR" },
3405 [FUSE_READLINK] = { do_readlink,
"READLINK" },
3406 [FUSE_SYMLINK] = { do_symlink,
"SYMLINK" },
3407 [FUSE_MKNOD] = { do_mknod,
"MKNOD" },
3408 [FUSE_MKDIR] = { do_mkdir,
"MKDIR" },
3409 [FUSE_UNLINK] = { do_unlink,
"UNLINK" },
3410 [FUSE_RMDIR] = { do_rmdir,
"RMDIR" },
3411 [FUSE_RENAME] = { do_rename,
"RENAME" },
3412 [FUSE_LINK] = { do_link,
"LINK" },
3413 [FUSE_OPEN] = { do_open,
"OPEN" },
3414 [FUSE_READ] = { do_read,
"READ" },
3415 [FUSE_WRITE] = { do_write,
"WRITE" },
3416 [FUSE_STATFS] = { do_statfs,
"STATFS" },
3417 [FUSE_RELEASE] = { do_release,
"RELEASE" },
3418 [FUSE_FSYNC] = { do_fsync,
"FSYNC" },
3419 [FUSE_SETXATTR] = { do_setxattr,
"SETXATTR" },
3420 [FUSE_GETXATTR] = { do_getxattr,
"GETXATTR" },
3421 [FUSE_LISTXATTR] = { do_listxattr,
"LISTXATTR" },
3422 [FUSE_REMOVEXATTR] = { do_removexattr,
"REMOVEXATTR" },
3423 [FUSE_FLUSH] = { do_flush,
"FLUSH" },
3424 [FUSE_INIT] = { do_init,
"INIT" },
3425 [FUSE_OPENDIR] = { do_opendir,
"OPENDIR" },
3426 [FUSE_READDIR] = { do_readdir,
"READDIR" },
3427 [FUSE_RELEASEDIR] = { do_releasedir,
"RELEASEDIR" },
3428 [FUSE_FSYNCDIR] = { do_fsyncdir,
"FSYNCDIR" },
3429 [FUSE_GETLK] = { do_getlk,
"GETLK" },
3430 [FUSE_SETLK] = { do_setlk,
"SETLK" },
3431 [FUSE_SETLKW] = { do_setlkw,
"SETLKW" },
3432 [FUSE_ACCESS] = { do_access,
"ACCESS" },
3433 [FUSE_CREATE] = { do_create,
"CREATE" },
3434 [FUSE_TMPFILE] = { do_tmpfile,
"TMPFILE" },
3435 [FUSE_INTERRUPT] = { do_interrupt,
"INTERRUPT" },
3436 [FUSE_BMAP] = { do_bmap,
"BMAP" },
3437 [FUSE_IOCTL] = { do_ioctl,
"IOCTL" },
3438 [FUSE_POLL] = { do_poll,
"POLL" },
3439 [FUSE_FALLOCATE] = { do_fallocate,
"FALLOCATE" },
3440 [FUSE_DESTROY] = { do_destroy,
"DESTROY" },
3441 [FUSE_NOTIFY_REPLY] = { (
void *) 1,
"NOTIFY_REPLY" },
3442 [FUSE_BATCH_FORGET] = { do_batch_forget,
"BATCH_FORGET" },
3443 [FUSE_READDIRPLUS] = { do_readdirplus,
"READDIRPLUS"},
3444 [FUSE_RENAME2] = { do_rename2,
"RENAME2" },
3445 [FUSE_COPY_FILE_RANGE] = { do_copy_file_range,
"COPY_FILE_RANGE" },
3446 [FUSE_COPY_FILE_RANGE_64] = { do_copy_file_range_64,
"COPY_FILE_RANGE_64" },
3447 [FUSE_LSEEK] = { do_lseek,
"LSEEK" },
3448 [FUSE_STATX] = { do_statx,
"STATX" },
3449 [CUSE_INIT] = { cuse_lowlevel_init,
"CUSE_INIT" },
3454 const void *op_payload);
3456} fuse_ll_ops2[] __attribute__((unused)) = {
3457 [FUSE_LOOKUP] = { _do_lookup,
"LOOKUP" },
3458 [FUSE_FORGET] = { _do_forget,
"FORGET" },
3459 [FUSE_GETATTR] = { _do_getattr,
"GETATTR" },
3460 [FUSE_SETATTR] = { _do_setattr,
"SETATTR" },
3461 [FUSE_READLINK] = { _do_readlink,
"READLINK" },
3462 [FUSE_SYMLINK] = { _do_symlink,
"SYMLINK" },
3463 [FUSE_MKNOD] = { _do_mknod,
"MKNOD" },
3464 [FUSE_MKDIR] = { _do_mkdir,
"MKDIR" },
3465 [FUSE_UNLINK] = { _do_unlink,
"UNLINK" },
3466 [FUSE_RMDIR] = { _do_rmdir,
"RMDIR" },
3467 [FUSE_RENAME] = { _do_rename,
"RENAME" },
3468 [FUSE_LINK] = { _do_link,
"LINK" },
3469 [FUSE_OPEN] = { _do_open,
"OPEN" },
3470 [FUSE_READ] = { _do_read,
"READ" },
3471 [FUSE_WRITE] = { _do_write,
"WRITE" },
3472 [FUSE_STATFS] = { _do_statfs,
"STATFS" },
3473 [FUSE_RELEASE] = { _do_release,
"RELEASE" },
3474 [FUSE_FSYNC] = { _do_fsync,
"FSYNC" },
3475 [FUSE_SETXATTR] = { _do_setxattr,
"SETXATTR" },
3476 [FUSE_GETXATTR] = { _do_getxattr,
"GETXATTR" },
3477 [FUSE_LISTXATTR] = { _do_listxattr,
"LISTXATTR" },
3478 [FUSE_REMOVEXATTR] = { _do_removexattr,
"REMOVEXATTR" },
3479 [FUSE_FLUSH] = { _do_flush,
"FLUSH" },
3480 [FUSE_INIT] = { _do_init,
"INIT" },
3481 [FUSE_OPENDIR] = { _do_opendir,
"OPENDIR" },
3482 [FUSE_READDIR] = { _do_readdir,
"READDIR" },
3483 [FUSE_RELEASEDIR] = { _do_releasedir,
"RELEASEDIR" },
3484 [FUSE_FSYNCDIR] = { _do_fsyncdir,
"FSYNCDIR" },
3485 [FUSE_GETLK] = { _do_getlk,
"GETLK" },
3486 [FUSE_SETLK] = { _do_setlk,
"SETLK" },
3487 [FUSE_SETLKW] = { _do_setlkw,
"SETLKW" },
3488 [FUSE_ACCESS] = { _do_access,
"ACCESS" },
3489 [FUSE_CREATE] = { _do_create,
"CREATE" },
3490 [FUSE_TMPFILE] = { _do_tmpfile,
"TMPFILE" },
3491 [FUSE_INTERRUPT] = { _do_interrupt,
"INTERRUPT" },
3492 [FUSE_BMAP] = { _do_bmap,
"BMAP" },
3493 [FUSE_IOCTL] = { _do_ioctl,
"IOCTL" },
3494 [FUSE_POLL] = { _do_poll,
"POLL" },
3495 [FUSE_FALLOCATE] = { _do_fallocate,
"FALLOCATE" },
3496 [FUSE_DESTROY] = { _do_destroy,
"DESTROY" },
3497 [FUSE_NOTIFY_REPLY] = { (
void *)1,
"NOTIFY_REPLY" },
3498 [FUSE_BATCH_FORGET] = { _do_batch_forget,
"BATCH_FORGET" },
3499 [FUSE_READDIRPLUS] = { _do_readdirplus,
"READDIRPLUS" },
3500 [FUSE_RENAME2] = { _do_rename2,
"RENAME2" },
3501 [FUSE_COPY_FILE_RANGE] = { _do_copy_file_range,
"COPY_FILE_RANGE" },
3502 [FUSE_COPY_FILE_RANGE_64] = { _do_copy_file_range_64,
"COPY_FILE_RANGE_64" },
3503 [FUSE_LSEEK] = { _do_lseek,
"LSEEK" },
3504 [FUSE_STATX] = { _do_statx,
"STATX" },
3505 [CUSE_INIT] = { _cuse_lowlevel_init,
"CUSE_INIT" },
3513#define FUSE_MAXOP (CUSE_INIT + 1)
3521fuse_req_opcode_sanity_ok(
struct fuse_session *se,
enum fuse_opcode in_op)
3525 if (!se->got_init) {
3526 enum fuse_opcode expected;
3528 expected = se->cuse_data ? CUSE_INIT : FUSE_INIT;
3529 if (in_op != expected)
3531 }
else if (in_op == FUSE_INIT || in_op == CUSE_INIT)
3538fuse_session_in2req(
struct fuse_req *req,
struct fuse_in_header *in)
3540 req->unique = in->unique;
3541 req->ctx.uid = in->uid;
3542 req->ctx.gid = in->gid;
3543 req->ctx.pid = in->pid;
3550fuse_req_check_allow_root(
struct fuse_session *se,
enum fuse_opcode in_op,
3555 if (se->deny_others && in_uid != se->owner && in_uid != 0 &&
3556 in_op != FUSE_INIT && in_op != FUSE_READ &&
3557 in_op != FUSE_WRITE && in_op != FUSE_FSYNC &&
3558 in_op != FUSE_RELEASE && in_op != FUSE_READDIR &&
3559 in_op != FUSE_FSYNCDIR && in_op != FUSE_RELEASEDIR &&
3560 in_op != FUSE_NOTIFY_REPLY &&
3561 in_op != FUSE_READDIRPLUS)
3567static const char *opname(
enum fuse_opcode opcode)
3569 if (opcode >= FUSE_MAXOP || !fuse_ll_ops[opcode].name)
3572 return fuse_ll_ops[opcode].name;
3575static int fuse_ll_copy_from_pipe(
struct fuse_bufvec *dst,
3580 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n", strerror(-res));
3584 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: short read\n");
3593 fuse_session_process_buf_internal(se, buf, NULL);
3597void fuse_session_process_buf_internal(
struct fuse_session *se,
3598 const struct fuse_buf *buf,
struct fuse_chan *ch)
3600 const size_t write_header_size =
sizeof(
struct fuse_in_header) +
3601 sizeof(struct fuse_write_in);
3603 struct fuse_bufvec tmpbuf = FUSE_BUFVEC_INIT(write_header_size);
3604 struct fuse_in_header *in;
3606 struct fuse_req *req;
3615 mbuf = malloc(tmpbuf.
buf[0].
size);
3617 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate header\n");
3620 tmpbuf.
buf[0].
mem = mbuf;
3622 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
3631 trace_request_process(in->opcode, in->unique);
3635 "dev unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n",
3636 (
unsigned long long) in->unique,
3637 opname((
enum fuse_opcode) in->opcode), in->opcode,
3638 (
unsigned long long) in->nodeid, buf->
size, in->pid);
3641 req = fuse_ll_alloc_req(se);
3643 struct fuse_out_header out = {
3644 .unique = in->unique,
3647 struct iovec iov = {
3649 .iov_len =
sizeof(
struct fuse_out_header),
3652 fuse_send_msg(se, ch, &iov, 1, NULL);
3656 fuse_session_in2req(req, in);
3657 req->ch = ch ? fuse_chan_get(ch) : NULL;
3659 err = fuse_req_opcode_sanity_ok(se, in->opcode);
3663 err = fuse_req_check_allow_root(se, in->opcode, in->uid);
3668 if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func)
3671 if (se->conn.no_interrupt && in->opcode == FUSE_INTERRUPT) {
3673 fuse_log(FUSE_LOG_DEBUG,
"FUSE_INTERRUPT: reply to kernel to disable interrupt\n");
3676 if (!se->conn.no_interrupt && in->opcode != FUSE_INTERRUPT) {
3677 struct fuse_req *intr;
3678 pthread_mutex_lock(&se->lock);
3679 intr = check_interrupt(se, req);
3680 list_add_req(req, &se->list);
3681 pthread_mutex_unlock(&se->lock);
3687 (in->opcode != FUSE_WRITE || !se->op.write_buf) &&
3688 in->opcode != FUSE_NOTIFY_REPLY) {
3692 newmbuf = realloc(mbuf, buf->
size);
3693 if (newmbuf == NULL)
3697 tmpbuf = FUSE_BUFVEC_INIT(buf->
size - write_header_size);
3698 tmpbuf.
buf[0].
mem = (
char *)mbuf + write_header_size;
3700 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
3708 inarg = (
void *) &in[1];
3709 if (in->opcode == FUSE_WRITE && se->op.write_buf)
3710 do_write_buf(req, in->nodeid, inarg, buf);
3711 else if (in->opcode == FUSE_NOTIFY_REPLY)
3712 do_notify_reply(req, in->nodeid, inarg, buf);
3714 fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
3724 fuse_ll_clear_pipe(se);
3728void fuse_session_process_uring_cqe(
struct fuse_session *se,
3729 struct fuse_req *req,
3730 struct fuse_in_header *in,
void *op_in,
3731 void *op_payload,
size_t payload_len)
3735 fuse_session_in2req(req, in);
3737 err = fuse_req_opcode_sanity_ok(se, in->opcode);
3741 err = fuse_req_check_allow_root(se, in->opcode, in->uid);
3746 if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func)
3752 "cqe unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n",
3753 (
unsigned long long)in->unique,
3754 opname((
enum fuse_opcode)in->opcode), in->opcode,
3755 (
unsigned long long)in->nodeid, payload_len, in->pid);
3758 if (in->opcode == FUSE_WRITE && se->op.write_buf) {
3760 .
buf[0] = { .
size = payload_len,
3762 .mem = op_payload },
3765 _do_write_buf(req, in->nodeid, op_in, &bufv);
3766 }
else if (in->opcode == FUSE_NOTIFY_REPLY) {
3768 .mem = op_payload };
3769 do_notify_reply(req, in->nodeid, op_in, &buf);
3771 fuse_ll_ops2[in->opcode].func(req, in->nodeid, op_in,
3781#define LL_OPTION(n,o,v) \
3782 { n, offsetof(struct fuse_session, o), v }
3784static const struct fuse_opt fuse_ll_opts[] = {
3785 LL_OPTION(
"debug", debug, 1),
3786 LL_OPTION(
"-d", debug, 1),
3787 LL_OPTION(
"--debug", debug, 1),
3788 LL_OPTION(
"allow_root", deny_others, 1),
3789 LL_OPTION(
"io_uring", uring.enable, 1),
3790 LL_OPTION(
"io_uring_q_depth=%u", uring.q_depth, -1),
3796 printf(
"using FUSE kernel interface version %i.%i\n",
3797 FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
3798 fuse_mount_version();
3806" -o allow_other allow access by all users\n"
3807" -o allow_root allow access by root\n"
3808" -o auto_unmount auto unmount on process termination\n"
3809" -o io_uring enable io-uring\n"
3810" -o io_uring_q_depth=<n> io-uring queue depth\n"
3816 struct fuse_ll_pipe *llp;
3818 if (se->got_init && !se->got_destroy) {
3820 se->op.destroy(se->userdata);
3822 llp = pthread_getspecific(se->pipe_key);
3824 fuse_ll_pipe_free(llp);
3825 pthread_key_delete(se->pipe_key);
3826 sem_destroy(&se->mt_finish);
3827 pthread_mutex_destroy(&se->mt_lock);
3828 pthread_mutex_destroy(&se->lock);
3829 free(se->cuse_data);
3834 destroy_mount_opts(se->mo);
3839static void fuse_ll_pipe_destructor(
void *data)
3841 struct fuse_ll_pipe *llp = data;
3842 fuse_ll_pipe_free(llp);
3845void fuse_buf_free(
struct fuse_buf *buf)
3847 if (buf->
mem == NULL)
3850 size_t write_header_sz =
3851 sizeof(
struct fuse_in_header) + sizeof(struct fuse_write_in);
3853 char *ptr = (
char *)buf->
mem - pagesize + write_header_sz;
3861static void *buf_alloc(
size_t size,
bool internal)
3869 size_t write_header_sz =
sizeof(
struct fuse_in_header) +
3870 sizeof(struct fuse_write_in);
3871 size_t new_size = ROUND_UP(size + write_header_sz, pagesize);
3873 char *buf = aligned_alloc(pagesize, new_size);
3877 buf += pagesize - write_header_sz;
3881 return malloc(size);
3888static int _fuse_session_receive_buf(
struct fuse_session *se,
3889 struct fuse_buf *buf,
struct fuse_chan *ch,
3896 struct fuse_ll_pipe *llp;
3900 bufsize = se->bufsize;
3902 if (se->conn.proto_minor < 14 ||
3906 llp = fuse_ll_get_pipe(se);
3910 if (llp->size < bufsize) {
3911 if (llp->can_grow) {
3912 res = fcntl(llp->pipe[0], F_SETPIPE_SZ, bufsize);
3915 res = grow_pipe_to_max(llp->pipe[0]);
3922 if (llp->size < bufsize)
3926 if (se->io != NULL && se->io->splice_receive != NULL) {
3927 res = se->io->splice_receive(ch ? ch->fd : se->
fd, NULL,
3928 llp->pipe[1], NULL, bufsize, 0,
3931 res = splice(ch ? ch->fd : se->
fd, NULL, llp->pipe[1], NULL,
3935 trace_request_receive(err);
3941 if (err == ENODEV) {
3949 if (err == EINVAL && bufsize < se->bufsize) {
3950 fuse_ll_clear_pipe(se);
3954 if (err != EINTR && err != EAGAIN)
3955 perror(
"fuse: splice from device");
3959 if (res <
sizeof(
struct fuse_in_header)) {
3960 fuse_log(FUSE_LOG_ERR,
"short splice from fuse device\n");
3975 if (res <
sizeof(
struct fuse_in_header) +
sizeof(
struct fuse_write_in) +
3981 buf->
mem = buf_alloc(bufsize, internal);
3985 "fuse: failed to allocate read buffer\n");
3996 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n",
3998 fuse_ll_clear_pipe(se);
4001 if (res < tmpbuf.size) {
4003 "fuse: copy from pipe: short read\n");
4004 fuse_ll_clear_pipe(se);
4007 assert(res == tmpbuf.size);
4011 buf->
fd = tmpbuf.fd;
4022 bufsize = se->bufsize;
4023 buf->
mem = buf_alloc(bufsize, internal);
4026 "fuse: failed to allocate read buffer\n");
4035 if (se->io != NULL) {
4038 res = se->io->read(ch ? ch->fd : se->fd,
buf->mem, bufsize,
4041 res = read(ch ? ch->fd : se->fd,
buf->mem, bufsize);
4044 trace_request_receive(err);
4049 if (err == EINVAL && internal && se->bufsize > bufsize) {
4051 bufsize = se->bufsize;
4052 void *newbuf = buf_alloc(bufsize, internal);
4056 "fuse: failed to (re)allocate read buffer\n");
4070 if (err == ENODEV) {
4079 if (err != EINTR && err != EAGAIN)
4080 perror(
"fuse: reading device");
4083 if ((
size_t)res <
sizeof(
struct fuse_in_header)) {
4084 fuse_log(FUSE_LOG_ERR,
"short read on fuse device\n");
4095 return _fuse_session_receive_buf(se,
buf, NULL,
false);
4099int fuse_session_receive_buf_internal(
struct fuse_session *se,
4101 struct fuse_chan *ch)
4107 if (unlikely(!se->got_init) && !se->buf_reallocable)
4108 se->buf_reallocable =
true;
4110 return _fuse_session_receive_buf(se,
buf, ch,
true);
4113struct fuse_session *
4114fuse_session_new_versioned(
struct fuse_args *args,
4119 struct fuse_session *se;
4120 struct mount_opts *mo;
4122 if (op == NULL || op_size == 0) {
4124 "fuse: warning: empty op list passed to fuse_session_new()\n");
4128 if (version == NULL) {
4129 fuse_log(FUSE_LOG_ERR,
"fuse: warning: version not passed to fuse_session_new()\n");
4134 fuse_log(FUSE_LOG_ERR,
"fuse: warning: library too old, some operations may not work\n");
4138 if (args == NULL || args->
argc == 0) {
4139 fuse_log(FUSE_LOG_ERR,
"fuse: empty argv passed to fuse_session_new().\n");
4143 se = (
struct fuse_session *) calloc(1,
sizeof(
struct fuse_session));
4145 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate fuse object\n");
4149 se->conn.max_write = FUSE_DEFAULT_MAX_PAGES_LIMIT * getpagesize();
4150 se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
4151 se->conn.max_readahead = UINT_MAX;
4157 se->uring.enable = getenv(
"FUSE_URING_ENABLE") ?
4158 atoi(getenv(
"FUSE_URING_ENABLE")) :
4159 SESSION_DEF_URING_ENABLE;
4160 se->uring.q_depth = getenv(
"FUSE_URING_QUEUE_DEPTH") ?
4161 atoi(getenv(
"FUSE_URING_QUEUE_DEPTH")) :
4162 SESSION_DEF_URING_Q_DEPTH;
4167 if(se->deny_others) {
4177 mo = parse_mount_opts(args);
4181 if(args->
argc == 1 &&
4182 args->
argv[0][0] ==
'-') {
4183 fuse_log(FUSE_LOG_ERR,
"fuse: warning: argv[0] looks like an option, but "
4184 "will be ignored\n");
4185 }
else if (args->
argc != 1) {
4187 fuse_log(FUSE_LOG_ERR,
"fuse: unknown option(s): `");
4188 for(i = 1; i < args->
argc-1; i++)
4195 fuse_log(FUSE_LOG_DEBUG,
"FUSE library version: %s\n", PACKAGE_VERSION);
4197 list_init_req(&se->list);
4198 list_init_req(&se->interrupts);
4199 list_init_nreq(&se->notify_list);
4201 pthread_mutex_init(&se->lock, NULL);
4202 sem_init(&se->mt_finish, 0, 0);
4203 pthread_mutex_init(&se->mt_lock, NULL);
4205 err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor);
4207 fuse_log(FUSE_LOG_ERR,
"fuse: failed to create thread specific key: %s\n",
4212 memcpy(&se->op, op, op_size);
4213 se->owner = getuid();
4214 se->userdata = userdata;
4223 se->version = *version;
4228 sem_destroy(&se->mt_finish);
4229 pthread_mutex_destroy(&se->mt_lock);
4230 pthread_mutex_destroy(&se->lock);
4235 destroy_mount_opts(mo);
4242struct fuse_session *fuse_session_new_30(
struct fuse_args *args,
4244 size_t op_size,
void *userdata);
4245struct fuse_session *fuse_session_new_30(
struct fuse_args *args,
4263 op_size =
sizeof(null_ops);
4266 return fuse_session_new_versioned(args, op, op_size, &version,
4270FUSE_SYMVER(
"fuse_session_custom_io_317",
"fuse_session_custom_io@@FUSE_3.17")
4271int fuse_session_custom_io_317(struct fuse_session *se,
4272 const struct fuse_custom_io *io,
size_t op_size,
int fd)
4274 if (
sizeof(
struct fuse_custom_io) < op_size) {
4275 fuse_log(FUSE_LOG_ERR,
"fuse: warning: library too old, some operations may not work\n");
4276 op_size =
sizeof(
struct fuse_custom_io);
4280 fuse_log(FUSE_LOG_ERR,
"Invalid file descriptor value %d passed to "
4281 "fuse_session_custom_io()\n", fd);
4285 fuse_log(FUSE_LOG_ERR,
"No custom IO passed to "
4286 "fuse_session_custom_io()\n");
4288 }
else if (io->read == NULL || io->writev == NULL) {
4293 fuse_log(FUSE_LOG_ERR,
"io passed to fuse_session_custom_io() must "
4294 "implement both io->read() and io->writev\n");
4298 se->io = calloc(1,
sizeof(
struct fuse_custom_io));
4299 if (se->io == NULL) {
4300 fuse_log(FUSE_LOG_ERR,
"Failed to allocate memory for custom io. "
4301 "Error: %s\n", strerror(errno));
4306 memcpy(se->io, io, op_size);
4310int fuse_session_custom_io_30(
struct fuse_session *se,
4311 const struct fuse_custom_io *io,
int fd);
4312FUSE_SYMVER(
"fuse_session_custom_io_30",
"fuse_session_custom_io@FUSE_3.0")
4313int fuse_session_custom_io_30(struct fuse_session *se,
4314 const struct fuse_custom_io *io,
int fd)
4316 return fuse_session_custom_io_317(se, io,
4317 offsetof(
struct fuse_custom_io, clone_fd), fd);
4325 if (_mountpoint == NULL) {
4326 fuse_log(FUSE_LOG_ERR,
"Invalid null-ptr mountpoint!\n");
4330 mountpoint = strdup(_mountpoint);
4331 if (mountpoint == NULL) {
4332 fuse_log(FUSE_LOG_ERR,
"Failed to allocate memory for mountpoint. Error: %s\n",
4342 fd = open(
"/dev/null", O_RDWR);
4345 }
while (fd >= 0 && fd <= 2);
4353 fd = fuse_mnt_parse_fuse_fd(mountpoint);
4355 if (fcntl(fd, F_GETFD) == -1) {
4357 "fuse: Invalid file descriptor /dev/fd/%u\n",
4366 fd = fuse_kern_mount(mountpoint, se->mo);
4372 se->mountpoint = mountpoint;
4388 if (se->mountpoint != NULL) {
4389 char *mountpoint = atomic_exchange(&se->mountpoint, NULL);
4391 fuse_kern_unmount(mountpoint, se->fd);
4401 size_t bufsize = 1024;
4405 unsigned long pid = req->ctx.pid;
4408 sprintf(path,
"/proc/%lu/task/%lu/status", pid, pid);
4411 buf = malloc(bufsize);
4416 fd = open(path, O_RDONLY);
4420 ret = read(fd, buf, bufsize);
4427 if ((
size_t)ret == bufsize) {
4435 s = strstr(buf,
"\nGroups:");
4443 unsigned long val = strtoul(s, &end, 0);
4463 (void) req; (void) size; (void) list;
4470__attribute__((no_sanitize_thread))
4473 atomic_store_explicit(&se->mt_exited, 1, memory_order_relaxed);
4474 sem_post(&se->mt_finish);
4477__attribute__((no_sanitize_thread))
4480 se->mt_exited =
false;
4484__attribute__((no_sanitize_thread))
4488 atomic_load_explicit(&se->mt_exited, memory_order_relaxed);
4490 return exited ? 1 : 0;
#define FUSE_CAP_IOCTL_DIR
#define FUSE_CAP_DONT_MASK
void fuse_unset_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
int fuse_convert_to_conn_want_ext(struct fuse_conn_info *conn)
bool fuse_set_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
#define FUSE_CAP_HANDLE_KILLPRIV
#define FUSE_CAP_AUTO_INVAL_DATA
#define FUSE_CAP_HANDLE_KILLPRIV_V2
#define FUSE_CAP_SPLICE_READ
#define FUSE_CAP_PARALLEL_DIROPS
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
#define FUSE_CAP_WRITEBACK_CACHE
#define FUSE_CAP_EXPIRE_ONLY
#define FUSE_CAP_ATOMIC_O_TRUNC
#define FUSE_CAP_ASYNC_READ
#define FUSE_CAP_SPLICE_WRITE
#define FUSE_CAP_CACHE_SYMLINKS
#define FUSE_CAP_POSIX_ACL
#define FUSE_CAP_EXPORT_SUPPORT
#define FUSE_CAP_POSIX_LOCKS
#define FUSE_CAP_EXPLICIT_INVAL_DATA
#define FUSE_CAP_READDIRPLUS_AUTO
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
#define FUSE_CAP_NO_OPENDIR_SUPPORT
#define FUSE_CAP_ASYNC_DIO
bool fuse_get_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
#define FUSE_CAP_PASSTHROUGH
#define FUSE_CAP_DIRECT_IO_ALLOW_MMAP
#define FUSE_CAP_NO_OPEN_SUPPORT
#define FUSE_CAP_READDIRPLUS
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
@ FUSE_BUF_SPLICE_NONBLOCK
#define FUSE_CAP_SETXATTR_EXT
#define FUSE_CAP_SPLICE_MOVE
#define FUSE_CAP_NO_EXPORT_SUPPORT
#define FUSE_CAP_FLOCK_LOCKS
void fuse_log(enum fuse_log_level level, const char *fmt,...)
void fuse_session_destroy(struct fuse_session *se)
int fuse_reply_data(fuse_req_t req, struct fuse_bufvec *bufv, enum fuse_buf_copy_flags flags)
int fuse_reply_lock(fuse_req_t req, const struct flock *lock)
int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *fi)
void fuse_session_exit(struct fuse_session *se)
void(* fuse_interrupt_func_t)(fuse_req_t req, void *data)
int fuse_reply_poll(fuse_req_t req, unsigned revents)
int fuse_reply_err(fuse_req_t req, int err)
void * fuse_req_userdata(fuse_req_t req)
int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size)
struct fuse_req * fuse_req_t
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_iov(fuse_req_t req, int result, const struct iovec *iov, int count)
int fuse_lowlevel_notify_delete(struct fuse_session *se, fuse_ino_t parent, fuse_ino_t child, const char *name, size_t namelen)
void fuse_session_process_buf(struct fuse_session *se, const struct fuse_buf *buf)
int fuse_session_exited(struct fuse_session *se)
int fuse_lowlevel_notify_retrieve(struct fuse_session *se, fuse_ino_t ino, size_t size, off_t offset, void *cookie)
int fuse_reply_readlink(fuse_req_t req, const char *link)
int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)
int fuse_reply_bmap(fuse_req_t req, uint64_t idx)
int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e)
void fuse_reply_none(fuse_req_t req)
int fuse_lowlevel_notify_expire_entry(struct fuse_session *se, fuse_ino_t parent, const char *name, size_t namelen)
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)
void fuse_lowlevel_help(void)
int fuse_lowlevel_notify_inval_inode(struct fuse_session *se, fuse_ino_t ino, off_t off, off_t len)
int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf)
int fuse_reply_write(fuse_req_t req, size_t count)
int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf)
int fuse_lowlevel_notify_poll(struct fuse_pollhandle *ph)
int fuse_lowlevel_notify_inval_entry(struct fuse_session *se, fuse_ino_t parent, const char *name, size_t namelen)
void fuse_session_reset(struct fuse_session *se)
int fuse_reply_create(fuse_req_t req, const struct fuse_entry_param *e, const struct fuse_file_info *fi)
int fuse_reply_lseek(fuse_req_t req, off_t off)
void fuse_lowlevel_version(void)
size_t fuse_add_direntry(fuse_req_t req, char *buf, size_t bufsize, const char *name, const struct stat *stbuf, off_t off)
int fuse_reply_attr(fuse_req_t req, const struct stat *attr, double attr_timeout)
int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, size_t size)
int fuse_passthrough_open(fuse_req_t req, int fd)
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_reply_xattr(fuse_req_t req, size_t count)
int fuse_opt_add_arg(struct fuse_args *args, const char *arg)
void fuse_opt_free_args(struct fuse_args *args)
int fuse_opt_parse(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc)
int fuse_convert_to_conn_want_ext(struct fuse_conn_info *conn)
#define FUSE_CAP_OVER_IO_URING
bool fuse_req_is_uring(fuse_req_t req)
const struct fuse_ctx * fuse_req_ctx(fuse_req_t req)
int fuse_session_fd(struct fuse_session *se)
int fuse_req_interrupted(fuse_req_t req)
int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
void fuse_session_unmount(struct fuse_session *se)
int fuse_req_get_payload(fuse_req_t req, char **payload, size_t *payload_sz, void **mr)
int fuse_session_mount(struct fuse_session *se, const char *mountpoint)
int fuse_lowlevel_notify_increment_epoch(struct fuse_session *se)
void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func, void *data)
int fuse_reply_statx(fuse_req_t req, int flags, struct statx *statx, double attr_timeout)
enum fuse_buf_flags flags
uint32_t parallel_direct_writes