14 #include "fuse_config.h"
16 #include "fuse_kernel.h"
18 #include "fuse_misc.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) );})
46 struct fuse_pollhandle {
48 struct fuse_session *se;
51 static size_t pagesize;
53 static __attribute__((constructor))
void fuse_ll_init_pagesize(
void)
55 pagesize = getpagesize();
58 static 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);
77 static 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);
91 static size_t iov_length(
const struct iovec *iov,
size_t count)
96 for (seg = 0; seg < count; seg++)
97 ret += iov[seg].iov_len;
101 static void list_init_req(
struct fuse_req *req)
107 static void list_del_req(
struct fuse_req *req)
109 struct fuse_req *prev = req->prev;
110 struct fuse_req *next = req->next;
115 static 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);
148 static 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);
166 static 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");
211 int fuse_send_reply_iov_nofree(
fuse_req_t req,
int error,
struct iovec *iov,
214 struct fuse_out_header out;
216 if (error <= -1000 || error > 0) {
217 fuse_log(FUSE_LOG_ERR,
"fuse: bad error value: %i\n", error);
221 out.unique = req->unique;
224 iov[0].iov_base = &out;
225 iov[0].iov_len =
sizeof(
struct fuse_out_header);
227 return fuse_send_msg(req->se, req->ch, iov, count);
230 static int send_reply_iov(
fuse_req_t req,
int error,
struct iovec *iov,
235 res = fuse_send_reply_iov_nofree(req, error, iov, count);
240 static int send_reply(
fuse_req_t req,
int error,
const void *arg,
246 iov[1].iov_base = (
void *) arg;
247 iov[1].iov_len = argsize;
250 return send_reply_iov(req, error, iov, count);
256 struct iovec *padded_iov;
258 padded_iov = malloc((count + 1) *
sizeof(
struct iovec));
259 if (padded_iov == NULL)
262 memcpy(padded_iov + 1, iov, count *
sizeof(
struct iovec));
265 res = send_reply_iov(req, 0, padded_iov, count);
275 const char *name,
const struct stat *stbuf, off_t off)
280 size_t entlen_padded;
281 struct fuse_dirent *dirent;
283 namelen = strlen(name);
284 entlen = FUSE_NAME_OFFSET + namelen;
285 entlen_padded = FUSE_DIRENT_ALIGN(entlen);
287 if ((buf == NULL) || (entlen_padded > bufsize))
288 return entlen_padded;
290 dirent = (
struct fuse_dirent*) buf;
291 dirent->ino = stbuf->st_ino;
293 dirent->namelen = namelen;
294 dirent->type = (stbuf->st_mode & S_IFMT) >> 12;
295 memcpy(dirent->name, name, namelen);
296 memset(dirent->name + namelen, 0, entlen_padded - entlen);
298 return entlen_padded;
301 static void convert_statfs(
const struct statvfs *stbuf,
302 struct fuse_kstatfs *kstatfs)
304 kstatfs->bsize = stbuf->f_bsize;
305 kstatfs->frsize = stbuf->f_frsize;
306 kstatfs->blocks = stbuf->f_blocks;
307 kstatfs->bfree = stbuf->f_bfree;
308 kstatfs->bavail = stbuf->f_bavail;
309 kstatfs->files = stbuf->f_files;
310 kstatfs->ffree = stbuf->f_ffree;
311 kstatfs->namelen = stbuf->f_namemax;
314 static int send_reply_ok(
fuse_req_t req,
const void *arg,
size_t argsize)
316 return send_reply(req, 0, arg, argsize);
321 return send_reply(req, -err, NULL, 0);
329 static unsigned long calc_timeout_sec(
double t)
331 if (t > (
double) ULONG_MAX)
336 return (
unsigned long) t;
339 static unsigned int calc_timeout_nsec(
double t)
341 double f = t - (double) calc_timeout_sec(t);
344 else if (f >= 0.999999999)
347 return (
unsigned int) (f * 1.0e9);
350 static void fill_entry(
struct fuse_entry_out *arg,
353 arg->nodeid = e->
ino;
358 arg->attr_valid_nsec = calc_timeout_nsec(e->
attr_timeout);
359 convert_stat(&e->
attr, &arg->attr);
371 size_t entlen_padded;
373 namelen = strlen(name);
374 entlen = FUSE_NAME_OFFSET_DIRENTPLUS + namelen;
375 entlen_padded = FUSE_DIRENT_ALIGN(entlen);
376 if ((buf == NULL) || (entlen_padded > bufsize))
377 return entlen_padded;
379 struct fuse_direntplus *dp = (
struct fuse_direntplus *) buf;
380 memset(&dp->entry_out, 0,
sizeof(dp->entry_out));
381 fill_entry(&dp->entry_out, e);
383 struct fuse_dirent *dirent = &dp->dirent;
384 dirent->ino = e->
attr.st_ino;
386 dirent->namelen = namelen;
387 dirent->type = (e->
attr.st_mode & S_IFMT) >> 12;
388 memcpy(dirent->name, name, namelen);
389 memset(dirent->name + namelen, 0, entlen_padded - entlen);
391 return entlen_padded;
394 static void fill_open(
struct fuse_open_out *arg,
399 arg->open_flags |= FOPEN_DIRECT_IO;
401 arg->open_flags |= FOPEN_KEEP_CACHE;
403 arg->open_flags |= FOPEN_CACHE_DIR;
405 arg->open_flags |= FOPEN_NONSEEKABLE;
407 arg->open_flags |= FOPEN_NOFLUSH;
409 arg->open_flags |= FOPEN_PARALLEL_DIRECT_WRITES;
414 struct fuse_entry_out arg;
415 size_t size = req->se->conn.proto_minor < 9 ?
416 FUSE_COMPAT_ENTRY_OUT_SIZE :
sizeof(arg);
420 if (!e->
ino && req->se->conn.proto_minor < 4)
423 memset(&arg, 0,
sizeof(arg));
425 return send_reply_ok(req, &arg, size);
431 char buf[
sizeof(
struct fuse_entry_out) + sizeof(struct fuse_open_out)];
432 size_t entrysize = req->se->conn.proto_minor < 9 ?
433 FUSE_COMPAT_ENTRY_OUT_SIZE :
sizeof(
struct fuse_entry_out);
434 struct fuse_entry_out *earg = (
struct fuse_entry_out *) buf;
435 struct fuse_open_out *oarg = (
struct fuse_open_out *) (buf + entrysize);
437 memset(buf, 0,
sizeof(buf));
440 return send_reply_ok(req, buf,
441 entrysize +
sizeof(
struct fuse_open_out));
447 struct fuse_attr_out arg;
448 size_t size = req->se->conn.proto_minor < 9 ?
449 FUSE_COMPAT_ATTR_OUT_SIZE :
sizeof(arg);
451 memset(&arg, 0,
sizeof(arg));
452 arg.attr_valid = calc_timeout_sec(attr_timeout);
453 arg.attr_valid_nsec = calc_timeout_nsec(attr_timeout);
454 convert_stat(attr, &arg.attr);
456 return send_reply_ok(req, &arg, size);
461 return send_reply_ok(req, linkname, strlen(linkname));
466 struct fuse_open_out arg;
468 memset(&arg, 0,
sizeof(arg));
470 return send_reply_ok(req, &arg,
sizeof(arg));
475 struct fuse_write_out arg;
477 memset(&arg, 0,
sizeof(arg));
480 return send_reply_ok(req, &arg,
sizeof(arg));
485 return send_reply_ok(req, buf, size);
488 static int fuse_send_data_iov_fallback(
struct fuse_session *se,
489 struct fuse_chan *ch,
490 struct iovec *iov,
int iov_count,
494 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
499 if (
buf->count == 1 &&
buf->idx == 0 &&
buf->off == 0 &&
504 iov[iov_count].iov_base =
buf->buf[0].
mem;
505 iov[iov_count].iov_len = len;
507 return fuse_send_msg(se, ch, iov, iov_count);
510 res = posix_memalign(&mbuf, pagesize, len);
514 mem_buf.
buf[0].
mem = mbuf;
522 iov[iov_count].iov_base = mbuf;
523 iov[iov_count].iov_len = len;
525 res = fuse_send_msg(se, ch, iov, iov_count);
531 struct fuse_ll_pipe {
537 static void fuse_ll_pipe_free(
struct fuse_ll_pipe *llp)
545 #if !defined(HAVE_PIPE2) || !defined(O_CLOEXEC)
546 static int fuse_pipe(
int fds[2])
553 if (fcntl(fds[0], F_SETFL, O_NONBLOCK) == -1 ||
554 fcntl(fds[1], F_SETFL, O_NONBLOCK) == -1 ||
555 fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
556 fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
564 static int fuse_pipe(
int fds[2])
566 return pipe2(fds, O_CLOEXEC | O_NONBLOCK);
570 static struct fuse_ll_pipe *fuse_ll_get_pipe(
struct fuse_session *se)
572 struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
576 llp = malloc(
sizeof(
struct fuse_ll_pipe));
580 res = fuse_pipe(llp->pipe);
589 llp->size = pagesize * 16;
592 pthread_setspecific(se->pipe_key, llp);
599 static void fuse_ll_clear_pipe(
struct fuse_session *se)
601 struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
603 pthread_setspecific(se->pipe_key, NULL);
604 fuse_ll_pipe_free(llp);
608 #if defined(HAVE_SPLICE) && defined(HAVE_VMSPLICE)
609 static int read_back(
int fd,
char *buf,
size_t len)
613 res = read(fd, buf, len);
615 fuse_log(FUSE_LOG_ERR,
"fuse: internal error: failed to read back from pipe: %s\n", strerror(errno));
619 fuse_log(FUSE_LOG_ERR,
"fuse: internal error: short read back from pipe: %i from %zi\n", res, len);
625 static int grow_pipe_to_max(
int pipefd)
632 maxfd = open(
"/proc/sys/fs/pipe-max-size", O_RDONLY);
636 res = read(maxfd, buf,
sizeof(buf) - 1);
648 res = fcntl(pipefd, F_SETPIPE_SZ, max);
654 static int fuse_send_data_iov(
struct fuse_session *se,
struct fuse_chan *ch,
655 struct iovec *iov,
int iov_count,
660 struct fuse_out_header *out = iov[0].iov_base;
661 struct fuse_ll_pipe *llp;
664 size_t total_buf_size;
667 struct fuse_bufvec pipe_buf = FUSE_BUFVEC_INIT(len);
669 if (se->broken_splice_nonblock)
679 total_buf_size -=
buf->off;
681 if (total_buf_size < 2 * pagesize)
684 if (se->conn.proto_minor < 14 ||
688 llp = fuse_ll_get_pipe(se);
693 headerlen = iov_length(iov, iov_count);
695 out->len = headerlen + len;
701 pipesize = pagesize * (iov_count +
buf->count + 1) + out->len;
703 if (llp->size < pipesize) {
705 res = fcntl(llp->pipe[0], F_SETPIPE_SZ, pipesize);
707 res = grow_pipe_to_max(llp->pipe[0]);
715 if (llp->size < pipesize)
720 res = vmsplice(llp->pipe[1], iov, iov_count, SPLICE_F_NONBLOCK);
724 if (res != headerlen) {
726 fuse_log(FUSE_LOG_ERR,
"fuse: short vmsplice to pipe: %u/%zu\n", res,
732 pipe_buf.
buf[0].
fd = llp->pipe[1];
737 if (res == -EAGAIN || res == -EINVAL) {
749 se->broken_splice_nonblock = 1;
751 pthread_setspecific(se->pipe_key, NULL);
752 fuse_ll_pipe_free(llp);
759 if (res != 0 && res < len) {
760 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
762 size_t now_len = res;
772 res = posix_memalign(&mbuf, pagesize, len);
776 mem_buf.
buf[0].
mem = mbuf;
777 mem_buf.
off = now_len;
781 size_t extra_len = res;
787 tmpbuf = malloc(headerlen);
788 if (tmpbuf == NULL) {
793 res = read_back(llp->pipe[0], tmpbuf, headerlen);
799 res = read_back(llp->pipe[0], mbuf, now_len);
804 len = now_len + extra_len;
805 iov[iov_count].iov_base = mbuf;
806 iov[iov_count].iov_len = len;
808 res = fuse_send_msg(se, ch, iov, iov_count);
816 out->len = headerlen + len;
820 " unique: %llu, success, outsize: %i (splice)\n",
821 (
unsigned long long) out->unique, out->len);
827 splice_flags |= SPLICE_F_MOVE;
829 if (se->io != NULL && se->io->splice_send != NULL) {
830 res = se->io->splice_send(llp->pipe[0], NULL,
831 ch ? ch->fd : se->fd, NULL, out->len,
832 splice_flags, se->userdata);
834 res = splice(llp->pipe[0], NULL, ch ? ch->fd : se->fd, NULL,
835 out->len, splice_flags);
839 perror(
"fuse: splice from pipe");
842 if (res != out->len) {
844 fuse_log(FUSE_LOG_ERR,
"fuse: short splice from pipe: %u/%u\n",
851 fuse_ll_clear_pipe(se);
855 return fuse_send_data_iov_fallback(se, ch, iov, iov_count,
buf, len);
858 static int fuse_send_data_iov(
struct fuse_session *se,
struct fuse_chan *ch,
859 struct iovec *iov,
int iov_count,
865 return fuse_send_data_iov_fallback(se, ch, iov, iov_count,
buf, len);
873 struct fuse_out_header out;
876 iov[0].iov_base = &out;
877 iov[0].iov_len =
sizeof(
struct fuse_out_header);
879 out.unique = req->unique;
882 res = fuse_send_data_iov(req->se, req->ch, iov, 1, bufv, flags);
893 struct fuse_statfs_out arg;
894 size_t size = req->se->conn.proto_minor < 4 ?
895 FUSE_COMPAT_STATFS_SIZE :
sizeof(arg);
897 memset(&arg, 0,
sizeof(arg));
898 convert_statfs(stbuf, &arg.st);
900 return send_reply_ok(req, &arg, size);
905 struct fuse_getxattr_out arg;
907 memset(&arg, 0,
sizeof(arg));
910 return send_reply_ok(req, &arg,
sizeof(arg));
915 struct fuse_lk_out arg;
917 memset(&arg, 0,
sizeof(arg));
918 arg.lk.type = lock->l_type;
919 if (lock->l_type != F_UNLCK) {
920 arg.lk.start = lock->l_start;
921 if (lock->l_len == 0)
922 arg.lk.end = OFFSET_MAX;
924 arg.lk.end = lock->l_start + lock->l_len - 1;
926 arg.lk.pid = lock->l_pid;
927 return send_reply_ok(req, &arg,
sizeof(arg));
932 struct fuse_bmap_out arg;
934 memset(&arg, 0,
sizeof(arg));
937 return send_reply_ok(req, &arg,
sizeof(arg));
940 static struct fuse_ioctl_iovec *fuse_ioctl_iovec_copy(
const struct iovec *iov,
943 struct fuse_ioctl_iovec *fiov;
946 fiov = malloc(
sizeof(fiov[0]) * count);
950 for (i = 0; i < count; i++) {
951 fiov[i].base = (uintptr_t) iov[i].iov_base;
952 fiov[i].len = iov[i].iov_len;
959 const struct iovec *in_iov,
size_t in_count,
960 const struct iovec *out_iov,
size_t out_count)
962 struct fuse_ioctl_out arg;
963 struct fuse_ioctl_iovec *in_fiov = NULL;
964 struct fuse_ioctl_iovec *out_fiov = NULL;
969 memset(&arg, 0,
sizeof(arg));
970 arg.flags |= FUSE_IOCTL_RETRY;
971 arg.in_iovs = in_count;
972 arg.out_iovs = out_count;
973 iov[count].iov_base = &arg;
974 iov[count].iov_len =
sizeof(arg);
977 if (req->se->conn.proto_minor < 16) {
979 iov[count].iov_base = (
void *)in_iov;
980 iov[count].iov_len =
sizeof(in_iov[0]) * in_count;
985 iov[count].iov_base = (
void *)out_iov;
986 iov[count].iov_len =
sizeof(out_iov[0]) * out_count;
991 if (
sizeof(
void *) == 4 && req->ioctl_64bit) {
997 in_fiov = fuse_ioctl_iovec_copy(in_iov, in_count);
1001 iov[count].iov_base = (
void *)in_fiov;
1002 iov[count].iov_len =
sizeof(in_fiov[0]) * in_count;
1006 out_fiov = fuse_ioctl_iovec_copy(out_iov, out_count);
1010 iov[count].iov_base = (
void *)out_fiov;
1011 iov[count].iov_len =
sizeof(out_fiov[0]) * out_count;
1016 res = send_reply_iov(req, 0, iov, count);
1030 struct fuse_ioctl_out arg;
1031 struct iovec iov[3];
1034 memset(&arg, 0,
sizeof(arg));
1035 arg.result = result;
1036 iov[count].iov_base = &arg;
1037 iov[count].iov_len =
sizeof(arg);
1041 iov[count].iov_base = (
char *) buf;
1042 iov[count].iov_len = size;
1046 return send_reply_iov(req, 0, iov, count);
1052 struct iovec *padded_iov;
1053 struct fuse_ioctl_out arg;
1056 padded_iov = malloc((count + 2) *
sizeof(
struct iovec));
1057 if (padded_iov == NULL)
1060 memset(&arg, 0,
sizeof(arg));
1061 arg.result = result;
1062 padded_iov[1].iov_base = &arg;
1063 padded_iov[1].iov_len =
sizeof(arg);
1065 memcpy(&padded_iov[2], iov, count *
sizeof(
struct iovec));
1067 res = send_reply_iov(req, 0, padded_iov, count + 2);
1075 struct fuse_poll_out arg;
1077 memset(&arg, 0,
sizeof(arg));
1078 arg.revents = revents;
1080 return send_reply_ok(req, &arg,
sizeof(arg));
1085 struct fuse_lseek_out arg;
1087 memset(&arg, 0,
sizeof(arg));
1090 return send_reply_ok(req, &arg,
sizeof(arg));
1095 char *name = (
char *) inarg;
1097 if (req->se->op.lookup)
1098 req->se->op.lookup(req, nodeid, name);
1105 struct fuse_forget_in *arg = (
struct fuse_forget_in *) inarg;
1107 if (req->se->op.forget)
1108 req->se->op.forget(req, nodeid, arg->nlookup);
1116 struct fuse_batch_forget_in *arg = (
void *) inarg;
1117 struct fuse_forget_one *param = (
void *) PARAM(arg);
1122 if (req->se->op.forget_multi) {
1123 req->se->op.forget_multi(req, arg->count,
1124 (
struct fuse_forget_data *) param);
1125 }
else if (req->se->op.forget) {
1126 for (i = 0; i < arg->count; i++) {
1127 struct fuse_forget_one *forget = ¶m[i];
1128 struct fuse_req *dummy_req;
1130 dummy_req = fuse_ll_alloc_req(req->se);
1131 if (dummy_req == NULL)
1134 dummy_req->unique = req->unique;
1135 dummy_req->ctx = req->ctx;
1136 dummy_req->ch = NULL;
1138 req->se->op.forget(dummy_req, forget->nodeid,
1152 if (req->se->conn.proto_minor >= 9) {
1153 struct fuse_getattr_in *arg = (
struct fuse_getattr_in *) inarg;
1155 if (arg->getattr_flags & FUSE_GETATTR_FH) {
1156 memset(&fi, 0,
sizeof(fi));
1162 if (req->se->op.getattr)
1163 req->se->op.getattr(req, nodeid, fip);
1170 struct fuse_setattr_in *arg = (
struct fuse_setattr_in *) inarg;
1172 if (req->se->op.setattr) {
1176 memset(&stbuf, 0,
sizeof(stbuf));
1177 convert_attr(arg, &stbuf);
1178 if (arg->valid & FATTR_FH) {
1179 arg->valid &= ~FATTR_FH;
1180 memset(&fi_store, 0,
sizeof(fi_store));
1185 FUSE_SET_ATTR_MODE |
1188 FUSE_SET_ATTR_SIZE |
1189 FUSE_SET_ATTR_ATIME |
1190 FUSE_SET_ATTR_MTIME |
1191 FUSE_SET_ATTR_KILL_SUID |
1192 FUSE_SET_ATTR_KILL_SGID |
1193 FUSE_SET_ATTR_ATIME_NOW |
1194 FUSE_SET_ATTR_MTIME_NOW |
1195 FUSE_SET_ATTR_CTIME;
1197 req->se->op.setattr(req, nodeid, &stbuf, arg->valid, fi);
1204 struct fuse_access_in *arg = (
struct fuse_access_in *) inarg;
1206 if (req->se->op.access)
1207 req->se->op.access(req, nodeid, arg->mask);
1216 if (req->se->op.readlink)
1217 req->se->op.readlink(req, nodeid);
1224 struct fuse_mknod_in *arg = (
struct fuse_mknod_in *) inarg;
1225 char *name = PARAM(arg);
1227 if (req->se->conn.proto_minor >= 12)
1228 req->ctx.umask = arg->umask;
1230 name = (
char *) inarg + FUSE_COMPAT_MKNOD_IN_SIZE;
1232 if (req->se->op.mknod)
1233 req->se->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
1240 struct fuse_mkdir_in *arg = (
struct fuse_mkdir_in *) inarg;
1242 if (req->se->conn.proto_minor >= 12)
1243 req->ctx.umask = arg->umask;
1245 if (req->se->op.mkdir)
1246 req->se->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
1253 char *name = (
char *) inarg;
1255 if (req->se->op.unlink)
1256 req->se->op.unlink(req, nodeid, name);
1263 char *name = (
char *) inarg;
1265 if (req->se->op.rmdir)
1266 req->se->op.rmdir(req, nodeid, name);
1273 char *name = (
char *) inarg;
1274 char *linkname = ((
char *) inarg) + strlen((
char *) inarg) + 1;
1276 if (req->se->op.symlink)
1277 req->se->op.symlink(req, linkname, nodeid, name);
1284 struct fuse_rename_in *arg = (
struct fuse_rename_in *) inarg;
1285 char *oldname = PARAM(arg);
1286 char *newname = oldname + strlen(oldname) + 1;
1288 if (req->se->op.rename)
1289 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1297 struct fuse_rename2_in *arg = (
struct fuse_rename2_in *) inarg;
1298 char *oldname = PARAM(arg);
1299 char *newname = oldname + strlen(oldname) + 1;
1301 if (req->se->op.rename)
1302 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1310 struct fuse_link_in *arg = (
struct fuse_link_in *) inarg;
1312 if (req->se->op.link)
1313 req->se->op.link(req, arg->oldnodeid, nodeid, PARAM(arg));
1320 struct fuse_create_in *arg = (
struct fuse_create_in *) inarg;
1322 if (req->se->op.create) {
1324 char *name = PARAM(arg);
1326 memset(&fi, 0,
sizeof(fi));
1327 fi.
flags = arg->flags;
1329 if (req->se->conn.proto_minor >= 12)
1330 req->ctx.umask = arg->umask;
1332 name = (
char *) inarg +
sizeof(
struct fuse_open_in);
1334 req->se->op.create(req, nodeid, name, arg->mode, &fi);
1341 struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
1344 memset(&fi, 0,
sizeof(fi));
1345 fi.
flags = arg->flags;
1347 if (req->se->op.open)
1348 req->se->op.open(req, nodeid, &fi);
1355 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1357 if (req->se->op.read) {
1360 memset(&fi, 0,
sizeof(fi));
1362 if (req->se->conn.proto_minor >= 9) {
1364 fi.
flags = arg->flags;
1366 req->se->op.read(req, nodeid, arg->size, arg->offset, &fi);
1373 struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
1377 memset(&fi, 0,
sizeof(fi));
1379 fi.
writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
1381 if (req->se->conn.proto_minor < 9) {
1382 param = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1385 fi.
flags = arg->flags;
1389 if (req->se->op.write)
1390 req->se->op.write(req, nodeid, param, arg->size,
1399 struct fuse_session *se = req->se;
1404 struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
1407 memset(&fi, 0,
sizeof(fi));
1409 fi.
writepage = arg->write_flags & FUSE_WRITE_CACHE;
1411 if (se->conn.proto_minor < 9) {
1412 bufv.
buf[0].
mem = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1413 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1414 FUSE_COMPAT_WRITE_IN_SIZE;
1418 fi.
flags = arg->flags;
1420 bufv.
buf[0].
mem = PARAM(arg);
1422 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1423 sizeof(struct fuse_write_in);
1425 if (bufv.
buf[0].
size < arg->size) {
1426 fuse_log(FUSE_LOG_ERR,
"fuse: do_write_buf: buffer size too small\n");
1432 se->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
1437 fuse_ll_clear_pipe(se);
1442 struct fuse_flush_in *arg = (
struct fuse_flush_in *) inarg;
1445 memset(&fi, 0,
sizeof(fi));
1448 if (req->se->conn.proto_minor >= 7)
1451 if (req->se->op.flush)
1452 req->se->op.flush(req, nodeid, &fi);
1459 struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
1462 memset(&fi, 0,
sizeof(fi));
1463 fi.
flags = arg->flags;
1465 if (req->se->conn.proto_minor >= 8) {
1466 fi.
flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
1469 if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) {
1470 fi.flock_release = 1;
1474 if (req->se->op.release)
1475 req->se->op.release(req, nodeid, &fi);
1482 struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
1484 int datasync = arg->fsync_flags & 1;
1486 memset(&fi, 0,
sizeof(fi));
1489 if (req->se->op.fsync)
1490 req->se->op.fsync(req, nodeid, datasync, &fi);
1497 struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
1500 memset(&fi, 0,
sizeof(fi));
1501 fi.
flags = arg->flags;
1503 if (req->se->op.opendir)
1504 req->se->op.opendir(req, nodeid, &fi);
1511 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1514 memset(&fi, 0,
sizeof(fi));
1517 if (req->se->op.readdir)
1518 req->se->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
1525 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1528 memset(&fi, 0,
sizeof(fi));
1531 if (req->se->op.readdirplus)
1532 req->se->op.readdirplus(req, nodeid, arg->size, arg->offset, &fi);
1539 struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
1542 memset(&fi, 0,
sizeof(fi));
1543 fi.
flags = arg->flags;
1546 if (req->se->op.releasedir)
1547 req->se->op.releasedir(req, nodeid, &fi);
1554 struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
1556 int datasync = arg->fsync_flags & 1;
1558 memset(&fi, 0,
sizeof(fi));
1561 if (req->se->op.fsyncdir)
1562 req->se->op.fsyncdir(req, nodeid, datasync, &fi);
1572 if (req->se->op.statfs)
1573 req->se->op.statfs(req, nodeid);
1575 struct statvfs buf = {
1585 struct fuse_setxattr_in *arg = (
struct fuse_setxattr_in *) inarg;
1586 char *name = PARAM(arg);
1587 char *value = name + strlen(name) + 1;
1589 if (req->se->op.setxattr)
1590 req->se->op.setxattr(req, nodeid, name, value, arg->size,
1598 struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
1600 if (req->se->op.getxattr)
1601 req->se->op.getxattr(req, nodeid, PARAM(arg), arg->size);
1608 struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
1610 if (req->se->op.listxattr)
1611 req->se->op.listxattr(req, nodeid, arg->size);
1618 char *name = (
char *) inarg;
1620 if (req->se->op.removexattr)
1621 req->se->op.removexattr(req, nodeid, name);
1626 static void convert_fuse_file_lock(
struct fuse_file_lock *fl,
1627 struct flock *flock)
1629 memset(flock, 0,
sizeof(
struct flock));
1630 flock->l_type = fl->type;
1631 flock->l_whence = SEEK_SET;
1632 flock->l_start = fl->start;
1633 if (fl->end == OFFSET_MAX)
1636 flock->l_len = fl->end - fl->start + 1;
1637 flock->l_pid = fl->pid;
1642 struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
1646 memset(&fi, 0,
sizeof(fi));
1650 convert_fuse_file_lock(&arg->lk, &flock);
1651 if (req->se->op.getlk)
1652 req->se->op.getlk(req, nodeid, &fi, &flock);
1658 const void *inarg,
int sleep)
1660 struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
1664 memset(&fi, 0,
sizeof(fi));
1668 if (arg->lk_flags & FUSE_LK_FLOCK) {
1671 switch (arg->lk.type) {
1685 if (req->se->op.flock)
1686 req->se->op.flock(req, nodeid, &fi, op);
1690 convert_fuse_file_lock(&arg->lk, &flock);
1691 if (req->se->op.setlk)
1692 req->se->op.setlk(req, nodeid, &fi, &flock, sleep);
1700 do_setlk_common(req, nodeid, inarg, 0);
1705 do_setlk_common(req, nodeid, inarg, 1);
1708 static int find_interrupted(
struct fuse_session *se,
struct fuse_req *req)
1710 struct fuse_req *curr;
1712 for (curr = se->list.next; curr != &se->list; curr = curr->next) {
1713 if (curr->unique == req->u.i.unique) {
1718 pthread_mutex_unlock(&se->lock);
1721 pthread_mutex_lock(&curr->lock);
1722 pthread_mutex_lock(&se->lock);
1723 curr->interrupted = 1;
1724 func = curr->u.ni.func;
1725 data = curr->u.ni.data;
1726 pthread_mutex_unlock(&se->lock);
1729 pthread_mutex_unlock(&curr->lock);
1731 pthread_mutex_lock(&se->lock);
1734 fuse_chan_put(req->ch);
1742 for (curr = se->interrupts.next; curr != &se->interrupts;
1743 curr = curr->next) {
1744 if (curr->u.i.unique == req->u.i.unique)
1752 struct fuse_interrupt_in *arg = (
struct fuse_interrupt_in *) inarg;
1753 struct fuse_session *se = req->se;
1757 fuse_log(FUSE_LOG_DEBUG,
"INTERRUPT: %llu\n",
1758 (
unsigned long long) arg->unique);
1760 req->u.i.unique = arg->unique;
1762 pthread_mutex_lock(&se->lock);
1763 if (find_interrupted(se, req)) {
1764 fuse_chan_put(req->ch);
1768 list_add_req(req, &se->interrupts);
1769 pthread_mutex_unlock(&se->lock);
1772 static struct fuse_req *check_interrupt(
struct fuse_session *se,
1773 struct fuse_req *req)
1775 struct fuse_req *curr;
1777 for (curr = se->interrupts.next; curr != &se->interrupts;
1778 curr = curr->next) {
1779 if (curr->u.i.unique == req->unique) {
1780 req->interrupted = 1;
1782 fuse_chan_put(curr->ch);
1788 curr = se->interrupts.next;
1789 if (curr != &se->interrupts) {
1791 list_init_req(curr);
1799 struct fuse_bmap_in *arg = (
struct fuse_bmap_in *) inarg;
1801 if (req->se->op.bmap)
1802 req->se->op.bmap(req, nodeid, arg->blocksize, arg->block);
1809 struct fuse_ioctl_in *arg = (
struct fuse_ioctl_in *) inarg;
1810 unsigned int flags = arg->flags;
1811 void *in_buf = arg->in_size ? PARAM(arg) : NULL;
1814 if (
flags & FUSE_IOCTL_DIR &&
1820 memset(&fi, 0,
sizeof(fi));
1823 if (
sizeof(
void *) == 4 && req->se->conn.proto_minor >= 16 &&
1824 !(
flags & FUSE_IOCTL_32BIT)) {
1825 req->ioctl_64bit = 1;
1828 if (req->se->op.ioctl)
1829 req->se->op.ioctl(req, nodeid, arg->cmd,
1830 (
void *)(uintptr_t)arg->arg, &fi,
flags,
1831 in_buf, arg->in_size, arg->out_size);
1843 struct fuse_poll_in *arg = (
struct fuse_poll_in *) inarg;
1846 memset(&fi, 0,
sizeof(fi));
1850 if (req->se->op.poll) {
1851 struct fuse_pollhandle *ph = NULL;
1853 if (arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) {
1854 ph = malloc(
sizeof(
struct fuse_pollhandle));
1863 req->se->op.poll(req, nodeid, &fi, ph);
1871 struct fuse_fallocate_in *arg = (
struct fuse_fallocate_in *) inarg;
1874 memset(&fi, 0,
sizeof(fi));
1877 if (req->se->op.fallocate)
1878 req->se->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi);
1885 struct fuse_copy_file_range_in *arg = (
struct fuse_copy_file_range_in *) inarg;
1888 memset(&fi_in, 0,
sizeof(fi_in));
1889 fi_in.fh = arg->fh_in;
1891 memset(&fi_out, 0,
sizeof(fi_out));
1892 fi_out.fh = arg->fh_out;
1895 if (req->se->op.copy_file_range)
1896 req->se->op.copy_file_range(req, nodeid_in, arg->off_in,
1897 &fi_in, arg->nodeid_out,
1898 arg->off_out, &fi_out, arg->len,
1906 struct fuse_lseek_in *arg = (
struct fuse_lseek_in *) inarg;
1909 memset(&fi, 0,
sizeof(fi));
1912 if (req->se->op.lseek)
1913 req->se->op.lseek(req, nodeid, arg->offset, arg->whence, &fi);
1920 static __attribute__((no_sanitize(
"thread")))
1923 struct fuse_init_in *arg = (
struct fuse_init_in *) inarg;
1924 struct fuse_init_out outarg;
1925 struct fuse_session *se = req->se;
1926 size_t bufsize = se->bufsize;
1927 size_t outargsize =
sizeof(outarg);
1928 uint64_t inargflags = 0;
1929 uint64_t outargflags = 0;
1932 fuse_log(FUSE_LOG_DEBUG,
"INIT: %u.%u\n", arg->major, arg->minor);
1933 if (arg->major == 7 && arg->minor >= 6) {
1934 fuse_log(FUSE_LOG_DEBUG,
"flags=0x%08x\n", arg->flags);
1935 fuse_log(FUSE_LOG_DEBUG,
"max_readahead=0x%08x\n",
1936 arg->max_readahead);
1939 se->conn.proto_major = arg->major;
1940 se->conn.proto_minor = arg->minor;
1941 se->conn.capable = 0;
1944 memset(&outarg, 0,
sizeof(outarg));
1945 outarg.major = FUSE_KERNEL_VERSION;
1946 outarg.minor = FUSE_KERNEL_MINOR_VERSION;
1948 if (arg->major < 7) {
1949 fuse_log(FUSE_LOG_ERR,
"fuse: unsupported protocol version: %u.%u\n",
1950 arg->major, arg->minor);
1955 if (arg->major > 7) {
1957 send_reply_ok(req, &outarg,
sizeof(outarg));
1961 if (arg->minor >= 6) {
1962 if (arg->max_readahead < se->conn.max_readahead)
1963 se->conn.max_readahead = arg->max_readahead;
1964 inargflags = arg->flags;
1965 if (inargflags & FUSE_INIT_EXT)
1966 inargflags = inargflags | (uint64_t) arg->flags2 << 32;
1967 if (inargflags & FUSE_ASYNC_READ)
1969 if (inargflags & FUSE_POSIX_LOCKS)
1971 if (inargflags & FUSE_ATOMIC_O_TRUNC)
1973 if (inargflags & FUSE_EXPORT_SUPPORT)
1975 if (inargflags & FUSE_DONT_MASK)
1977 if (inargflags & FUSE_FLOCK_LOCKS)
1979 if (inargflags & FUSE_AUTO_INVAL_DATA)
1981 if (inargflags & FUSE_DO_READDIRPLUS)
1983 if (inargflags & FUSE_READDIRPLUS_AUTO)
1985 if (inargflags & FUSE_ASYNC_DIO)
1987 if (inargflags & FUSE_WRITEBACK_CACHE)
1989 if (inargflags & FUSE_NO_OPEN_SUPPORT)
1991 if (inargflags & FUSE_PARALLEL_DIROPS)
1993 if (inargflags & FUSE_POSIX_ACL)
1995 if (inargflags & FUSE_HANDLE_KILLPRIV)
1997 if (inargflags & FUSE_CACHE_SYMLINKS)
1999 if (inargflags & FUSE_NO_OPENDIR_SUPPORT)
2001 if (inargflags & FUSE_EXPLICIT_INVAL_DATA)
2003 if (!(inargflags & FUSE_MAX_PAGES)) {
2004 size_t max_bufsize =
2005 FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
2006 + FUSE_BUFFER_HEADER_SIZE;
2007 if (bufsize > max_bufsize) {
2008 bufsize = max_bufsize;
2011 if (arg->minor >= 38)
2014 se->conn.max_readahead = 0;
2017 if (se->conn.proto_minor >= 14) {
2019 #ifdef HAVE_VMSPLICE
2020 if ((se->io == NULL) || (se->io->splice_send != NULL)) {
2024 if ((se->io == NULL) || (se->io->splice_receive != NULL)) {
2029 if (se->conn.proto_minor >= 18)
2039 #define LL_SET_DEFAULT(cond, cap) \
2040 if ((cond) && (se->conn.capable & (cap))) \
2041 se->conn.want |= (cap)
2050 LL_SET_DEFAULT(se->op.getlk && se->op.setlk,
2054 LL_SET_DEFAULT(se->op.readdirplus && se->op.readdir,
2056 se->conn.time_gran = 1;
2058 if (bufsize < FUSE_MIN_READ_BUFFER) {
2059 fuse_log(FUSE_LOG_ERR,
"fuse: warning: buffer size too small: %zu\n",
2061 bufsize = FUSE_MIN_READ_BUFFER;
2063 se->bufsize = bufsize;
2065 if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE)
2066 se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE;
2070 se->op.init(se->userdata, &se->conn);
2072 if (se->conn.want & (~se->conn.capable)) {
2073 fuse_log(FUSE_LOG_ERR,
"fuse: error: filesystem requested capabilities "
2074 "0x%x that are not supported by kernel, aborting.\n",
2075 se->conn.want & (~se->conn.capable));
2077 se->error = -EPROTO;
2082 unsigned max_read_mo = get_max_read(se->mo);
2083 if (se->conn.max_read != max_read_mo) {
2084 fuse_log(FUSE_LOG_ERR,
"fuse: error: init() and fuse_session_new() "
2085 "requested different maximum read size (%u vs %u)\n",
2086 se->conn.max_read, max_read_mo);
2088 se->error = -EPROTO;
2093 if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE) {
2094 se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
2096 if (arg->flags & FUSE_MAX_PAGES) {
2097 outarg.flags |= FUSE_MAX_PAGES;
2098 outarg.max_pages = (se->conn.max_write - 1) / getpagesize() + 1;
2100 outargflags = outarg.flags;
2103 outargflags |= FUSE_BIG_WRITES;
2106 outargflags |= FUSE_ASYNC_READ;
2108 outargflags |= FUSE_POSIX_LOCKS;
2110 outargflags |= FUSE_ATOMIC_O_TRUNC;
2112 outargflags |= FUSE_EXPORT_SUPPORT;
2114 outargflags |= FUSE_DONT_MASK;
2116 outargflags |= FUSE_FLOCK_LOCKS;
2118 outargflags |= FUSE_AUTO_INVAL_DATA;
2120 outargflags |= FUSE_DO_READDIRPLUS;
2122 outargflags |= FUSE_READDIRPLUS_AUTO;
2124 outargflags |= FUSE_ASYNC_DIO;
2126 outargflags |= FUSE_WRITEBACK_CACHE;
2128 outargflags |= FUSE_POSIX_ACL;
2130 outargflags |= FUSE_CACHE_SYMLINKS;
2132 outargflags |= FUSE_EXPLICIT_INVAL_DATA;
2134 if (inargflags & FUSE_INIT_EXT) {
2135 outargflags |= FUSE_INIT_EXT;
2136 outarg.flags2 = outargflags >> 32;
2139 outarg.flags = outargflags;
2141 outarg.max_readahead = se->conn.max_readahead;
2142 outarg.max_write = se->conn.max_write;
2143 if (se->conn.proto_minor >= 13) {
2144 if (se->conn.max_background >= (1 << 16))
2145 se->conn.max_background = (1 << 16) - 1;
2146 if (se->conn.congestion_threshold > se->conn.max_background)
2147 se->conn.congestion_threshold = se->conn.max_background;
2148 if (!se->conn.congestion_threshold) {
2149 se->conn.congestion_threshold =
2150 se->conn.max_background * 3 / 4;
2153 outarg.max_background = se->conn.max_background;
2154 outarg.congestion_threshold = se->conn.congestion_threshold;
2156 if (se->conn.proto_minor >= 23)
2157 outarg.time_gran = se->conn.time_gran;
2160 fuse_log(FUSE_LOG_DEBUG,
" INIT: %u.%u\n", outarg.major, outarg.minor);
2161 fuse_log(FUSE_LOG_DEBUG,
" flags=0x%08x\n", outarg.flags);
2162 fuse_log(FUSE_LOG_DEBUG,
" max_readahead=0x%08x\n",
2163 outarg.max_readahead);
2164 fuse_log(FUSE_LOG_DEBUG,
" max_write=0x%08x\n", outarg.max_write);
2165 fuse_log(FUSE_LOG_DEBUG,
" max_background=%i\n",
2166 outarg.max_background);
2167 fuse_log(FUSE_LOG_DEBUG,
" congestion_threshold=%i\n",
2168 outarg.congestion_threshold);
2169 fuse_log(FUSE_LOG_DEBUG,
" time_gran=%u\n",
2173 outargsize = FUSE_COMPAT_INIT_OUT_SIZE;
2174 else if (arg->minor < 23)
2175 outargsize = FUSE_COMPAT_22_INIT_OUT_SIZE;
2177 send_reply_ok(req, &outarg, outargsize);
2182 struct fuse_session *se = req->se;
2187 se->got_destroy = 1;
2189 se->op.destroy(se->userdata);
2191 send_reply_ok(req, NULL, 0);
2194 static void list_del_nreq(
struct fuse_notify_req *nreq)
2196 struct fuse_notify_req *prev = nreq->prev;
2197 struct fuse_notify_req *next = nreq->next;
2202 static void list_add_nreq(
struct fuse_notify_req *nreq,
2203 struct fuse_notify_req *next)
2205 struct fuse_notify_req *prev = next->prev;
2212 static void list_init_nreq(
struct fuse_notify_req *nreq)
2219 const void *inarg,
const struct fuse_buf *buf)
2221 struct fuse_session *se = req->se;
2222 struct fuse_notify_req *nreq;
2223 struct fuse_notify_req *head;
2225 pthread_mutex_lock(&se->lock);
2226 head = &se->notify_list;
2227 for (nreq = head->next; nreq != head; nreq = nreq->next) {
2228 if (nreq->unique == req->unique) {
2229 list_del_nreq(nreq);
2233 pthread_mutex_unlock(&se->lock);
2236 nreq->reply(nreq, req, nodeid, inarg, buf);
2239 static int send_notify_iov(
struct fuse_session *se,
int notify_code,
2240 struct iovec *iov,
int count)
2242 struct fuse_out_header out;
2248 out.error = notify_code;
2249 iov[0].iov_base = &out;
2250 iov[0].iov_len =
sizeof(
struct fuse_out_header);
2252 return fuse_send_msg(se, NULL, iov, count);
2258 struct fuse_notify_poll_wakeup_out outarg;
2259 struct iovec iov[2];
2263 iov[1].iov_base = &outarg;
2264 iov[1].iov_len =
sizeof(outarg);
2266 return send_notify_iov(ph->se, FUSE_NOTIFY_POLL, iov, 2);
2273 off_t off, off_t len)
2275 struct fuse_notify_inval_inode_out outarg;
2276 struct iovec iov[2];
2281 if (se->conn.proto_minor < 12)
2288 iov[1].iov_base = &outarg;
2289 iov[1].iov_len =
sizeof(outarg);
2291 return send_notify_iov(se, FUSE_NOTIFY_INVAL_INODE, iov, 2);
2295 const char *name,
size_t namelen,
2298 struct fuse_notify_inval_entry_out outarg;
2299 struct iovec iov[3];
2304 if (se->conn.proto_minor < 12)
2307 outarg.parent = parent;
2308 outarg.namelen = namelen;
2310 if (flags & FUSE_LL_EXPIRE_ONLY)
2311 outarg.flags |= FUSE_EXPIRE_ONLY;
2313 iov[1].iov_base = &outarg;
2314 iov[1].iov_len =
sizeof(outarg);
2315 iov[2].iov_base = (
void *)name;
2316 iov[2].iov_len = namelen + 1;
2318 return send_notify_iov(se, FUSE_NOTIFY_INVAL_ENTRY, iov, 3);
2322 const char *name,
size_t namelen)
2330 const char *name,
size_t namelen)
2332 struct fuse_notify_delete_out outarg;
2333 struct iovec iov[3];
2338 if (se->conn.proto_minor < 18)
2341 outarg.parent = parent;
2342 outarg.child = child;
2343 outarg.namelen = namelen;
2346 iov[1].iov_base = &outarg;
2347 iov[1].iov_len =
sizeof(outarg);
2348 iov[2].iov_base = (
void *)name;
2349 iov[2].iov_len = namelen + 1;
2351 return send_notify_iov(se, FUSE_NOTIFY_DELETE, iov, 3);
2358 struct fuse_out_header out;
2359 struct fuse_notify_store_out outarg;
2360 struct iovec iov[3];
2367 if (se->conn.proto_minor < 15)
2371 out.error = FUSE_NOTIFY_STORE;
2373 outarg.nodeid = ino;
2374 outarg.offset = offset;
2378 iov[0].iov_base = &out;
2379 iov[0].iov_len =
sizeof(out);
2380 iov[1].iov_base = &outarg;
2381 iov[1].iov_len =
sizeof(outarg);
2383 res = fuse_send_data_iov(se, NULL, iov, 2, bufv, flags);
2390 struct fuse_retrieve_req {
2391 struct fuse_notify_req nreq;
2395 static void fuse_ll_retrieve_reply(
struct fuse_notify_req *nreq,
2400 struct fuse_session *se = req->se;
2401 struct fuse_retrieve_req *rreq =
2402 container_of(nreq,
struct fuse_retrieve_req, nreq);
2403 const struct fuse_notify_retrieve_in *arg = inarg;
2410 bufv.
buf[0].
mem = PARAM(arg);
2412 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
2413 sizeof(struct fuse_notify_retrieve_in);
2415 if (bufv.
buf[0].
size < arg->size) {
2416 fuse_log(FUSE_LOG_ERR,
"fuse: retrieve reply: buffer size too small\n");
2422 if (se->op.retrieve_reply) {
2423 se->op.retrieve_reply(req, rreq->cookie, ino,
2424 arg->offset, &bufv);
2431 fuse_ll_clear_pipe(se);
2435 size_t size, off_t offset,
void *cookie)
2437 struct fuse_notify_retrieve_out outarg;
2438 struct iovec iov[2];
2439 struct fuse_retrieve_req *rreq;
2445 if (se->conn.proto_minor < 15)
2448 rreq = malloc(
sizeof(*rreq));
2452 pthread_mutex_lock(&se->lock);
2453 rreq->cookie = cookie;
2454 rreq->nreq.unique = se->notify_ctr++;
2455 rreq->nreq.reply = fuse_ll_retrieve_reply;
2456 list_add_nreq(&rreq->nreq, &se->notify_list);
2457 pthread_mutex_unlock(&se->lock);
2459 outarg.notify_unique = rreq->nreq.unique;
2460 outarg.nodeid = ino;
2461 outarg.offset = offset;
2465 iov[1].iov_base = &outarg;
2466 iov[1].iov_len =
sizeof(outarg);
2468 err = send_notify_iov(se, FUSE_NOTIFY_RETRIEVE, iov, 2);
2470 pthread_mutex_lock(&se->lock);
2471 list_del_nreq(&rreq->nreq);
2472 pthread_mutex_unlock(&se->lock);
2481 return req->se->userdata;
2492 pthread_mutex_lock(&req->lock);
2493 pthread_mutex_lock(&req->se->lock);
2494 req->u.ni.func = func;
2495 req->u.ni.data = data;
2496 pthread_mutex_unlock(&req->se->lock);
2497 if (req->interrupted && func)
2499 pthread_mutex_unlock(&req->lock);
2506 pthread_mutex_lock(&req->se->lock);
2507 interrupted = req->interrupted;
2508 pthread_mutex_unlock(&req->se->lock);
2517 [FUSE_LOOKUP] = { do_lookup,
"LOOKUP" },
2518 [FUSE_FORGET] = { do_forget,
"FORGET" },
2519 [FUSE_GETATTR] = { do_getattr,
"GETATTR" },
2520 [FUSE_SETATTR] = { do_setattr,
"SETATTR" },
2521 [FUSE_READLINK] = { do_readlink,
"READLINK" },
2522 [FUSE_SYMLINK] = { do_symlink,
"SYMLINK" },
2523 [FUSE_MKNOD] = { do_mknod,
"MKNOD" },
2524 [FUSE_MKDIR] = { do_mkdir,
"MKDIR" },
2525 [FUSE_UNLINK] = { do_unlink,
"UNLINK" },
2526 [FUSE_RMDIR] = { do_rmdir,
"RMDIR" },
2527 [FUSE_RENAME] = { do_rename,
"RENAME" },
2528 [FUSE_LINK] = { do_link,
"LINK" },
2529 [FUSE_OPEN] = { do_open,
"OPEN" },
2530 [FUSE_READ] = { do_read,
"READ" },
2531 [FUSE_WRITE] = { do_write,
"WRITE" },
2532 [FUSE_STATFS] = { do_statfs,
"STATFS" },
2533 [FUSE_RELEASE] = { do_release,
"RELEASE" },
2534 [FUSE_FSYNC] = { do_fsync,
"FSYNC" },
2535 [FUSE_SETXATTR] = { do_setxattr,
"SETXATTR" },
2536 [FUSE_GETXATTR] = { do_getxattr,
"GETXATTR" },
2537 [FUSE_LISTXATTR] = { do_listxattr,
"LISTXATTR" },
2538 [FUSE_REMOVEXATTR] = { do_removexattr,
"REMOVEXATTR" },
2539 [FUSE_FLUSH] = { do_flush,
"FLUSH" },
2540 [FUSE_INIT] = { do_init,
"INIT" },
2541 [FUSE_OPENDIR] = { do_opendir,
"OPENDIR" },
2542 [FUSE_READDIR] = { do_readdir,
"READDIR" },
2543 [FUSE_RELEASEDIR] = { do_releasedir,
"RELEASEDIR" },
2544 [FUSE_FSYNCDIR] = { do_fsyncdir,
"FSYNCDIR" },
2545 [FUSE_GETLK] = { do_getlk,
"GETLK" },
2546 [FUSE_SETLK] = { do_setlk,
"SETLK" },
2547 [FUSE_SETLKW] = { do_setlkw,
"SETLKW" },
2548 [FUSE_ACCESS] = { do_access,
"ACCESS" },
2549 [FUSE_CREATE] = { do_create,
"CREATE" },
2550 [FUSE_INTERRUPT] = { do_interrupt,
"INTERRUPT" },
2551 [FUSE_BMAP] = { do_bmap,
"BMAP" },
2552 [FUSE_IOCTL] = { do_ioctl,
"IOCTL" },
2553 [FUSE_POLL] = { do_poll,
"POLL" },
2554 [FUSE_FALLOCATE] = { do_fallocate,
"FALLOCATE" },
2555 [FUSE_DESTROY] = { do_destroy,
"DESTROY" },
2556 [FUSE_NOTIFY_REPLY] = { (
void *) 1,
"NOTIFY_REPLY" },
2557 [FUSE_BATCH_FORGET] = { do_batch_forget,
"BATCH_FORGET" },
2558 [FUSE_READDIRPLUS] = { do_readdirplus,
"READDIRPLUS"},
2559 [FUSE_RENAME2] = { do_rename2,
"RENAME2" },
2560 [FUSE_COPY_FILE_RANGE] = { do_copy_file_range,
"COPY_FILE_RANGE" },
2561 [FUSE_LSEEK] = { do_lseek,
"LSEEK" },
2562 [CUSE_INIT] = { cuse_lowlevel_init,
"CUSE_INIT" },
2565 #define FUSE_MAXOP (sizeof(fuse_ll_ops) / sizeof(fuse_ll_ops[0]))
2567 static const char *opname(
enum fuse_opcode opcode)
2569 if (opcode >= FUSE_MAXOP || !fuse_ll_ops[opcode].name)
2572 return fuse_ll_ops[opcode].name;
2575 static int fuse_ll_copy_from_pipe(
struct fuse_bufvec *dst,
2580 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n", strerror(-res));
2584 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: short read\n");
2593 fuse_session_process_buf_int(se, buf, NULL);
2596 void fuse_session_process_buf_int(
struct fuse_session *se,
2597 const struct fuse_buf *buf,
struct fuse_chan *ch)
2599 const size_t write_header_size =
sizeof(
struct fuse_in_header) +
2600 sizeof(struct fuse_write_in);
2602 struct fuse_bufvec tmpbuf = FUSE_BUFVEC_INIT(write_header_size);
2603 struct fuse_in_header *in;
2605 struct fuse_req *req;
2614 mbuf = malloc(tmpbuf.
buf[0].
size);
2616 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate header\n");
2619 tmpbuf.
buf[0].
mem = mbuf;
2621 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
2632 "unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n",
2633 (
unsigned long long) in->unique,
2634 opname((
enum fuse_opcode) in->opcode), in->opcode,
2635 (
unsigned long long) in->nodeid, buf->
size, in->pid);
2638 req = fuse_ll_alloc_req(se);
2640 struct fuse_out_header out = {
2641 .unique = in->unique,
2644 struct iovec iov = {
2646 .iov_len =
sizeof(
struct fuse_out_header),
2649 fuse_send_msg(se, ch, &iov, 1);
2653 req->unique = in->unique;
2654 req->ctx.uid = in->uid;
2655 req->ctx.gid = in->gid;
2656 req->ctx.pid = in->pid;
2657 req->ch = ch ? fuse_chan_get(ch) : NULL;
2660 if (!se->got_init) {
2661 enum fuse_opcode expected;
2663 expected = se->cuse_data ? CUSE_INIT : FUSE_INIT;
2664 if (in->opcode != expected)
2666 }
else if (in->opcode == FUSE_INIT || in->opcode == CUSE_INIT)
2671 if (se->deny_others && in->uid != se->owner && in->uid != 0 &&
2672 in->opcode != FUSE_INIT && in->opcode != FUSE_READ &&
2673 in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC &&
2674 in->opcode != FUSE_RELEASE && in->opcode != FUSE_READDIR &&
2675 in->opcode != FUSE_FSYNCDIR && in->opcode != FUSE_RELEASEDIR &&
2676 in->opcode != FUSE_NOTIFY_REPLY &&
2677 in->opcode != FUSE_READDIRPLUS)
2681 if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func)
2683 if (in->opcode != FUSE_INTERRUPT) {
2684 struct fuse_req *intr;
2685 pthread_mutex_lock(&se->lock);
2686 intr = check_interrupt(se, req);
2687 list_add_req(req, &se->list);
2688 pthread_mutex_unlock(&se->lock);
2694 (in->opcode != FUSE_WRITE || !se->op.write_buf) &&
2695 in->opcode != FUSE_NOTIFY_REPLY) {
2699 newmbuf = realloc(mbuf, buf->
size);
2700 if (newmbuf == NULL)
2704 tmpbuf = FUSE_BUFVEC_INIT(buf->
size - write_header_size);
2705 tmpbuf.
buf[0].
mem = (
char *)mbuf + write_header_size;
2707 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
2715 inarg = (
void *) &in[1];
2716 if (in->opcode == FUSE_WRITE && se->op.write_buf)
2717 do_write_buf(req, in->nodeid, inarg, buf);
2718 else if (in->opcode == FUSE_NOTIFY_REPLY)
2719 do_notify_reply(req, in->nodeid, inarg, buf);
2721 fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
2731 fuse_ll_clear_pipe(se);
2735 #define LL_OPTION(n,o,v) \
2736 { n, offsetof(struct fuse_session, o), v }
2738 static const struct fuse_opt fuse_ll_opts[] = {
2739 LL_OPTION(
"debug", debug, 1),
2740 LL_OPTION(
"-d", debug, 1),
2741 LL_OPTION(
"--debug", debug, 1),
2742 LL_OPTION(
"allow_root", deny_others, 1),
2748 printf(
"using FUSE kernel interface version %i.%i\n",
2749 FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
2750 fuse_mount_version();
2758 " -o allow_other allow access by all users\n"
2759 " -o allow_root allow access by root\n"
2760 " -o auto_unmount auto unmount on process termination\n");
2765 struct fuse_ll_pipe *llp;
2767 if (se->got_init && !se->got_destroy) {
2769 se->op.destroy(se->userdata);
2771 llp = pthread_getspecific(se->pipe_key);
2773 fuse_ll_pipe_free(llp);
2774 pthread_key_delete(se->pipe_key);
2775 pthread_mutex_destroy(&se->lock);
2776 free(se->cuse_data);
2781 destroy_mount_opts(se->mo);
2786 static void fuse_ll_pipe_destructor(
void *data)
2788 struct fuse_ll_pipe *llp = data;
2789 fuse_ll_pipe_free(llp);
2794 return fuse_session_receive_buf_int(se, buf, NULL);
2797 int fuse_session_receive_buf_int(
struct fuse_session *se,
struct fuse_buf *buf,
2798 struct fuse_chan *ch)
2803 size_t bufsize = se->bufsize;
2804 struct fuse_ll_pipe *llp;
2810 llp = fuse_ll_get_pipe(se);
2814 if (llp->size < bufsize) {
2815 if (llp->can_grow) {
2816 res = fcntl(llp->pipe[0], F_SETPIPE_SZ, bufsize);
2819 res = grow_pipe_to_max(llp->pipe[0]);
2826 if (llp->size < bufsize)
2830 if (se->io != NULL && se->io->splice_receive != NULL) {
2831 res = se->io->splice_receive(ch ? ch->fd : se->fd, NULL,
2832 llp->pipe[1], NULL, bufsize, 0,
2835 res = splice(ch ? ch->fd : se->fd, NULL, llp->pipe[1], NULL,
2844 if (err == ENODEV) {
2850 if (err != EINTR && err != EAGAIN)
2851 perror(
"fuse: splice from device");
2855 if (res <
sizeof(
struct fuse_in_header)) {
2856 fuse_log(FUSE_LOG_ERR,
"short splice from fuse device\n");
2871 if (res <
sizeof(
struct fuse_in_header) +
2872 sizeof(
struct fuse_write_in) + pagesize) {
2877 buf->
mem = malloc(se->bufsize);
2880 "fuse: failed to allocate read buffer\n");
2890 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n",
2892 fuse_ll_clear_pipe(se);
2895 if (res < tmpbuf.size) {
2896 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: short read\n");
2897 fuse_ll_clear_pipe(se);
2900 assert(res == tmpbuf.size);
2904 buf->
fd = tmpbuf.fd;
2914 buf->
mem = malloc(se->bufsize);
2917 "fuse: failed to allocate read buffer\n");
2923 if (se->io != NULL) {
2926 res = se->io->read(ch ? ch->fd : se->fd,
buf->
mem, se->bufsize,
2929 res = read(ch ? ch->fd : se->fd,
buf->
mem, se->bufsize);
2941 if (err == ENODEV) {
2950 if (err != EINTR && err != EAGAIN)
2951 perror(
"fuse: reading device");
2954 if ((
size_t) res <
sizeof(
struct fuse_in_header)) {
2955 fuse_log(FUSE_LOG_ERR,
"short read on fuse device\n");
2966 size_t op_size,
void *userdata)
2969 struct fuse_session *se;
2970 struct mount_opts *mo;
2973 fuse_log(FUSE_LOG_ERR,
"fuse: warning: library too old, some operations may not work\n");
2977 if (args->
argc == 0) {
2978 fuse_log(FUSE_LOG_ERR,
"fuse: empty argv passed to fuse_session_new().\n");
2982 se = (
struct fuse_session *) calloc(1,
sizeof(
struct fuse_session));
2984 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate fuse object\n");
2988 se->conn.max_write = UINT_MAX;
2989 se->conn.max_readahead = UINT_MAX;
2994 if(se->deny_others) {
3004 mo = parse_mount_opts(args);
3008 if(args->
argc == 1 &&
3009 args->
argv[0][0] ==
'-') {
3010 fuse_log(FUSE_LOG_ERR,
"fuse: warning: argv[0] looks like an option, but "
3011 "will be ignored\n");
3012 }
else if (args->
argc != 1) {
3014 fuse_log(FUSE_LOG_ERR,
"fuse: unknown option(s): `");
3015 for(i = 1; i < args->
argc-1; i++)
3022 fuse_log(FUSE_LOG_DEBUG,
"FUSE library version: %s\n", PACKAGE_VERSION);
3024 se->bufsize = FUSE_MAX_MAX_PAGES * getpagesize() +
3025 FUSE_BUFFER_HEADER_SIZE;
3027 list_init_req(&se->list);
3028 list_init_req(&se->interrupts);
3029 list_init_nreq(&se->notify_list);
3031 pthread_mutex_init(&se->lock, NULL);
3033 err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor);
3035 fuse_log(FUSE_LOG_ERR,
"fuse: failed to create thread specific key: %s\n",
3040 memcpy(&se->op, op, op_size);
3041 se->owner = getuid();
3042 se->userdata = userdata;
3048 pthread_mutex_destroy(&se->lock);
3053 destroy_mount_opts(mo);
3064 fuse_log(FUSE_LOG_ERR,
"Invalid file descriptor value %d passed to "
3065 "fuse_session_custom_io()\n", fd);
3069 fuse_log(FUSE_LOG_ERR,
"No custom IO passed to "
3070 "fuse_session_custom_io()\n");
3072 }
else if (io->read == NULL || io->writev == NULL) {
3077 fuse_log(FUSE_LOG_ERR,
"io passed to fuse_session_custom_io() must "
3078 "implement both io->read() and io->writev\n");
3082 se->io = malloc(
sizeof(
struct fuse_custom_io));
3083 if (se->io == NULL) {
3084 fuse_log(FUSE_LOG_ERR,
"Failed to allocate memory for custom io. "
3085 "Error: %s\n", strerror(errno));
3103 fd = open(
"/dev/null", O_RDWR);
3106 }
while (fd >= 0 && fd <= 2);
3114 fd = fuse_mnt_parse_fuse_fd(mountpoint);
3116 if (fcntl(fd, F_GETFD) == -1) {
3118 "fuse: Invalid file descriptor /dev/fd/%u\n",
3127 fd = fuse_kern_mount(mountpoint, se->mo);
3133 se->mountpoint = strdup(mountpoint);
3134 if (se->mountpoint == NULL)
3140 fuse_kern_unmount(mountpoint, fd);
3151 if (se->mountpoint != NULL) {
3152 fuse_kern_unmount(se->mountpoint, se->fd);
3154 free(se->mountpoint);
3155 se->mountpoint = NULL;
3163 size_t bufsize = 1024;
3167 unsigned long pid = req->ctx.pid;
3170 sprintf(path,
"/proc/%lu/task/%lu/status", pid, pid);
3173 buf = malloc(bufsize);
3178 fd = open(path, O_RDONLY);
3182 ret = read(fd, buf, bufsize);
3189 if ((
size_t)ret == bufsize) {
3196 s = strstr(buf,
"\nGroups:");
3204 unsigned long val = strtoul(s, &end, 0);
3224 (void) req; (void) size; (void) list;
3231 __attribute__((no_sanitize_thread))
3237 __attribute__((no_sanitize_thread))
3244 __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_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)
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)
void fuse_reply_none(fuse_req_t req)
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)
struct fuse_session * fuse_session_new(struct fuse_args *args, const struct fuse_lowlevel_ops *op, size_t op_size, void *userdata)
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)
void * fuse_req_userdata(fuse_req_t req)
int fuse_lowlevel_notify_expire_entry(struct fuse_session *se, fuse_ino_t parent, const char *name, size_t namelen, enum fuse_expire_flags flags)
int fuse_lowlevel_notify_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)
const struct fuse_ctx * fuse_req_ctx(fuse_req_t req)
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