14#include "fuse_config.h"
16#include "fuse_kernel.h"
19#include "mount_util.h"
31#ifndef F_LINUX_SPECIFIC_BASE
32#define F_LINUX_SPECIFIC_BASE 1024
35#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
39#define PARAM(inarg) (((char *)(inarg)) + sizeof(*(inarg)))
40#define OFFSET_MAX 0x7fffffffffffffffLL
42#define container_of(ptr, type, member) ({ \
43 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
44 (type *)( (char *)__mptr - offsetof(type,member) );})
46struct fuse_pollhandle {
48 struct fuse_session *se;
51static size_t pagesize;
53static __attribute__((constructor))
void fuse_ll_init_pagesize(
void)
55 pagesize = getpagesize();
58static void convert_stat(
const struct stat *stbuf,
struct fuse_attr *attr)
60 attr->ino = stbuf->st_ino;
61 attr->mode = stbuf->st_mode;
62 attr->nlink = stbuf->st_nlink;
63 attr->uid = stbuf->st_uid;
64 attr->gid = stbuf->st_gid;
65 attr->rdev = stbuf->st_rdev;
66 attr->size = stbuf->st_size;
67 attr->blksize = stbuf->st_blksize;
68 attr->blocks = stbuf->st_blocks;
69 attr->atime = stbuf->st_atime;
70 attr->mtime = stbuf->st_mtime;
71 attr->ctime = stbuf->st_ctime;
72 attr->atimensec = ST_ATIM_NSEC(stbuf);
73 attr->mtimensec = ST_MTIM_NSEC(stbuf);
74 attr->ctimensec = ST_CTIM_NSEC(stbuf);
77static void convert_attr(
const struct fuse_setattr_in *attr,
struct stat *stbuf)
79 stbuf->st_mode = attr->mode;
80 stbuf->st_uid = attr->uid;
81 stbuf->st_gid = attr->gid;
82 stbuf->st_size = attr->size;
83 stbuf->st_atime = attr->atime;
84 stbuf->st_mtime = attr->mtime;
85 stbuf->st_ctime = attr->ctime;
86 ST_ATIM_NSEC_SET(stbuf, attr->atimensec);
87 ST_MTIM_NSEC_SET(stbuf, attr->mtimensec);
88 ST_CTIM_NSEC_SET(stbuf, attr->ctimensec);
91static size_t iov_length(
const struct iovec *iov,
size_t count)
96 for (seg = 0; seg < count; seg++)
97 ret += iov[seg].iov_len;
101static void list_init_req(
struct fuse_req *req)
107static void list_del_req(
struct fuse_req *req)
109 struct fuse_req *prev = req->prev;
110 struct fuse_req *next = req->next;
115static void list_add_req(
struct fuse_req *req,
struct fuse_req *next)
117 struct fuse_req *prev = next->prev;
126 assert(req->ch == NULL);
127 pthread_mutex_destroy(&req->lock);
134 struct fuse_session *se = req->se;
136 pthread_mutex_lock(&se->lock);
137 req->u.ni.func = NULL;
138 req->u.ni.data = NULL;
141 fuse_chan_put(req->ch);
143 pthread_mutex_unlock(&se->lock);
148static struct fuse_req *fuse_ll_alloc_req(
struct fuse_session *se)
150 struct fuse_req *req;
152 req = (
struct fuse_req *) calloc(1,
sizeof(
struct fuse_req));
154 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate request\n");
159 pthread_mutex_init(&req->lock, NULL);
166static int fuse_send_msg(
struct fuse_session *se,
struct fuse_chan *ch,
167 struct iovec *iov,
int count)
169 struct fuse_out_header *out = iov[0].iov_base;
172 out->len = iov_length(iov, count);
174 if (out->unique == 0) {
175 fuse_log(FUSE_LOG_DEBUG,
"NOTIFY: code=%d length=%u\n",
176 out->error, out->len);
177 }
else if (out->error) {
179 " unique: %llu, error: %i (%s), outsize: %i\n",
180 (
unsigned long long) out->unique, out->error,
181 strerror(-out->error), out->len);
184 " unique: %llu, success, outsize: %i\n",
185 (
unsigned long long) out->unique, out->len);
193 res = se->io->writev(ch ? ch->fd : se->fd, iov, count,
196 res = writev(ch ? ch->fd : se->fd, iov, count);
203 perror(
"fuse: writing device");
211int fuse_send_reply_iov_nofree(
fuse_req_t req,
int error,
struct iovec *iov,
214 struct fuse_out_header out;
216#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 32
217 const char *str = strerrordesc_np(error * -1);
218 if ((str == NULL && error != 0) || error > 0) {
220 if (error <= -1000 || error > 0) {
222 fuse_log(FUSE_LOG_ERR,
"fuse: bad error value: %i\n", error);
226 out.unique = req->unique;
229 iov[0].iov_base = &out;
230 iov[0].iov_len =
sizeof(
struct fuse_out_header);
232 return fuse_send_msg(req->se, req->ch, iov, count);
235static int send_reply_iov(
fuse_req_t req,
int error,
struct iovec *iov,
240 res = fuse_send_reply_iov_nofree(req, error, iov, count);
245static int send_reply(
fuse_req_t req,
int error,
const void *arg,
251 iov[1].iov_base = (
void *) arg;
252 iov[1].iov_len = argsize;
255 return send_reply_iov(req, error, iov, count);
261 struct iovec *padded_iov;
263 padded_iov = malloc((count + 1) *
sizeof(
struct iovec));
264 if (padded_iov == NULL)
267 memcpy(padded_iov + 1, iov, count *
sizeof(
struct iovec));
270 res = send_reply_iov(req, 0, padded_iov, count);
280 const char *name,
const struct stat *stbuf, off_t off)
285 size_t entlen_padded;
286 struct fuse_dirent *dirent;
288 namelen = strlen(name);
289 entlen = FUSE_NAME_OFFSET + namelen;
290 entlen_padded = FUSE_DIRENT_ALIGN(entlen);
292 if ((buf == NULL) || (entlen_padded > bufsize))
293 return entlen_padded;
295 dirent = (
struct fuse_dirent*) buf;
296 dirent->ino = stbuf->st_ino;
298 dirent->namelen = namelen;
299 dirent->type = (stbuf->st_mode & S_IFMT) >> 12;
300 memcpy(dirent->name, name, namelen);
301 memset(dirent->name + namelen, 0, entlen_padded - entlen);
303 return entlen_padded;
306static void convert_statfs(
const struct statvfs *stbuf,
307 struct fuse_kstatfs *kstatfs)
309 kstatfs->bsize = stbuf->f_bsize;
310 kstatfs->frsize = stbuf->f_frsize;
311 kstatfs->blocks = stbuf->f_blocks;
312 kstatfs->bfree = stbuf->f_bfree;
313 kstatfs->bavail = stbuf->f_bavail;
314 kstatfs->files = stbuf->f_files;
315 kstatfs->ffree = stbuf->f_ffree;
316 kstatfs->namelen = stbuf->f_namemax;
319static int send_reply_ok(
fuse_req_t req,
const void *arg,
size_t argsize)
321 return send_reply(req, 0, arg, argsize);
326 return send_reply(req, -err, NULL, 0);
334static unsigned long calc_timeout_sec(
double t)
336 if (t > (
double) ULONG_MAX)
341 return (
unsigned long) t;
344static unsigned int calc_timeout_nsec(
double t)
346 double f = t - (double) calc_timeout_sec(t);
349 else if (f >= 0.999999999)
352 return (
unsigned int) (f * 1.0e9);
355static void fill_entry(
struct fuse_entry_out *arg,
358 arg->nodeid = e->
ino;
363 arg->attr_valid_nsec = calc_timeout_nsec(e->
attr_timeout);
364 convert_stat(&e->
attr, &arg->attr);
376 size_t entlen_padded;
378 namelen = strlen(name);
379 entlen = FUSE_NAME_OFFSET_DIRENTPLUS + namelen;
380 entlen_padded = FUSE_DIRENT_ALIGN(entlen);
381 if ((buf == NULL) || (entlen_padded > bufsize))
382 return entlen_padded;
384 struct fuse_direntplus *dp = (
struct fuse_direntplus *) buf;
385 memset(&dp->entry_out, 0,
sizeof(dp->entry_out));
386 fill_entry(&dp->entry_out, e);
388 struct fuse_dirent *dirent = &dp->dirent;
389 dirent->ino = e->
attr.st_ino;
391 dirent->namelen = namelen;
392 dirent->type = (e->
attr.st_mode & S_IFMT) >> 12;
393 memcpy(dirent->name, name, namelen);
394 memset(dirent->name + namelen, 0, entlen_padded - entlen);
396 return entlen_padded;
399static void fill_open(
struct fuse_open_out *arg,
404 arg->open_flags |= FOPEN_DIRECT_IO;
406 arg->open_flags |= FOPEN_KEEP_CACHE;
408 arg->open_flags |= FOPEN_CACHE_DIR;
410 arg->open_flags |= FOPEN_NONSEEKABLE;
412 arg->open_flags |= FOPEN_NOFLUSH;
414 arg->open_flags |= FOPEN_PARALLEL_DIRECT_WRITES;
419 struct fuse_entry_out arg;
420 size_t size = req->se->conn.proto_minor < 9 ?
421 FUSE_COMPAT_ENTRY_OUT_SIZE :
sizeof(arg);
425 if (!e->
ino && req->se->conn.proto_minor < 4)
428 memset(&arg, 0,
sizeof(arg));
430 return send_reply_ok(req, &arg, size);
436 char buf[
sizeof(
struct fuse_entry_out) + sizeof(struct fuse_open_out)];
437 size_t entrysize = req->se->conn.proto_minor < 9 ?
438 FUSE_COMPAT_ENTRY_OUT_SIZE :
sizeof(
struct fuse_entry_out);
439 struct fuse_entry_out *earg = (
struct fuse_entry_out *) buf;
440 struct fuse_open_out *oarg = (
struct fuse_open_out *) (buf + entrysize);
442 memset(buf, 0,
sizeof(buf));
445 return send_reply_ok(req, buf,
446 entrysize +
sizeof(
struct fuse_open_out));
452 struct fuse_attr_out arg;
453 size_t size = req->se->conn.proto_minor < 9 ?
454 FUSE_COMPAT_ATTR_OUT_SIZE :
sizeof(arg);
456 memset(&arg, 0,
sizeof(arg));
457 arg.attr_valid = calc_timeout_sec(attr_timeout);
458 arg.attr_valid_nsec = calc_timeout_nsec(attr_timeout);
459 convert_stat(attr, &arg.attr);
461 return send_reply_ok(req, &arg, size);
466 return send_reply_ok(req, linkname, strlen(linkname));
471 struct fuse_open_out arg;
473 memset(&arg, 0,
sizeof(arg));
475 return send_reply_ok(req, &arg,
sizeof(arg));
480 struct fuse_write_out arg;
482 memset(&arg, 0,
sizeof(arg));
485 return send_reply_ok(req, &arg,
sizeof(arg));
490 return send_reply_ok(req, buf, size);
493static int fuse_send_data_iov_fallback(
struct fuse_session *se,
494 struct fuse_chan *ch,
495 struct iovec *iov,
int iov_count,
499 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
504 if (
buf->count == 1 &&
buf->idx == 0 &&
buf->off == 0 &&
509 iov[iov_count].iov_base =
buf->buf[0].
mem;
510 iov[iov_count].iov_len = len;
512 return fuse_send_msg(se, ch, iov, iov_count);
515 res = posix_memalign(&mbuf, pagesize, len);
519 mem_buf.
buf[0].
mem = mbuf;
527 iov[iov_count].iov_base = mbuf;
528 iov[iov_count].iov_len = len;
530 res = fuse_send_msg(se, ch, iov, iov_count);
542static void fuse_ll_pipe_free(
struct fuse_ll_pipe *llp)
550#if !defined(HAVE_PIPE2) || !defined(O_CLOEXEC)
551static int fuse_pipe(
int fds[2])
558 if (fcntl(fds[0], F_SETFL, O_NONBLOCK) == -1 ||
559 fcntl(fds[1], F_SETFL, O_NONBLOCK) == -1 ||
560 fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
561 fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
569static int fuse_pipe(
int fds[2])
571 return pipe2(fds, O_CLOEXEC | O_NONBLOCK);
575static struct fuse_ll_pipe *fuse_ll_get_pipe(
struct fuse_session *se)
577 struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
581 llp = malloc(
sizeof(
struct fuse_ll_pipe));
585 res = fuse_pipe(llp->pipe);
594 llp->size = pagesize * 16;
597 pthread_setspecific(se->pipe_key, llp);
604static void fuse_ll_clear_pipe(
struct fuse_session *se)
606 struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
608 pthread_setspecific(se->pipe_key, NULL);
609 fuse_ll_pipe_free(llp);
613#if defined(HAVE_SPLICE) && defined(HAVE_VMSPLICE)
614static int read_back(
int fd,
char *buf,
size_t len)
618 res = read(fd, buf, len);
620 fuse_log(FUSE_LOG_ERR,
"fuse: internal error: failed to read back from pipe: %s\n", strerror(errno));
624 fuse_log(FUSE_LOG_ERR,
"fuse: internal error: short read back from pipe: %i from %zi\n", res, len);
630static int grow_pipe_to_max(
int pipefd)
637 maxfd = open(
"/proc/sys/fs/pipe-max-size", O_RDONLY);
641 res = read(maxfd, buf,
sizeof(buf) - 1);
653 res = fcntl(pipefd, F_SETPIPE_SZ, max);
659static int fuse_send_data_iov(
struct fuse_session *se,
struct fuse_chan *ch,
660 struct iovec *iov,
int iov_count,
665 struct fuse_out_header *out = iov[0].iov_base;
666 struct fuse_ll_pipe *llp;
669 size_t total_buf_size;
672 struct fuse_bufvec pipe_buf = FUSE_BUFVEC_INIT(len);
674 if (se->broken_splice_nonblock)
684 total_buf_size -=
buf->off;
686 if (total_buf_size < 2 * pagesize)
689 if (se->conn.proto_minor < 14 ||
693 llp = fuse_ll_get_pipe(se);
698 headerlen = iov_length(iov, iov_count);
700 out->len = headerlen + len;
706 pipesize = pagesize * (iov_count +
buf->count + 1) + out->len;
708 if (llp->size < pipesize) {
710 res = fcntl(llp->pipe[0], F_SETPIPE_SZ, pipesize);
712 res = grow_pipe_to_max(llp->pipe[0]);
720 if (llp->size < pipesize)
725 res = vmsplice(llp->pipe[1], iov, iov_count, SPLICE_F_NONBLOCK);
729 if (res != headerlen) {
731 fuse_log(FUSE_LOG_ERR,
"fuse: short vmsplice to pipe: %u/%zu\n", res,
737 pipe_buf.
buf[0].
fd = llp->pipe[1];
742 if (res == -EAGAIN || res == -EINVAL) {
754 se->broken_splice_nonblock = 1;
756 pthread_setspecific(se->pipe_key, NULL);
757 fuse_ll_pipe_free(llp);
764 if (res != 0 && res < len) {
765 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
767 size_t now_len = res;
777 res = posix_memalign(&mbuf, pagesize, len);
781 mem_buf.
buf[0].
mem = mbuf;
782 mem_buf.
off = now_len;
786 size_t extra_len = res;
792 tmpbuf = malloc(headerlen);
793 if (tmpbuf == NULL) {
798 res = read_back(llp->pipe[0], tmpbuf, headerlen);
804 res = read_back(llp->pipe[0], mbuf, now_len);
809 len = now_len + extra_len;
810 iov[iov_count].iov_base = mbuf;
811 iov[iov_count].iov_len = len;
813 res = fuse_send_msg(se, ch, iov, iov_count);
821 out->len = headerlen + len;
825 " unique: %llu, success, outsize: %i (splice)\n",
826 (
unsigned long long) out->unique, out->len);
832 splice_flags |= SPLICE_F_MOVE;
834 if (se->io != NULL && se->io->splice_send != NULL) {
835 res = se->io->splice_send(llp->pipe[0], NULL,
836 ch ? ch->fd : se->fd, NULL, out->len,
837 splice_flags, se->userdata);
839 res = splice(llp->pipe[0], NULL, ch ? ch->fd : se->fd, NULL,
840 out->len, splice_flags);
844 perror(
"fuse: splice from pipe");
847 if (res != out->len) {
849 fuse_log(FUSE_LOG_ERR,
"fuse: short splice from pipe: %u/%u\n",
856 fuse_ll_clear_pipe(se);
860 return fuse_send_data_iov_fallback(se, ch, iov, iov_count,
buf, len);
863static int fuse_send_data_iov(
struct fuse_session *se,
struct fuse_chan *ch,
864 struct iovec *iov,
int iov_count,
870 return fuse_send_data_iov_fallback(se, ch, iov, iov_count,
buf, len);
878 struct fuse_out_header out;
881 iov[0].iov_base = &out;
882 iov[0].iov_len =
sizeof(
struct fuse_out_header);
884 out.unique = req->unique;
887 res = fuse_send_data_iov(req->se, req->ch, iov, 1, bufv, flags);
898 struct fuse_statfs_out arg;
899 size_t size = req->se->conn.proto_minor < 4 ?
900 FUSE_COMPAT_STATFS_SIZE :
sizeof(arg);
902 memset(&arg, 0,
sizeof(arg));
903 convert_statfs(stbuf, &arg.st);
905 return send_reply_ok(req, &arg, size);
910 struct fuse_getxattr_out arg;
912 memset(&arg, 0,
sizeof(arg));
915 return send_reply_ok(req, &arg,
sizeof(arg));
920 struct fuse_lk_out arg;
922 memset(&arg, 0,
sizeof(arg));
923 arg.lk.type = lock->l_type;
924 if (lock->l_type != F_UNLCK) {
925 arg.lk.start = lock->l_start;
926 if (lock->l_len == 0)
927 arg.lk.end = OFFSET_MAX;
929 arg.lk.end = lock->l_start + lock->l_len - 1;
931 arg.lk.pid = lock->l_pid;
932 return send_reply_ok(req, &arg,
sizeof(arg));
937 struct fuse_bmap_out arg;
939 memset(&arg, 0,
sizeof(arg));
942 return send_reply_ok(req, &arg,
sizeof(arg));
945static struct fuse_ioctl_iovec *fuse_ioctl_iovec_copy(
const struct iovec *iov,
948 struct fuse_ioctl_iovec *fiov;
951 fiov = malloc(
sizeof(fiov[0]) * count);
955 for (i = 0; i < count; i++) {
956 fiov[i].base = (uintptr_t) iov[i].iov_base;
957 fiov[i].len = iov[i].iov_len;
964 const struct iovec *in_iov,
size_t in_count,
965 const struct iovec *out_iov,
size_t out_count)
967 struct fuse_ioctl_out arg;
968 struct fuse_ioctl_iovec *in_fiov = NULL;
969 struct fuse_ioctl_iovec *out_fiov = NULL;
974 memset(&arg, 0,
sizeof(arg));
975 arg.flags |= FUSE_IOCTL_RETRY;
976 arg.in_iovs = in_count;
977 arg.out_iovs = out_count;
978 iov[count].iov_base = &arg;
979 iov[count].iov_len =
sizeof(arg);
982 if (req->se->conn.proto_minor < 16) {
984 iov[count].iov_base = (
void *)in_iov;
985 iov[count].iov_len =
sizeof(in_iov[0]) * in_count;
990 iov[count].iov_base = (
void *)out_iov;
991 iov[count].iov_len =
sizeof(out_iov[0]) * out_count;
996 if (
sizeof(
void *) == 4 && req->ioctl_64bit) {
1002 in_fiov = fuse_ioctl_iovec_copy(in_iov, in_count);
1006 iov[count].iov_base = (
void *)in_fiov;
1007 iov[count].iov_len =
sizeof(in_fiov[0]) * in_count;
1011 out_fiov = fuse_ioctl_iovec_copy(out_iov, out_count);
1015 iov[count].iov_base = (
void *)out_fiov;
1016 iov[count].iov_len =
sizeof(out_fiov[0]) * out_count;
1021 res = send_reply_iov(req, 0, iov, count);
1035 struct fuse_ioctl_out arg;
1036 struct iovec iov[3];
1039 memset(&arg, 0,
sizeof(arg));
1040 arg.result = result;
1041 iov[count].iov_base = &arg;
1042 iov[count].iov_len =
sizeof(arg);
1046 iov[count].iov_base = (
char *) buf;
1047 iov[count].iov_len = size;
1051 return send_reply_iov(req, 0, iov, count);
1057 struct iovec *padded_iov;
1058 struct fuse_ioctl_out arg;
1061 padded_iov = malloc((count + 2) *
sizeof(
struct iovec));
1062 if (padded_iov == NULL)
1065 memset(&arg, 0,
sizeof(arg));
1066 arg.result = result;
1067 padded_iov[1].iov_base = &arg;
1068 padded_iov[1].iov_len =
sizeof(arg);
1070 memcpy(&padded_iov[2], iov, count *
sizeof(
struct iovec));
1072 res = send_reply_iov(req, 0, padded_iov, count + 2);
1080 struct fuse_poll_out arg;
1082 memset(&arg, 0,
sizeof(arg));
1083 arg.revents = revents;
1085 return send_reply_ok(req, &arg,
sizeof(arg));
1090 struct fuse_lseek_out arg;
1092 memset(&arg, 0,
sizeof(arg));
1095 return send_reply_ok(req, &arg,
sizeof(arg));
1100 char *name = (
char *) inarg;
1102 if (req->se->op.lookup)
1103 req->se->op.lookup(req, nodeid, name);
1110 struct fuse_forget_in *arg = (
struct fuse_forget_in *) inarg;
1112 if (req->se->op.forget)
1113 req->se->op.forget(req, nodeid, arg->nlookup);
1121 struct fuse_batch_forget_in *arg = (
void *) inarg;
1122 struct fuse_forget_one *param = (
void *) PARAM(arg);
1127 if (req->se->op.forget_multi) {
1128 req->se->op.forget_multi(req, arg->count,
1129 (
struct fuse_forget_data *) param);
1130 }
else if (req->se->op.forget) {
1131 for (i = 0; i < arg->count; i++) {
1132 struct fuse_forget_one *forget = ¶m[i];
1133 struct fuse_req *dummy_req;
1135 dummy_req = fuse_ll_alloc_req(req->se);
1136 if (dummy_req == NULL)
1139 dummy_req->unique = req->unique;
1140 dummy_req->ctx = req->ctx;
1141 dummy_req->ch = NULL;
1143 req->se->op.forget(dummy_req, forget->nodeid,
1157 if (req->se->conn.proto_minor >= 9) {
1158 struct fuse_getattr_in *arg = (
struct fuse_getattr_in *) inarg;
1160 if (arg->getattr_flags & FUSE_GETATTR_FH) {
1161 memset(&fi, 0,
sizeof(fi));
1167 if (req->se->op.getattr)
1168 req->se->op.getattr(req, nodeid, fip);
1175 struct fuse_setattr_in *arg = (
struct fuse_setattr_in *) inarg;
1177 if (req->se->op.setattr) {
1181 memset(&stbuf, 0,
sizeof(stbuf));
1182 convert_attr(arg, &stbuf);
1183 if (arg->valid & FATTR_FH) {
1184 arg->valid &= ~FATTR_FH;
1185 memset(&fi_store, 0,
sizeof(fi_store));
1190 FUSE_SET_ATTR_MODE |
1193 FUSE_SET_ATTR_SIZE |
1194 FUSE_SET_ATTR_ATIME |
1195 FUSE_SET_ATTR_MTIME |
1196 FUSE_SET_ATTR_KILL_SUID |
1197 FUSE_SET_ATTR_KILL_SGID |
1198 FUSE_SET_ATTR_ATIME_NOW |
1199 FUSE_SET_ATTR_MTIME_NOW |
1200 FUSE_SET_ATTR_CTIME;
1202 req->se->op.setattr(req, nodeid, &stbuf, arg->valid, fi);
1209 struct fuse_access_in *arg = (
struct fuse_access_in *) inarg;
1211 if (req->se->op.access)
1212 req->se->op.access(req, nodeid, arg->mask);
1221 if (req->se->op.readlink)
1222 req->se->op.readlink(req, nodeid);
1229 struct fuse_mknod_in *arg = (
struct fuse_mknod_in *) inarg;
1230 char *name = PARAM(arg);
1232 if (req->se->conn.proto_minor >= 12)
1233 req->ctx.umask = arg->umask;
1235 name = (
char *) inarg + FUSE_COMPAT_MKNOD_IN_SIZE;
1237 if (req->se->op.mknod)
1238 req->se->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
1245 struct fuse_mkdir_in *arg = (
struct fuse_mkdir_in *) inarg;
1247 if (req->se->conn.proto_minor >= 12)
1248 req->ctx.umask = arg->umask;
1250 if (req->se->op.mkdir)
1251 req->se->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
1258 char *name = (
char *) inarg;
1260 if (req->se->op.unlink)
1261 req->se->op.unlink(req, nodeid, name);
1268 char *name = (
char *) inarg;
1270 if (req->se->op.rmdir)
1271 req->se->op.rmdir(req, nodeid, name);
1278 char *name = (
char *) inarg;
1279 char *linkname = ((
char *) inarg) + strlen((
char *) inarg) + 1;
1281 if (req->se->op.symlink)
1282 req->se->op.symlink(req, linkname, nodeid, name);
1289 struct fuse_rename_in *arg = (
struct fuse_rename_in *) inarg;
1290 char *oldname = PARAM(arg);
1291 char *newname = oldname + strlen(oldname) + 1;
1293 if (req->se->op.rename)
1294 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1302 struct fuse_rename2_in *arg = (
struct fuse_rename2_in *) inarg;
1303 char *oldname = PARAM(arg);
1304 char *newname = oldname + strlen(oldname) + 1;
1306 if (req->se->op.rename)
1307 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1315 struct fuse_link_in *arg = (
struct fuse_link_in *) inarg;
1317 if (req->se->op.link)
1318 req->se->op.link(req, arg->oldnodeid, nodeid, PARAM(arg));
1325 struct fuse_create_in *arg = (
struct fuse_create_in *) inarg;
1327 if (req->se->op.create) {
1329 char *name = PARAM(arg);
1331 memset(&fi, 0,
sizeof(fi));
1332 fi.
flags = arg->flags;
1334 if (req->se->conn.proto_minor >= 12)
1335 req->ctx.umask = arg->umask;
1337 name = (
char *) inarg +
sizeof(
struct fuse_open_in);
1339 req->se->op.create(req, nodeid, name, arg->mode, &fi);
1346 struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
1349 memset(&fi, 0,
sizeof(fi));
1350 fi.
flags = arg->flags;
1352 if (req->se->op.open)
1353 req->se->op.open(req, nodeid, &fi);
1360 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1362 if (req->se->op.read) {
1365 memset(&fi, 0,
sizeof(fi));
1367 if (req->se->conn.proto_minor >= 9) {
1369 fi.
flags = arg->flags;
1371 req->se->op.read(req, nodeid, arg->size, arg->offset, &fi);
1378 struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
1382 memset(&fi, 0,
sizeof(fi));
1384 fi.
writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
1386 if (req->se->conn.proto_minor < 9) {
1387 param = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1390 fi.
flags = arg->flags;
1394 if (req->se->op.write)
1395 req->se->op.write(req, nodeid, param, arg->size,
1404 struct fuse_session *se = req->se;
1409 struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
1412 memset(&fi, 0,
sizeof(fi));
1414 fi.
writepage = arg->write_flags & FUSE_WRITE_CACHE;
1416 if (se->conn.proto_minor < 9) {
1417 bufv.
buf[0].
mem = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1418 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1419 FUSE_COMPAT_WRITE_IN_SIZE;
1423 fi.
flags = arg->flags;
1425 bufv.
buf[0].
mem = PARAM(arg);
1427 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1428 sizeof(struct fuse_write_in);
1430 if (bufv.
buf[0].
size < arg->size) {
1431 fuse_log(FUSE_LOG_ERR,
"fuse: do_write_buf: buffer size too small\n");
1437 se->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
1442 fuse_ll_clear_pipe(se);
1447 struct fuse_flush_in *arg = (
struct fuse_flush_in *) inarg;
1450 memset(&fi, 0,
sizeof(fi));
1453 if (req->se->conn.proto_minor >= 7)
1456 if (req->se->op.flush)
1457 req->se->op.flush(req, nodeid, &fi);
1464 struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
1467 memset(&fi, 0,
sizeof(fi));
1468 fi.
flags = arg->flags;
1470 if (req->se->conn.proto_minor >= 8) {
1471 fi.
flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
1474 if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) {
1475 fi.flock_release = 1;
1479 if (req->se->op.release)
1480 req->se->op.release(req, nodeid, &fi);
1487 struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
1489 int datasync = arg->fsync_flags & 1;
1491 memset(&fi, 0,
sizeof(fi));
1494 if (req->se->op.fsync)
1495 req->se->op.fsync(req, nodeid, datasync, &fi);
1502 struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
1505 memset(&fi, 0,
sizeof(fi));
1506 fi.
flags = arg->flags;
1508 if (req->se->op.opendir)
1509 req->se->op.opendir(req, nodeid, &fi);
1516 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1519 memset(&fi, 0,
sizeof(fi));
1522 if (req->se->op.readdir)
1523 req->se->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
1530 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1533 memset(&fi, 0,
sizeof(fi));
1536 if (req->se->op.readdirplus)
1537 req->se->op.readdirplus(req, nodeid, arg->size, arg->offset, &fi);
1544 struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
1547 memset(&fi, 0,
sizeof(fi));
1548 fi.
flags = arg->flags;
1551 if (req->se->op.releasedir)
1552 req->se->op.releasedir(req, nodeid, &fi);
1559 struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
1561 int datasync = arg->fsync_flags & 1;
1563 memset(&fi, 0,
sizeof(fi));
1566 if (req->se->op.fsyncdir)
1567 req->se->op.fsyncdir(req, nodeid, datasync, &fi);
1577 if (req->se->op.statfs)
1578 req->se->op.statfs(req, nodeid);
1580 struct statvfs buf = {
1590 struct fuse_session *se = req->se;
1592 struct fuse_setxattr_in *arg = (
struct fuse_setxattr_in *) inarg;
1593 char *name = xattr_ext ? PARAM(arg) :
1594 (char *)arg + FUSE_COMPAT_SETXATTR_IN_SIZE;
1595 char *value = name + strlen(name) + 1;
1598 if (req->se->op.setxattr)
1599 req->se->op.setxattr(req, nodeid, name, value, arg->size,
1607 struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
1609 if (req->se->op.getxattr)
1610 req->se->op.getxattr(req, nodeid, PARAM(arg), arg->size);
1617 struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
1619 if (req->se->op.listxattr)
1620 req->se->op.listxattr(req, nodeid, arg->size);
1627 char *name = (
char *) inarg;
1629 if (req->se->op.removexattr)
1630 req->se->op.removexattr(req, nodeid, name);
1635static void convert_fuse_file_lock(
struct fuse_file_lock *fl,
1636 struct flock *flock)
1638 memset(flock, 0,
sizeof(
struct flock));
1639 flock->l_type = fl->type;
1640 flock->l_whence = SEEK_SET;
1641 flock->l_start = fl->start;
1642 if (fl->end == OFFSET_MAX)
1645 flock->l_len = fl->end - fl->start + 1;
1646 flock->l_pid = fl->pid;
1651 struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
1655 memset(&fi, 0,
sizeof(fi));
1659 convert_fuse_file_lock(&arg->lk, &flock);
1660 if (req->se->op.getlk)
1661 req->se->op.getlk(req, nodeid, &fi, &flock);
1667 const void *inarg,
int sleep)
1669 struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
1673 memset(&fi, 0,
sizeof(fi));
1677 if (arg->lk_flags & FUSE_LK_FLOCK) {
1680 switch (arg->lk.type) {
1694 if (req->se->op.flock)
1695 req->se->op.flock(req, nodeid, &fi, op);
1699 convert_fuse_file_lock(&arg->lk, &flock);
1700 if (req->se->op.setlk)
1701 req->se->op.setlk(req, nodeid, &fi, &flock, sleep);
1709 do_setlk_common(req, nodeid, inarg, 0);
1714 do_setlk_common(req, nodeid, inarg, 1);
1717static int find_interrupted(
struct fuse_session *se,
struct fuse_req *req)
1719 struct fuse_req *curr;
1721 for (curr = se->list.next; curr != &se->list; curr = curr->next) {
1722 if (curr->unique == req->u.i.unique) {
1727 pthread_mutex_unlock(&se->lock);
1730 pthread_mutex_lock(&curr->lock);
1731 pthread_mutex_lock(&se->lock);
1732 curr->interrupted = 1;
1733 func = curr->u.ni.func;
1734 data = curr->u.ni.data;
1735 pthread_mutex_unlock(&se->lock);
1738 pthread_mutex_unlock(&curr->lock);
1740 pthread_mutex_lock(&se->lock);
1743 fuse_chan_put(req->ch);
1751 for (curr = se->interrupts.next; curr != &se->interrupts;
1752 curr = curr->next) {
1753 if (curr->u.i.unique == req->u.i.unique)
1761 struct fuse_interrupt_in *arg = (
struct fuse_interrupt_in *) inarg;
1762 struct fuse_session *se = req->se;
1766 fuse_log(FUSE_LOG_DEBUG,
"INTERRUPT: %llu\n",
1767 (
unsigned long long) arg->unique);
1769 req->u.i.unique = arg->unique;
1771 pthread_mutex_lock(&se->lock);
1772 if (find_interrupted(se, req)) {
1773 fuse_chan_put(req->ch);
1777 list_add_req(req, &se->interrupts);
1778 pthread_mutex_unlock(&se->lock);
1781static struct fuse_req *check_interrupt(
struct fuse_session *se,
1782 struct fuse_req *req)
1784 struct fuse_req *curr;
1786 for (curr = se->interrupts.next; curr != &se->interrupts;
1787 curr = curr->next) {
1788 if (curr->u.i.unique == req->unique) {
1789 req->interrupted = 1;
1791 fuse_chan_put(curr->ch);
1797 curr = se->interrupts.next;
1798 if (curr != &se->interrupts) {
1800 list_init_req(curr);
1808 struct fuse_bmap_in *arg = (
struct fuse_bmap_in *) inarg;
1810 if (req->se->op.bmap)
1811 req->se->op.bmap(req, nodeid, arg->blocksize, arg->block);
1818 struct fuse_ioctl_in *arg = (
struct fuse_ioctl_in *) inarg;
1819 unsigned int flags = arg->flags;
1820 void *in_buf = arg->in_size ? PARAM(arg) : NULL;
1823 if (
flags & FUSE_IOCTL_DIR &&
1829 memset(&fi, 0,
sizeof(fi));
1832 if (
sizeof(
void *) == 4 && req->se->conn.proto_minor >= 16 &&
1833 !(
flags & FUSE_IOCTL_32BIT)) {
1834 req->ioctl_64bit = 1;
1837 if (req->se->op.ioctl)
1838 req->se->op.ioctl(req, nodeid, arg->cmd,
1839 (
void *)(uintptr_t)arg->arg, &fi,
flags,
1840 in_buf, arg->in_size, arg->out_size);
1852 struct fuse_poll_in *arg = (
struct fuse_poll_in *) inarg;
1855 memset(&fi, 0,
sizeof(fi));
1859 if (req->se->op.poll) {
1860 struct fuse_pollhandle *ph = NULL;
1862 if (arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) {
1863 ph = malloc(
sizeof(
struct fuse_pollhandle));
1872 req->se->op.poll(req, nodeid, &fi, ph);
1880 struct fuse_fallocate_in *arg = (
struct fuse_fallocate_in *) inarg;
1883 memset(&fi, 0,
sizeof(fi));
1886 if (req->se->op.fallocate)
1887 req->se->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi);
1894 struct fuse_copy_file_range_in *arg = (
struct fuse_copy_file_range_in *) inarg;
1897 memset(&fi_in, 0,
sizeof(fi_in));
1898 fi_in.fh = arg->fh_in;
1900 memset(&fi_out, 0,
sizeof(fi_out));
1901 fi_out.fh = arg->fh_out;
1904 if (req->se->op.copy_file_range)
1905 req->se->op.copy_file_range(req, nodeid_in, arg->off_in,
1906 &fi_in, arg->nodeid_out,
1907 arg->off_out, &fi_out, arg->len,
1915 struct fuse_lseek_in *arg = (
struct fuse_lseek_in *) inarg;
1918 memset(&fi, 0,
sizeof(fi));
1921 if (req->se->op.lseek)
1922 req->se->op.lseek(req, nodeid, arg->offset, arg->whence, &fi);
1929static __attribute__((no_sanitize(
"thread")))
1932 struct fuse_init_in *arg = (
struct fuse_init_in *) inarg;
1933 struct fuse_init_out outarg;
1934 struct fuse_session *se = req->se;
1935 size_t bufsize = se->bufsize;
1936 size_t outargsize =
sizeof(outarg);
1937 uint64_t inargflags = 0;
1938 uint64_t outargflags = 0;
1941 fuse_log(FUSE_LOG_DEBUG,
"INIT: %u.%u\n", arg->major, arg->minor);
1942 if (arg->major == 7 && arg->minor >= 6) {
1943 fuse_log(FUSE_LOG_DEBUG,
"flags=0x%08x\n", arg->flags);
1944 fuse_log(FUSE_LOG_DEBUG,
"max_readahead=0x%08x\n",
1945 arg->max_readahead);
1948 se->conn.proto_major = arg->major;
1949 se->conn.proto_minor = arg->minor;
1950 se->conn.capable = 0;
1953 memset(&outarg, 0,
sizeof(outarg));
1954 outarg.major = FUSE_KERNEL_VERSION;
1955 outarg.minor = FUSE_KERNEL_MINOR_VERSION;
1957 if (arg->major < 7) {
1958 fuse_log(FUSE_LOG_ERR,
"fuse: unsupported protocol version: %u.%u\n",
1959 arg->major, arg->minor);
1964 if (arg->major > 7) {
1966 send_reply_ok(req, &outarg,
sizeof(outarg));
1970 if (arg->minor >= 6) {
1971 if (arg->max_readahead < se->conn.max_readahead)
1972 se->conn.max_readahead = arg->max_readahead;
1973 inargflags = arg->flags;
1974 if (inargflags & FUSE_INIT_EXT)
1975 inargflags = inargflags | (uint64_t) arg->flags2 << 32;
1976 if (inargflags & FUSE_ASYNC_READ)
1978 if (inargflags & FUSE_POSIX_LOCKS)
1980 if (inargflags & FUSE_ATOMIC_O_TRUNC)
1982 if (inargflags & FUSE_EXPORT_SUPPORT)
1984 if (inargflags & FUSE_DONT_MASK)
1986 if (inargflags & FUSE_FLOCK_LOCKS)
1988 if (inargflags & FUSE_AUTO_INVAL_DATA)
1990 if (inargflags & FUSE_DO_READDIRPLUS)
1992 if (inargflags & FUSE_READDIRPLUS_AUTO)
1994 if (inargflags & FUSE_ASYNC_DIO)
1996 if (inargflags & FUSE_WRITEBACK_CACHE)
1998 if (inargflags & FUSE_NO_OPEN_SUPPORT)
2000 if (inargflags & FUSE_PARALLEL_DIROPS)
2002 if (inargflags & FUSE_POSIX_ACL)
2004 if (inargflags & FUSE_HANDLE_KILLPRIV)
2006 if (inargflags & FUSE_CACHE_SYMLINKS)
2008 if (inargflags & FUSE_NO_OPENDIR_SUPPORT)
2010 if (inargflags & FUSE_EXPLICIT_INVAL_DATA)
2012 if (inargflags & FUSE_SETXATTR_EXT)
2014 if (!(inargflags & FUSE_MAX_PAGES)) {
2015 size_t max_bufsize =
2016 FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
2017 + FUSE_BUFFER_HEADER_SIZE;
2018 if (bufsize > max_bufsize) {
2019 bufsize = max_bufsize;
2022 if (arg->minor >= 38)
2025 se->conn.max_readahead = 0;
2028 if (se->conn.proto_minor >= 14) {
2031 if ((se->io == NULL) || (se->io->splice_send != NULL)) {
2035 if ((se->io == NULL) || (se->io->splice_receive != NULL)) {
2040 if (se->conn.proto_minor >= 18)
2050#define LL_SET_DEFAULT(cond, cap) \
2051 if ((cond) && (se->conn.capable & (cap))) \
2052 se->conn.want |= (cap)
2061 LL_SET_DEFAULT(se->op.getlk && se->op.setlk,
2065 LL_SET_DEFAULT(se->op.readdirplus && se->op.readdir,
2073 se->conn.time_gran = 1;
2075 if (bufsize < FUSE_MIN_READ_BUFFER) {
2076 fuse_log(FUSE_LOG_ERR,
"fuse: warning: buffer size too small: %zu\n",
2078 bufsize = FUSE_MIN_READ_BUFFER;
2080 se->bufsize = bufsize;
2082 if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE)
2083 se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE;
2087 se->op.init(se->userdata, &se->conn);
2089 if (se->conn.want & (~se->conn.capable)) {
2090 fuse_log(FUSE_LOG_ERR,
"fuse: error: filesystem requested capabilities "
2091 "0x%x that are not supported by kernel, aborting.\n",
2092 se->conn.want & (~se->conn.capable));
2094 se->error = -EPROTO;
2099 unsigned max_read_mo = get_max_read(se->mo);
2100 if (se->conn.max_read != max_read_mo) {
2101 fuse_log(FUSE_LOG_ERR,
"fuse: error: init() and fuse_session_new() "
2102 "requested different maximum read size (%u vs %u)\n",
2103 se->conn.max_read, max_read_mo);
2105 se->error = -EPROTO;
2110 if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE) {
2111 se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
2113 if (arg->flags & FUSE_MAX_PAGES) {
2114 outarg.flags |= FUSE_MAX_PAGES;
2115 outarg.max_pages = (se->conn.max_write - 1) / getpagesize() + 1;
2117 outargflags = outarg.flags;
2120 outargflags |= FUSE_BIG_WRITES;
2123 outargflags |= FUSE_ASYNC_READ;
2125 outargflags |= FUSE_POSIX_LOCKS;
2127 outargflags |= FUSE_ATOMIC_O_TRUNC;
2129 outargflags |= FUSE_EXPORT_SUPPORT;
2131 outargflags |= FUSE_DONT_MASK;
2133 outargflags |= FUSE_FLOCK_LOCKS;
2135 outargflags |= FUSE_AUTO_INVAL_DATA;
2137 outargflags |= FUSE_DO_READDIRPLUS;
2139 outargflags |= FUSE_READDIRPLUS_AUTO;
2141 outargflags |= FUSE_ASYNC_DIO;
2143 outargflags |= FUSE_WRITEBACK_CACHE;
2145 outargflags |= FUSE_POSIX_ACL;
2147 outargflags |= FUSE_CACHE_SYMLINKS;
2149 outargflags |= FUSE_EXPLICIT_INVAL_DATA;
2151 outargflags |= FUSE_SETXATTR_EXT;
2153 if (inargflags & FUSE_INIT_EXT) {
2154 outargflags |= FUSE_INIT_EXT;
2155 outarg.flags2 = outargflags >> 32;
2158 outarg.flags = outargflags;
2160 outarg.max_readahead = se->conn.max_readahead;
2161 outarg.max_write = se->conn.max_write;
2162 if (se->conn.proto_minor >= 13) {
2163 if (se->conn.max_background >= (1 << 16))
2164 se->conn.max_background = (1 << 16) - 1;
2165 if (se->conn.congestion_threshold > se->conn.max_background)
2166 se->conn.congestion_threshold = se->conn.max_background;
2167 if (!se->conn.congestion_threshold) {
2168 se->conn.congestion_threshold =
2169 se->conn.max_background * 3 / 4;
2172 outarg.max_background = se->conn.max_background;
2173 outarg.congestion_threshold = se->conn.congestion_threshold;
2175 if (se->conn.proto_minor >= 23)
2176 outarg.time_gran = se->conn.time_gran;
2179 fuse_log(FUSE_LOG_DEBUG,
" INIT: %u.%u\n", outarg.major, outarg.minor);
2180 fuse_log(FUSE_LOG_DEBUG,
" flags=0x%08x\n", outarg.flags);
2181 fuse_log(FUSE_LOG_DEBUG,
" max_readahead=0x%08x\n",
2182 outarg.max_readahead);
2183 fuse_log(FUSE_LOG_DEBUG,
" max_write=0x%08x\n", outarg.max_write);
2184 fuse_log(FUSE_LOG_DEBUG,
" max_background=%i\n",
2185 outarg.max_background);
2186 fuse_log(FUSE_LOG_DEBUG,
" congestion_threshold=%i\n",
2187 outarg.congestion_threshold);
2188 fuse_log(FUSE_LOG_DEBUG,
" time_gran=%u\n",
2192 outargsize = FUSE_COMPAT_INIT_OUT_SIZE;
2193 else if (arg->minor < 23)
2194 outargsize = FUSE_COMPAT_22_INIT_OUT_SIZE;
2196 send_reply_ok(req, &outarg, outargsize);
2201 struct fuse_session *se = req->se;
2206 se->got_destroy = 1;
2208 se->op.destroy(se->userdata);
2210 send_reply_ok(req, NULL, 0);
2213static void list_del_nreq(
struct fuse_notify_req *nreq)
2215 struct fuse_notify_req *prev = nreq->prev;
2216 struct fuse_notify_req *next = nreq->next;
2221static void list_add_nreq(
struct fuse_notify_req *nreq,
2222 struct fuse_notify_req *next)
2224 struct fuse_notify_req *prev = next->prev;
2231static void list_init_nreq(
struct fuse_notify_req *nreq)
2238 const void *inarg,
const struct fuse_buf *buf)
2240 struct fuse_session *se = req->se;
2241 struct fuse_notify_req *nreq;
2242 struct fuse_notify_req *head;
2244 pthread_mutex_lock(&se->lock);
2245 head = &se->notify_list;
2246 for (nreq = head->next; nreq != head; nreq = nreq->next) {
2247 if (nreq->unique == req->unique) {
2248 list_del_nreq(nreq);
2252 pthread_mutex_unlock(&se->lock);
2255 nreq->reply(nreq, req, nodeid, inarg, buf);
2258static int send_notify_iov(
struct fuse_session *se,
int notify_code,
2259 struct iovec *iov,
int count)
2261 struct fuse_out_header out;
2267 out.error = notify_code;
2268 iov[0].iov_base = &out;
2269 iov[0].iov_len =
sizeof(
struct fuse_out_header);
2271 return fuse_send_msg(se, NULL, iov, count);
2277 struct fuse_notify_poll_wakeup_out outarg;
2278 struct iovec iov[2];
2282 iov[1].iov_base = &outarg;
2283 iov[1].iov_len =
sizeof(outarg);
2285 return send_notify_iov(ph->se, FUSE_NOTIFY_POLL, iov, 2);
2292 off_t off, off_t len)
2294 struct fuse_notify_inval_inode_out outarg;
2295 struct iovec iov[2];
2300 if (se->conn.proto_minor < 12)
2307 iov[1].iov_base = &outarg;
2308 iov[1].iov_len =
sizeof(outarg);
2310 return send_notify_iov(se, FUSE_NOTIFY_INVAL_INODE, iov, 2);
2332static int fuse_lowlevel_notify_entry(
struct fuse_session *se,
fuse_ino_t parent,
2333 const char *name,
size_t namelen,
2336 struct fuse_notify_inval_entry_out outarg;
2337 struct iovec iov[3];
2342 if (se->conn.proto_minor < 12)
2345 outarg.parent = parent;
2346 outarg.namelen = namelen;
2348 if (flags & FUSE_LL_EXPIRE_ONLY)
2349 outarg.flags |= FUSE_EXPIRE_ONLY;
2351 iov[1].iov_base = &outarg;
2352 iov[1].iov_len =
sizeof(outarg);
2353 iov[2].iov_base = (
void *)name;
2354 iov[2].iov_len = namelen + 1;
2356 return send_notify_iov(se, FUSE_NOTIFY_INVAL_ENTRY, iov, 3);
2360 const char *name,
size_t namelen)
2362 return fuse_lowlevel_notify_entry(se, parent, name, namelen, FUSE_LL_INVALIDATE);
2366 const char *name,
size_t namelen)
2374 return fuse_lowlevel_notify_entry(se, parent, name, namelen, FUSE_LL_EXPIRE_ONLY);
2380 const char *name,
size_t namelen)
2382 struct fuse_notify_delete_out outarg;
2383 struct iovec iov[3];
2388 if (se->conn.proto_minor < 18)
2391 outarg.parent = parent;
2392 outarg.child = child;
2393 outarg.namelen = namelen;
2396 iov[1].iov_base = &outarg;
2397 iov[1].iov_len =
sizeof(outarg);
2398 iov[2].iov_base = (
void *)name;
2399 iov[2].iov_len = namelen + 1;
2401 return send_notify_iov(se, FUSE_NOTIFY_DELETE, iov, 3);
2408 struct fuse_out_header out;
2409 struct fuse_notify_store_out outarg;
2410 struct iovec iov[3];
2417 if (se->conn.proto_minor < 15)
2421 out.error = FUSE_NOTIFY_STORE;
2423 outarg.nodeid = ino;
2424 outarg.offset = offset;
2428 iov[0].iov_base = &out;
2429 iov[0].iov_len =
sizeof(out);
2430 iov[1].iov_base = &outarg;
2431 iov[1].iov_len =
sizeof(outarg);
2433 res = fuse_send_data_iov(se, NULL, iov, 2, bufv, flags);
2440struct fuse_retrieve_req {
2441 struct fuse_notify_req nreq;
2445static void fuse_ll_retrieve_reply(
struct fuse_notify_req *nreq,
2450 struct fuse_session *se = req->se;
2451 struct fuse_retrieve_req *rreq =
2452 container_of(nreq,
struct fuse_retrieve_req, nreq);
2453 const struct fuse_notify_retrieve_in *arg = inarg;
2460 bufv.
buf[0].
mem = PARAM(arg);
2462 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
2463 sizeof(struct fuse_notify_retrieve_in);
2465 if (bufv.
buf[0].
size < arg->size) {
2466 fuse_log(FUSE_LOG_ERR,
"fuse: retrieve reply: buffer size too small\n");
2472 if (se->op.retrieve_reply) {
2473 se->op.retrieve_reply(req, rreq->cookie, ino,
2474 arg->offset, &bufv);
2481 fuse_ll_clear_pipe(se);
2485 size_t size, off_t offset,
void *cookie)
2487 struct fuse_notify_retrieve_out outarg;
2488 struct iovec iov[2];
2489 struct fuse_retrieve_req *rreq;
2495 if (se->conn.proto_minor < 15)
2498 rreq = malloc(
sizeof(*rreq));
2502 pthread_mutex_lock(&se->lock);
2503 rreq->cookie = cookie;
2504 rreq->nreq.unique = se->notify_ctr++;
2505 rreq->nreq.reply = fuse_ll_retrieve_reply;
2506 list_add_nreq(&rreq->nreq, &se->notify_list);
2507 pthread_mutex_unlock(&se->lock);
2509 outarg.notify_unique = rreq->nreq.unique;
2510 outarg.nodeid = ino;
2511 outarg.offset = offset;
2515 iov[1].iov_base = &outarg;
2516 iov[1].iov_len =
sizeof(outarg);
2518 err = send_notify_iov(se, FUSE_NOTIFY_RETRIEVE, iov, 2);
2520 pthread_mutex_lock(&se->lock);
2521 list_del_nreq(&rreq->nreq);
2522 pthread_mutex_unlock(&se->lock);
2531 return req->se->userdata;
2542 pthread_mutex_lock(&req->lock);
2543 pthread_mutex_lock(&req->se->lock);
2544 req->u.ni.func = func;
2545 req->u.ni.data = data;
2546 pthread_mutex_unlock(&req->se->lock);
2547 if (req->interrupted && func)
2549 pthread_mutex_unlock(&req->lock);
2556 pthread_mutex_lock(&req->se->lock);
2557 interrupted = req->interrupted;
2558 pthread_mutex_unlock(&req->se->lock);
2567 [FUSE_LOOKUP] = { do_lookup,
"LOOKUP" },
2568 [FUSE_FORGET] = { do_forget,
"FORGET" },
2569 [FUSE_GETATTR] = { do_getattr,
"GETATTR" },
2570 [FUSE_SETATTR] = { do_setattr,
"SETATTR" },
2571 [FUSE_READLINK] = { do_readlink,
"READLINK" },
2572 [FUSE_SYMLINK] = { do_symlink,
"SYMLINK" },
2573 [FUSE_MKNOD] = { do_mknod,
"MKNOD" },
2574 [FUSE_MKDIR] = { do_mkdir,
"MKDIR" },
2575 [FUSE_UNLINK] = { do_unlink,
"UNLINK" },
2576 [FUSE_RMDIR] = { do_rmdir,
"RMDIR" },
2577 [FUSE_RENAME] = { do_rename,
"RENAME" },
2578 [FUSE_LINK] = { do_link,
"LINK" },
2579 [FUSE_OPEN] = { do_open,
"OPEN" },
2580 [FUSE_READ] = { do_read,
"READ" },
2581 [FUSE_WRITE] = { do_write,
"WRITE" },
2582 [FUSE_STATFS] = { do_statfs,
"STATFS" },
2583 [FUSE_RELEASE] = { do_release,
"RELEASE" },
2584 [FUSE_FSYNC] = { do_fsync,
"FSYNC" },
2585 [FUSE_SETXATTR] = { do_setxattr,
"SETXATTR" },
2586 [FUSE_GETXATTR] = { do_getxattr,
"GETXATTR" },
2587 [FUSE_LISTXATTR] = { do_listxattr,
"LISTXATTR" },
2588 [FUSE_REMOVEXATTR] = { do_removexattr,
"REMOVEXATTR" },
2589 [FUSE_FLUSH] = { do_flush,
"FLUSH" },
2590 [FUSE_INIT] = { do_init,
"INIT" },
2591 [FUSE_OPENDIR] = { do_opendir,
"OPENDIR" },
2592 [FUSE_READDIR] = { do_readdir,
"READDIR" },
2593 [FUSE_RELEASEDIR] = { do_releasedir,
"RELEASEDIR" },
2594 [FUSE_FSYNCDIR] = { do_fsyncdir,
"FSYNCDIR" },
2595 [FUSE_GETLK] = { do_getlk,
"GETLK" },
2596 [FUSE_SETLK] = { do_setlk,
"SETLK" },
2597 [FUSE_SETLKW] = { do_setlkw,
"SETLKW" },
2598 [FUSE_ACCESS] = { do_access,
"ACCESS" },
2599 [FUSE_CREATE] = { do_create,
"CREATE" },
2600 [FUSE_INTERRUPT] = { do_interrupt,
"INTERRUPT" },
2601 [FUSE_BMAP] = { do_bmap,
"BMAP" },
2602 [FUSE_IOCTL] = { do_ioctl,
"IOCTL" },
2603 [FUSE_POLL] = { do_poll,
"POLL" },
2604 [FUSE_FALLOCATE] = { do_fallocate,
"FALLOCATE" },
2605 [FUSE_DESTROY] = { do_destroy,
"DESTROY" },
2606 [FUSE_NOTIFY_REPLY] = { (
void *) 1,
"NOTIFY_REPLY" },
2607 [FUSE_BATCH_FORGET] = { do_batch_forget,
"BATCH_FORGET" },
2608 [FUSE_READDIRPLUS] = { do_readdirplus,
"READDIRPLUS"},
2609 [FUSE_RENAME2] = { do_rename2,
"RENAME2" },
2610 [FUSE_COPY_FILE_RANGE] = { do_copy_file_range,
"COPY_FILE_RANGE" },
2611 [FUSE_LSEEK] = { do_lseek,
"LSEEK" },
2612 [CUSE_INIT] = { cuse_lowlevel_init,
"CUSE_INIT" },
2615#define FUSE_MAXOP (sizeof(fuse_ll_ops) / sizeof(fuse_ll_ops[0]))
2617static const char *opname(
enum fuse_opcode opcode)
2619 if (opcode >= FUSE_MAXOP || !fuse_ll_ops[opcode].name)
2622 return fuse_ll_ops[opcode].name;
2625static int fuse_ll_copy_from_pipe(
struct fuse_bufvec *dst,
2630 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n", strerror(-res));
2634 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: short read\n");
2643 fuse_session_process_buf_int(se, buf, NULL);
2646void fuse_session_process_buf_int(
struct fuse_session *se,
2647 const struct fuse_buf *buf,
struct fuse_chan *ch)
2649 const size_t write_header_size =
sizeof(
struct fuse_in_header) +
2650 sizeof(struct fuse_write_in);
2652 struct fuse_bufvec tmpbuf = FUSE_BUFVEC_INIT(write_header_size);
2653 struct fuse_in_header *in;
2655 struct fuse_req *req;
2664 mbuf = malloc(tmpbuf.
buf[0].
size);
2666 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate header\n");
2669 tmpbuf.
buf[0].
mem = mbuf;
2671 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
2682 "unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n",
2683 (
unsigned long long) in->unique,
2684 opname((
enum fuse_opcode) in->opcode), in->opcode,
2685 (
unsigned long long) in->nodeid, buf->
size, in->pid);
2688 req = fuse_ll_alloc_req(se);
2690 struct fuse_out_header out = {
2691 .unique = in->unique,
2694 struct iovec iov = {
2696 .iov_len =
sizeof(
struct fuse_out_header),
2699 fuse_send_msg(se, ch, &iov, 1);
2703 req->unique = in->unique;
2704 req->ctx.uid = in->uid;
2705 req->ctx.gid = in->gid;
2706 req->ctx.pid = in->pid;
2707 req->ch = ch ? fuse_chan_get(ch) : NULL;
2710 if (!se->got_init) {
2711 enum fuse_opcode expected;
2713 expected = se->cuse_data ? CUSE_INIT : FUSE_INIT;
2714 if (in->opcode != expected)
2716 }
else if (in->opcode == FUSE_INIT || in->opcode == CUSE_INIT)
2721 if (se->deny_others && in->uid != se->owner && in->uid != 0 &&
2722 in->opcode != FUSE_INIT && in->opcode != FUSE_READ &&
2723 in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC &&
2724 in->opcode != FUSE_RELEASE && in->opcode != FUSE_READDIR &&
2725 in->opcode != FUSE_FSYNCDIR && in->opcode != FUSE_RELEASEDIR &&
2726 in->opcode != FUSE_NOTIFY_REPLY &&
2727 in->opcode != FUSE_READDIRPLUS)
2731 if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func)
2733 if (in->opcode != FUSE_INTERRUPT) {
2734 struct fuse_req *intr;
2735 pthread_mutex_lock(&se->lock);
2736 intr = check_interrupt(se, req);
2737 list_add_req(req, &se->list);
2738 pthread_mutex_unlock(&se->lock);
2744 (in->opcode != FUSE_WRITE || !se->op.write_buf) &&
2745 in->opcode != FUSE_NOTIFY_REPLY) {
2749 newmbuf = realloc(mbuf, buf->
size);
2750 if (newmbuf == NULL)
2754 tmpbuf = FUSE_BUFVEC_INIT(buf->
size - write_header_size);
2755 tmpbuf.
buf[0].
mem = (
char *)mbuf + write_header_size;
2757 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
2765 inarg = (
void *) &in[1];
2766 if (in->opcode == FUSE_WRITE && se->op.write_buf)
2767 do_write_buf(req, in->nodeid, inarg, buf);
2768 else if (in->opcode == FUSE_NOTIFY_REPLY)
2769 do_notify_reply(req, in->nodeid, inarg, buf);
2771 fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
2781 fuse_ll_clear_pipe(se);
2785#define LL_OPTION(n,o,v) \
2786 { n, offsetof(struct fuse_session, o), v }
2788static const struct fuse_opt fuse_ll_opts[] = {
2789 LL_OPTION(
"debug", debug, 1),
2790 LL_OPTION(
"-d", debug, 1),
2791 LL_OPTION(
"--debug", debug, 1),
2792 LL_OPTION(
"allow_root", deny_others, 1),
2798 printf(
"using FUSE kernel interface version %i.%i\n",
2799 FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
2800 fuse_mount_version();
2808" -o allow_other allow access by all users\n"
2809" -o allow_root allow access by root\n"
2810" -o auto_unmount auto unmount on process termination\n");
2815 struct fuse_ll_pipe *llp;
2817 if (se->got_init && !se->got_destroy) {
2819 se->op.destroy(se->userdata);
2821 llp = pthread_getspecific(se->pipe_key);
2823 fuse_ll_pipe_free(llp);
2824 pthread_key_delete(se->pipe_key);
2825 pthread_mutex_destroy(&se->lock);
2826 free(se->cuse_data);
2831 destroy_mount_opts(se->mo);
2836static void fuse_ll_pipe_destructor(
void *data)
2838 struct fuse_ll_pipe *llp = data;
2839 fuse_ll_pipe_free(llp);
2844 return fuse_session_receive_buf_int(se, buf, NULL);
2847int fuse_session_receive_buf_int(
struct fuse_session *se,
struct fuse_buf *buf,
2848 struct fuse_chan *ch)
2853 size_t bufsize = se->bufsize;
2854 struct fuse_ll_pipe *llp;
2860 llp = fuse_ll_get_pipe(se);
2864 if (llp->size < bufsize) {
2865 if (llp->can_grow) {
2866 res = fcntl(llp->pipe[0], F_SETPIPE_SZ, bufsize);
2869 res = grow_pipe_to_max(llp->pipe[0]);
2876 if (llp->size < bufsize)
2880 if (se->io != NULL && se->io->splice_receive != NULL) {
2881 res = se->io->splice_receive(ch ? ch->fd : se->fd, NULL,
2882 llp->pipe[1], NULL, bufsize, 0,
2885 res = splice(ch ? ch->fd : se->fd, NULL, llp->pipe[1], NULL,
2894 if (err == ENODEV) {
2900 if (err != EINTR && err != EAGAIN)
2901 perror(
"fuse: splice from device");
2905 if (res <
sizeof(
struct fuse_in_header)) {
2906 fuse_log(FUSE_LOG_ERR,
"short splice from fuse device\n");
2921 if (res <
sizeof(
struct fuse_in_header) +
2922 sizeof(
struct fuse_write_in) + pagesize) {
2927 buf->
mem = malloc(se->bufsize);
2930 "fuse: failed to allocate read buffer\n");
2940 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n",
2942 fuse_ll_clear_pipe(se);
2945 if (res < tmpbuf.size) {
2946 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: short read\n");
2947 fuse_ll_clear_pipe(se);
2950 assert(res == tmpbuf.size);
2954 buf->
fd = tmpbuf.fd;
2964 buf->
mem = malloc(se->bufsize);
2967 "fuse: failed to allocate read buffer\n");
2973 if (se->io != NULL) {
2976 res = se->io->read(ch ? ch->fd : se->fd,
buf->
mem, se->bufsize,
2979 res = read(ch ? ch->fd : se->fd,
buf->
mem, se->bufsize);
2991 if (err == ENODEV) {
3000 if (err != EINTR && err != EAGAIN)
3001 perror(
"fuse: reading device");
3004 if ((
size_t) res <
sizeof(
struct fuse_in_header)) {
3005 fuse_log(FUSE_LOG_ERR,
"short read on fuse device\n");
3016 size_t op_size,
void *userdata)
3019 struct fuse_session *se;
3020 struct mount_opts *mo;
3023 fuse_log(FUSE_LOG_ERR,
"fuse: warning: library too old, some operations may not work\n");
3027 if (args->
argc == 0) {
3028 fuse_log(FUSE_LOG_ERR,
"fuse: empty argv passed to fuse_session_new().\n");
3032 se = (
struct fuse_session *) calloc(1,
sizeof(
struct fuse_session));
3034 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate fuse object\n");
3038 se->conn.max_write = UINT_MAX;
3039 se->conn.max_readahead = UINT_MAX;
3044 if(se->deny_others) {
3054 mo = parse_mount_opts(args);
3058 if(args->
argc == 1 &&
3059 args->
argv[0][0] ==
'-') {
3060 fuse_log(FUSE_LOG_ERR,
"fuse: warning: argv[0] looks like an option, but "
3061 "will be ignored\n");
3062 }
else if (args->
argc != 1) {
3064 fuse_log(FUSE_LOG_ERR,
"fuse: unknown option(s): `");
3065 for(i = 1; i < args->
argc-1; i++)
3072 fuse_log(FUSE_LOG_DEBUG,
"FUSE library version: %s\n", PACKAGE_VERSION);
3074 se->bufsize = FUSE_MAX_MAX_PAGES * getpagesize() +
3075 FUSE_BUFFER_HEADER_SIZE;
3077 list_init_req(&se->list);
3078 list_init_req(&se->interrupts);
3079 list_init_nreq(&se->notify_list);
3081 pthread_mutex_init(&se->lock, NULL);
3083 err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor);
3085 fuse_log(FUSE_LOG_ERR,
"fuse: failed to create thread specific key: %s\n",
3090 memcpy(&se->op, op, op_size);
3091 se->owner = getuid();
3092 se->userdata = userdata;
3098 pthread_mutex_destroy(&se->lock);
3103 destroy_mount_opts(mo);
3114 fuse_log(FUSE_LOG_ERR,
"Invalid file descriptor value %d passed to "
3115 "fuse_session_custom_io()\n", fd);
3119 fuse_log(FUSE_LOG_ERR,
"No custom IO passed to "
3120 "fuse_session_custom_io()\n");
3122 }
else if (io->read == NULL || io->writev == NULL) {
3127 fuse_log(FUSE_LOG_ERR,
"io passed to fuse_session_custom_io() must "
3128 "implement both io->read() and io->writev\n");
3132 se->io = malloc(
sizeof(
struct fuse_custom_io));
3133 if (se->io == NULL) {
3134 fuse_log(FUSE_LOG_ERR,
"Failed to allocate memory for custom io. "
3135 "Error: %s\n", strerror(errno));
3153 fd = open(
"/dev/null", O_RDWR);
3156 }
while (fd >= 0 && fd <= 2);
3164 fd = fuse_mnt_parse_fuse_fd(mountpoint);
3166 if (fcntl(fd, F_GETFD) == -1) {
3168 "fuse: Invalid file descriptor /dev/fd/%u\n",
3177 fd = fuse_kern_mount(mountpoint, se->mo);
3183 se->mountpoint = strdup(mountpoint);
3184 if (se->mountpoint == NULL)
3190 fuse_kern_unmount(mountpoint, fd);
3201 if (se->mountpoint != NULL) {
3202 fuse_kern_unmount(se->mountpoint, se->fd);
3204 free(se->mountpoint);
3205 se->mountpoint = NULL;
3213 size_t bufsize = 1024;
3217 unsigned long pid = req->ctx.pid;
3220 sprintf(path,
"/proc/%lu/task/%lu/status", pid, pid);
3223 buf = malloc(bufsize);
3228 fd = open(path, O_RDONLY);
3232 ret = read(fd, buf, bufsize);
3239 if ((
size_t)ret == bufsize) {
3246 s = strstr(buf,
"\nGroups:");
3254 unsigned long val = strtoul(s, &end, 0);
3274 (void) req; (void) size; (void) list;
3281__attribute__((no_sanitize_thread))
3287__attribute__((no_sanitize_thread))
3294__attribute__((no_sanitize_thread))
#define FUSE_CAP_IOCTL_DIR
#define FUSE_CAP_DONT_MASK
#define FUSE_CAP_HANDLE_KILLPRIV
#define FUSE_CAP_AUTO_INVAL_DATA
#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
#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_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)
const struct fuse_ctx * fuse_req_ctx(fuse_req_t req)
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_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[])
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_session_unmount(struct fuse_session *se)
struct fuse_session * fuse_session_new(struct fuse_args *args, const struct fuse_lowlevel_ops *op, size_t op_size, void *userdata)
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_session_mount(struct fuse_session *se, const char *mountpoint)
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_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func, void *data)
void fuse_session_reset(struct fuse_session *se)
int fuse_session_custom_io(struct fuse_session *se, const struct fuse_custom_io *io, int fd)
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_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)
enum fuse_buf_flags flags
unsigned int parallel_direct_writes
unsigned int cache_readdir