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;
412 struct fuse_entry_out arg;
413 size_t size = req->se->conn.proto_minor < 9 ?
414 FUSE_COMPAT_ENTRY_OUT_SIZE :
sizeof(arg);
418 if (!e->
ino && req->se->conn.proto_minor < 4)
421 memset(&arg, 0,
sizeof(arg));
423 return send_reply_ok(req, &arg, size);
429 char buf[
sizeof(
struct fuse_entry_out) + sizeof(struct fuse_open_out)];
430 size_t entrysize = req->se->conn.proto_minor < 9 ?
431 FUSE_COMPAT_ENTRY_OUT_SIZE :
sizeof(
struct fuse_entry_out);
432 struct fuse_entry_out *earg = (
struct fuse_entry_out *) buf;
433 struct fuse_open_out *oarg = (
struct fuse_open_out *) (buf + entrysize);
435 memset(buf, 0,
sizeof(buf));
438 return send_reply_ok(req, buf,
439 entrysize +
sizeof(
struct fuse_open_out));
445 struct fuse_attr_out arg;
446 size_t size = req->se->conn.proto_minor < 9 ?
447 FUSE_COMPAT_ATTR_OUT_SIZE :
sizeof(arg);
449 memset(&arg, 0,
sizeof(arg));
450 arg.attr_valid = calc_timeout_sec(attr_timeout);
451 arg.attr_valid_nsec = calc_timeout_nsec(attr_timeout);
452 convert_stat(attr, &arg.attr);
454 return send_reply_ok(req, &arg, size);
459 return send_reply_ok(req, linkname, strlen(linkname));
464 struct fuse_open_out arg;
466 memset(&arg, 0,
sizeof(arg));
468 return send_reply_ok(req, &arg,
sizeof(arg));
473 struct fuse_write_out arg;
475 memset(&arg, 0,
sizeof(arg));
478 return send_reply_ok(req, &arg,
sizeof(arg));
483 return send_reply_ok(req, buf, size);
486 static int fuse_send_data_iov_fallback(
struct fuse_session *se,
487 struct fuse_chan *ch,
488 struct iovec *iov,
int iov_count,
492 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
497 if (
buf->count == 1 &&
buf->idx == 0 &&
buf->off == 0 &&
502 iov[iov_count].iov_base =
buf->buf[0].
mem;
503 iov[iov_count].iov_len = len;
505 return fuse_send_msg(se, ch, iov, iov_count);
508 res = posix_memalign(&mbuf, pagesize, len);
512 mem_buf.
buf[0].
mem = mbuf;
520 iov[iov_count].iov_base = mbuf;
521 iov[iov_count].iov_len = len;
523 res = fuse_send_msg(se, ch, iov, iov_count);
529 struct fuse_ll_pipe {
535 static void fuse_ll_pipe_free(
struct fuse_ll_pipe *llp)
543 #if !defined(HAVE_PIPE2) || !defined(O_CLOEXEC)
544 static int fuse_pipe(
int fds[2])
551 if (fcntl(fds[0], F_SETFL, O_NONBLOCK) == -1 ||
552 fcntl(fds[1], F_SETFL, O_NONBLOCK) == -1 ||
553 fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
554 fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
562 static int fuse_pipe(
int fds[2])
564 return pipe2(fds, O_CLOEXEC | O_NONBLOCK);
568 static struct fuse_ll_pipe *fuse_ll_get_pipe(
struct fuse_session *se)
570 struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
574 llp = malloc(
sizeof(
struct fuse_ll_pipe));
578 res = fuse_pipe(llp->pipe);
587 llp->size = pagesize * 16;
590 pthread_setspecific(se->pipe_key, llp);
597 static void fuse_ll_clear_pipe(
struct fuse_session *se)
599 struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
601 pthread_setspecific(se->pipe_key, NULL);
602 fuse_ll_pipe_free(llp);
606 #if defined(HAVE_SPLICE) && defined(HAVE_VMSPLICE)
607 static int read_back(
int fd,
char *buf,
size_t len)
611 res = read(fd, buf, len);
613 fuse_log(FUSE_LOG_ERR,
"fuse: internal error: failed to read back from pipe: %s\n", strerror(errno));
617 fuse_log(FUSE_LOG_ERR,
"fuse: internal error: short read back from pipe: %i from %zi\n", res, len);
623 static int grow_pipe_to_max(
int pipefd)
630 maxfd = open(
"/proc/sys/fs/pipe-max-size", O_RDONLY);
634 res = read(maxfd, buf,
sizeof(buf) - 1);
646 res = fcntl(pipefd, F_SETPIPE_SZ, max);
652 static int fuse_send_data_iov(
struct fuse_session *se,
struct fuse_chan *ch,
653 struct iovec *iov,
int iov_count,
658 struct fuse_out_header *out = iov[0].iov_base;
659 struct fuse_ll_pipe *llp;
662 size_t total_buf_size;
665 struct fuse_bufvec pipe_buf = FUSE_BUFVEC_INIT(len);
667 if (se->broken_splice_nonblock)
677 total_buf_size -=
buf->off;
679 if (total_buf_size < 2 * pagesize)
682 if (se->conn.proto_minor < 14 ||
686 llp = fuse_ll_get_pipe(se);
691 headerlen = iov_length(iov, iov_count);
693 out->len = headerlen + len;
699 pipesize = pagesize * (iov_count +
buf->count + 1) + out->len;
701 if (llp->size < pipesize) {
703 res = fcntl(llp->pipe[0], F_SETPIPE_SZ, pipesize);
705 res = grow_pipe_to_max(llp->pipe[0]);
713 if (llp->size < pipesize)
718 res = vmsplice(llp->pipe[1], iov, iov_count, SPLICE_F_NONBLOCK);
722 if (res != headerlen) {
724 fuse_log(FUSE_LOG_ERR,
"fuse: short vmsplice to pipe: %u/%zu\n", res,
730 pipe_buf.
buf[0].
fd = llp->pipe[1];
735 if (res == -EAGAIN || res == -EINVAL) {
747 se->broken_splice_nonblock = 1;
749 pthread_setspecific(se->pipe_key, NULL);
750 fuse_ll_pipe_free(llp);
757 if (res != 0 && res < len) {
758 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
760 size_t now_len = res;
770 res = posix_memalign(&mbuf, pagesize, len);
774 mem_buf.
buf[0].
mem = mbuf;
775 mem_buf.
off = now_len;
779 size_t extra_len = res;
785 tmpbuf = malloc(headerlen);
786 if (tmpbuf == NULL) {
791 res = read_back(llp->pipe[0], tmpbuf, headerlen);
797 res = read_back(llp->pipe[0], mbuf, now_len);
802 len = now_len + extra_len;
803 iov[iov_count].iov_base = mbuf;
804 iov[iov_count].iov_len = len;
806 res = fuse_send_msg(se, ch, iov, iov_count);
814 out->len = headerlen + len;
818 " unique: %llu, success, outsize: %i (splice)\n",
819 (
unsigned long long) out->unique, out->len);
825 splice_flags |= SPLICE_F_MOVE;
827 if (se->io != NULL && se->io->splice_send != NULL) {
828 res = se->io->splice_send(llp->pipe[0], NULL,
829 ch ? ch->fd : se->fd, NULL, out->len,
830 splice_flags, se->userdata);
832 res = splice(llp->pipe[0], NULL, ch ? ch->fd : se->fd, NULL,
833 out->len, splice_flags);
837 perror(
"fuse: splice from pipe");
840 if (res != out->len) {
842 fuse_log(FUSE_LOG_ERR,
"fuse: short splice from pipe: %u/%u\n",
849 fuse_ll_clear_pipe(se);
853 return fuse_send_data_iov_fallback(se, ch, iov, iov_count,
buf, len);
856 static int fuse_send_data_iov(
struct fuse_session *se,
struct fuse_chan *ch,
857 struct iovec *iov,
int iov_count,
863 return fuse_send_data_iov_fallback(se, ch, iov, iov_count,
buf, len);
871 struct fuse_out_header out;
874 iov[0].iov_base = &out;
875 iov[0].iov_len =
sizeof(
struct fuse_out_header);
877 out.unique = req->unique;
880 res = fuse_send_data_iov(req->se, req->ch, iov, 1, bufv, flags);
891 struct fuse_statfs_out arg;
892 size_t size = req->se->conn.proto_minor < 4 ?
893 FUSE_COMPAT_STATFS_SIZE :
sizeof(arg);
895 memset(&arg, 0,
sizeof(arg));
896 convert_statfs(stbuf, &arg.st);
898 return send_reply_ok(req, &arg, size);
903 struct fuse_getxattr_out arg;
905 memset(&arg, 0,
sizeof(arg));
908 return send_reply_ok(req, &arg,
sizeof(arg));
913 struct fuse_lk_out arg;
915 memset(&arg, 0,
sizeof(arg));
916 arg.lk.type = lock->l_type;
917 if (lock->l_type != F_UNLCK) {
918 arg.lk.start = lock->l_start;
919 if (lock->l_len == 0)
920 arg.lk.end = OFFSET_MAX;
922 arg.lk.end = lock->l_start + lock->l_len - 1;
924 arg.lk.pid = lock->l_pid;
925 return send_reply_ok(req, &arg,
sizeof(arg));
930 struct fuse_bmap_out arg;
932 memset(&arg, 0,
sizeof(arg));
935 return send_reply_ok(req, &arg,
sizeof(arg));
938 static struct fuse_ioctl_iovec *fuse_ioctl_iovec_copy(
const struct iovec *iov,
941 struct fuse_ioctl_iovec *fiov;
944 fiov = malloc(
sizeof(fiov[0]) * count);
948 for (i = 0; i < count; i++) {
949 fiov[i].base = (uintptr_t) iov[i].iov_base;
950 fiov[i].len = iov[i].iov_len;
957 const struct iovec *in_iov,
size_t in_count,
958 const struct iovec *out_iov,
size_t out_count)
960 struct fuse_ioctl_out arg;
961 struct fuse_ioctl_iovec *in_fiov = NULL;
962 struct fuse_ioctl_iovec *out_fiov = NULL;
967 memset(&arg, 0,
sizeof(arg));
968 arg.flags |= FUSE_IOCTL_RETRY;
969 arg.in_iovs = in_count;
970 arg.out_iovs = out_count;
971 iov[count].iov_base = &arg;
972 iov[count].iov_len =
sizeof(arg);
975 if (req->se->conn.proto_minor < 16) {
977 iov[count].iov_base = (
void *)in_iov;
978 iov[count].iov_len =
sizeof(in_iov[0]) * in_count;
983 iov[count].iov_base = (
void *)out_iov;
984 iov[count].iov_len =
sizeof(out_iov[0]) * out_count;
989 if (
sizeof(
void *) == 4 && req->ioctl_64bit) {
995 in_fiov = fuse_ioctl_iovec_copy(in_iov, in_count);
999 iov[count].iov_base = (
void *)in_fiov;
1000 iov[count].iov_len =
sizeof(in_fiov[0]) * in_count;
1004 out_fiov = fuse_ioctl_iovec_copy(out_iov, out_count);
1008 iov[count].iov_base = (
void *)out_fiov;
1009 iov[count].iov_len =
sizeof(out_fiov[0]) * out_count;
1014 res = send_reply_iov(req, 0, iov, count);
1028 struct fuse_ioctl_out arg;
1029 struct iovec iov[3];
1032 memset(&arg, 0,
sizeof(arg));
1033 arg.result = result;
1034 iov[count].iov_base = &arg;
1035 iov[count].iov_len =
sizeof(arg);
1039 iov[count].iov_base = (
char *) buf;
1040 iov[count].iov_len = size;
1044 return send_reply_iov(req, 0, iov, count);
1050 struct iovec *padded_iov;
1051 struct fuse_ioctl_out arg;
1054 padded_iov = malloc((count + 2) *
sizeof(
struct iovec));
1055 if (padded_iov == NULL)
1058 memset(&arg, 0,
sizeof(arg));
1059 arg.result = result;
1060 padded_iov[1].iov_base = &arg;
1061 padded_iov[1].iov_len =
sizeof(arg);
1063 memcpy(&padded_iov[2], iov, count *
sizeof(
struct iovec));
1065 res = send_reply_iov(req, 0, padded_iov, count + 2);
1073 struct fuse_poll_out arg;
1075 memset(&arg, 0,
sizeof(arg));
1076 arg.revents = revents;
1078 return send_reply_ok(req, &arg,
sizeof(arg));
1083 struct fuse_lseek_out arg;
1085 memset(&arg, 0,
sizeof(arg));
1088 return send_reply_ok(req, &arg,
sizeof(arg));
1093 char *name = (
char *) inarg;
1095 if (req->se->op.lookup)
1096 req->se->op.lookup(req, nodeid, name);
1103 struct fuse_forget_in *arg = (
struct fuse_forget_in *) inarg;
1105 if (req->se->op.forget)
1106 req->se->op.forget(req, nodeid, arg->nlookup);
1114 struct fuse_batch_forget_in *arg = (
void *) inarg;
1115 struct fuse_forget_one *param = (
void *) PARAM(arg);
1120 if (req->se->op.forget_multi) {
1121 req->se->op.forget_multi(req, arg->count,
1122 (
struct fuse_forget_data *) param);
1123 }
else if (req->se->op.forget) {
1124 for (i = 0; i < arg->count; i++) {
1125 struct fuse_forget_one *forget = ¶m[i];
1126 struct fuse_req *dummy_req;
1128 dummy_req = fuse_ll_alloc_req(req->se);
1129 if (dummy_req == NULL)
1132 dummy_req->unique = req->unique;
1133 dummy_req->ctx = req->ctx;
1134 dummy_req->ch = NULL;
1136 req->se->op.forget(dummy_req, forget->nodeid,
1150 if (req->se->conn.proto_minor >= 9) {
1151 struct fuse_getattr_in *arg = (
struct fuse_getattr_in *) inarg;
1153 if (arg->getattr_flags & FUSE_GETATTR_FH) {
1154 memset(&fi, 0,
sizeof(fi));
1160 if (req->se->op.getattr)
1161 req->se->op.getattr(req, nodeid, fip);
1168 struct fuse_setattr_in *arg = (
struct fuse_setattr_in *) inarg;
1170 if (req->se->op.setattr) {
1174 memset(&stbuf, 0,
sizeof(stbuf));
1175 convert_attr(arg, &stbuf);
1176 if (arg->valid & FATTR_FH) {
1177 arg->valid &= ~FATTR_FH;
1178 memset(&fi_store, 0,
sizeof(fi_store));
1183 FUSE_SET_ATTR_MODE |
1186 FUSE_SET_ATTR_SIZE |
1187 FUSE_SET_ATTR_ATIME |
1188 FUSE_SET_ATTR_MTIME |
1189 FUSE_SET_ATTR_ATIME_NOW |
1190 FUSE_SET_ATTR_MTIME_NOW |
1191 FUSE_SET_ATTR_CTIME;
1193 req->se->op.setattr(req, nodeid, &stbuf, arg->valid, fi);
1200 struct fuse_access_in *arg = (
struct fuse_access_in *) inarg;
1202 if (req->se->op.access)
1203 req->se->op.access(req, nodeid, arg->mask);
1212 if (req->se->op.readlink)
1213 req->se->op.readlink(req, nodeid);
1220 struct fuse_mknod_in *arg = (
struct fuse_mknod_in *) inarg;
1221 char *name = PARAM(arg);
1223 if (req->se->conn.proto_minor >= 12)
1224 req->ctx.umask = arg->umask;
1226 name = (
char *) inarg + FUSE_COMPAT_MKNOD_IN_SIZE;
1228 if (req->se->op.mknod)
1229 req->se->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
1236 struct fuse_mkdir_in *arg = (
struct fuse_mkdir_in *) inarg;
1238 if (req->se->conn.proto_minor >= 12)
1239 req->ctx.umask = arg->umask;
1241 if (req->se->op.mkdir)
1242 req->se->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
1249 char *name = (
char *) inarg;
1251 if (req->se->op.unlink)
1252 req->se->op.unlink(req, nodeid, name);
1259 char *name = (
char *) inarg;
1261 if (req->se->op.rmdir)
1262 req->se->op.rmdir(req, nodeid, name);
1269 char *name = (
char *) inarg;
1270 char *linkname = ((
char *) inarg) + strlen((
char *) inarg) + 1;
1272 if (req->se->op.symlink)
1273 req->se->op.symlink(req, linkname, nodeid, name);
1280 struct fuse_rename_in *arg = (
struct fuse_rename_in *) inarg;
1281 char *oldname = PARAM(arg);
1282 char *newname = oldname + strlen(oldname) + 1;
1284 if (req->se->op.rename)
1285 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1293 struct fuse_rename2_in *arg = (
struct fuse_rename2_in *) inarg;
1294 char *oldname = PARAM(arg);
1295 char *newname = oldname + strlen(oldname) + 1;
1297 if (req->se->op.rename)
1298 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1306 struct fuse_link_in *arg = (
struct fuse_link_in *) inarg;
1308 if (req->se->op.link)
1309 req->se->op.link(req, arg->oldnodeid, nodeid, PARAM(arg));
1316 struct fuse_create_in *arg = (
struct fuse_create_in *) inarg;
1318 if (req->se->op.create) {
1320 char *name = PARAM(arg);
1322 memset(&fi, 0,
sizeof(fi));
1323 fi.
flags = arg->flags;
1325 if (req->se->conn.proto_minor >= 12)
1326 req->ctx.umask = arg->umask;
1328 name = (
char *) inarg +
sizeof(
struct fuse_open_in);
1330 req->se->op.create(req, nodeid, name, arg->mode, &fi);
1337 struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
1340 memset(&fi, 0,
sizeof(fi));
1341 fi.
flags = arg->flags;
1343 if (req->se->op.open)
1344 req->se->op.open(req, nodeid, &fi);
1351 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1353 if (req->se->op.read) {
1356 memset(&fi, 0,
sizeof(fi));
1358 if (req->se->conn.proto_minor >= 9) {
1360 fi.
flags = arg->flags;
1362 req->se->op.read(req, nodeid, arg->size, arg->offset, &fi);
1369 struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
1373 memset(&fi, 0,
sizeof(fi));
1375 fi.
writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
1377 if (req->se->conn.proto_minor < 9) {
1378 param = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1381 fi.
flags = arg->flags;
1385 if (req->se->op.write)
1386 req->se->op.write(req, nodeid, param, arg->size,
1395 struct fuse_session *se = req->se;
1400 struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
1403 memset(&fi, 0,
sizeof(fi));
1405 fi.
writepage = arg->write_flags & FUSE_WRITE_CACHE;
1407 if (se->conn.proto_minor < 9) {
1408 bufv.
buf[0].
mem = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1409 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1410 FUSE_COMPAT_WRITE_IN_SIZE;
1414 fi.
flags = arg->flags;
1416 bufv.
buf[0].
mem = PARAM(arg);
1418 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1419 sizeof(struct fuse_write_in);
1421 if (bufv.
buf[0].
size < arg->size) {
1422 fuse_log(FUSE_LOG_ERR,
"fuse: do_write_buf: buffer size too small\n");
1428 se->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
1433 fuse_ll_clear_pipe(se);
1438 struct fuse_flush_in *arg = (
struct fuse_flush_in *) inarg;
1441 memset(&fi, 0,
sizeof(fi));
1444 if (req->se->conn.proto_minor >= 7)
1447 if (req->se->op.flush)
1448 req->se->op.flush(req, nodeid, &fi);
1455 struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
1458 memset(&fi, 0,
sizeof(fi));
1459 fi.
flags = arg->flags;
1461 if (req->se->conn.proto_minor >= 8) {
1462 fi.
flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
1465 if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) {
1466 fi.flock_release = 1;
1470 if (req->se->op.release)
1471 req->se->op.release(req, nodeid, &fi);
1478 struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
1480 int datasync = arg->fsync_flags & 1;
1482 memset(&fi, 0,
sizeof(fi));
1485 if (req->se->op.fsync)
1486 req->se->op.fsync(req, nodeid, datasync, &fi);
1493 struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
1496 memset(&fi, 0,
sizeof(fi));
1497 fi.
flags = arg->flags;
1499 if (req->se->op.opendir)
1500 req->se->op.opendir(req, nodeid, &fi);
1507 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1510 memset(&fi, 0,
sizeof(fi));
1513 if (req->se->op.readdir)
1514 req->se->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
1521 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1524 memset(&fi, 0,
sizeof(fi));
1527 if (req->se->op.readdirplus)
1528 req->se->op.readdirplus(req, nodeid, arg->size, arg->offset, &fi);
1535 struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
1538 memset(&fi, 0,
sizeof(fi));
1539 fi.
flags = arg->flags;
1542 if (req->se->op.releasedir)
1543 req->se->op.releasedir(req, nodeid, &fi);
1550 struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
1552 int datasync = arg->fsync_flags & 1;
1554 memset(&fi, 0,
sizeof(fi));
1557 if (req->se->op.fsyncdir)
1558 req->se->op.fsyncdir(req, nodeid, datasync, &fi);
1568 if (req->se->op.statfs)
1569 req->se->op.statfs(req, nodeid);
1571 struct statvfs buf = {
1581 struct fuse_setxattr_in *arg = (
struct fuse_setxattr_in *) inarg;
1582 char *name = PARAM(arg);
1583 char *value = name + strlen(name) + 1;
1585 if (req->se->op.setxattr)
1586 req->se->op.setxattr(req, nodeid, name, value, arg->size,
1594 struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
1596 if (req->se->op.getxattr)
1597 req->se->op.getxattr(req, nodeid, PARAM(arg), arg->size);
1604 struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
1606 if (req->se->op.listxattr)
1607 req->se->op.listxattr(req, nodeid, arg->size);
1614 char *name = (
char *) inarg;
1616 if (req->se->op.removexattr)
1617 req->se->op.removexattr(req, nodeid, name);
1622 static void convert_fuse_file_lock(
struct fuse_file_lock *fl,
1623 struct flock *flock)
1625 memset(flock, 0,
sizeof(
struct flock));
1626 flock->l_type = fl->type;
1627 flock->l_whence = SEEK_SET;
1628 flock->l_start = fl->start;
1629 if (fl->end == OFFSET_MAX)
1632 flock->l_len = fl->end - fl->start + 1;
1633 flock->l_pid = fl->pid;
1638 struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
1642 memset(&fi, 0,
sizeof(fi));
1646 convert_fuse_file_lock(&arg->lk, &flock);
1647 if (req->se->op.getlk)
1648 req->se->op.getlk(req, nodeid, &fi, &flock);
1654 const void *inarg,
int sleep)
1656 struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
1660 memset(&fi, 0,
sizeof(fi));
1664 if (arg->lk_flags & FUSE_LK_FLOCK) {
1667 switch (arg->lk.type) {
1681 if (req->se->op.flock)
1682 req->se->op.flock(req, nodeid, &fi, op);
1686 convert_fuse_file_lock(&arg->lk, &flock);
1687 if (req->se->op.setlk)
1688 req->se->op.setlk(req, nodeid, &fi, &flock, sleep);
1696 do_setlk_common(req, nodeid, inarg, 0);
1701 do_setlk_common(req, nodeid, inarg, 1);
1704 static int find_interrupted(
struct fuse_session *se,
struct fuse_req *req)
1706 struct fuse_req *curr;
1708 for (curr = se->list.next; curr != &se->list; curr = curr->next) {
1709 if (curr->unique == req->u.i.unique) {
1714 pthread_mutex_unlock(&se->lock);
1717 pthread_mutex_lock(&curr->lock);
1718 pthread_mutex_lock(&se->lock);
1719 curr->interrupted = 1;
1720 func = curr->u.ni.func;
1721 data = curr->u.ni.data;
1722 pthread_mutex_unlock(&se->lock);
1725 pthread_mutex_unlock(&curr->lock);
1727 pthread_mutex_lock(&se->lock);
1730 fuse_chan_put(req->ch);
1738 for (curr = se->interrupts.next; curr != &se->interrupts;
1739 curr = curr->next) {
1740 if (curr->u.i.unique == req->u.i.unique)
1748 struct fuse_interrupt_in *arg = (
struct fuse_interrupt_in *) inarg;
1749 struct fuse_session *se = req->se;
1753 fuse_log(FUSE_LOG_DEBUG,
"INTERRUPT: %llu\n",
1754 (
unsigned long long) arg->unique);
1756 req->u.i.unique = arg->unique;
1758 pthread_mutex_lock(&se->lock);
1759 if (find_interrupted(se, req)) {
1760 fuse_chan_put(req->ch);
1764 list_add_req(req, &se->interrupts);
1765 pthread_mutex_unlock(&se->lock);
1768 static struct fuse_req *check_interrupt(
struct fuse_session *se,
1769 struct fuse_req *req)
1771 struct fuse_req *curr;
1773 for (curr = se->interrupts.next; curr != &se->interrupts;
1774 curr = curr->next) {
1775 if (curr->u.i.unique == req->unique) {
1776 req->interrupted = 1;
1778 fuse_chan_put(curr->ch);
1784 curr = se->interrupts.next;
1785 if (curr != &se->interrupts) {
1787 list_init_req(curr);
1795 struct fuse_bmap_in *arg = (
struct fuse_bmap_in *) inarg;
1797 if (req->se->op.bmap)
1798 req->se->op.bmap(req, nodeid, arg->blocksize, arg->block);
1805 struct fuse_ioctl_in *arg = (
struct fuse_ioctl_in *) inarg;
1806 unsigned int flags = arg->flags;
1807 void *in_buf = arg->in_size ? PARAM(arg) : NULL;
1810 if (
flags & FUSE_IOCTL_DIR &&
1816 memset(&fi, 0,
sizeof(fi));
1819 if (
sizeof(
void *) == 4 && req->se->conn.proto_minor >= 16 &&
1820 !(
flags & FUSE_IOCTL_32BIT)) {
1821 req->ioctl_64bit = 1;
1824 if (req->se->op.ioctl)
1825 req->se->op.ioctl(req, nodeid, arg->cmd,
1826 (
void *)(uintptr_t)arg->arg, &fi,
flags,
1827 in_buf, arg->in_size, arg->out_size);
1839 struct fuse_poll_in *arg = (
struct fuse_poll_in *) inarg;
1842 memset(&fi, 0,
sizeof(fi));
1846 if (req->se->op.poll) {
1847 struct fuse_pollhandle *ph = NULL;
1849 if (arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) {
1850 ph = malloc(
sizeof(
struct fuse_pollhandle));
1859 req->se->op.poll(req, nodeid, &fi, ph);
1867 struct fuse_fallocate_in *arg = (
struct fuse_fallocate_in *) inarg;
1870 memset(&fi, 0,
sizeof(fi));
1873 if (req->se->op.fallocate)
1874 req->se->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi);
1881 struct fuse_copy_file_range_in *arg = (
struct fuse_copy_file_range_in *) inarg;
1884 memset(&fi_in, 0,
sizeof(fi_in));
1885 fi_in.fh = arg->fh_in;
1887 memset(&fi_out, 0,
sizeof(fi_out));
1888 fi_out.fh = arg->fh_out;
1891 if (req->se->op.copy_file_range)
1892 req->se->op.copy_file_range(req, nodeid_in, arg->off_in,
1893 &fi_in, arg->nodeid_out,
1894 arg->off_out, &fi_out, arg->len,
1902 struct fuse_lseek_in *arg = (
struct fuse_lseek_in *) inarg;
1905 memset(&fi, 0,
sizeof(fi));
1908 if (req->se->op.lseek)
1909 req->se->op.lseek(req, nodeid, arg->offset, arg->whence, &fi);
1916 static __attribute__((no_sanitize(
"thread")))
1919 struct fuse_init_in *arg = (
struct fuse_init_in *) inarg;
1920 struct fuse_init_out outarg;
1921 struct fuse_session *se = req->se;
1922 size_t bufsize = se->bufsize;
1923 size_t outargsize =
sizeof(outarg);
1924 uint64_t inargflags = 0;
1925 uint64_t outargflags = 0;
1928 fuse_log(FUSE_LOG_DEBUG,
"INIT: %u.%u\n", arg->major, arg->minor);
1929 if (arg->major == 7 && arg->minor >= 6) {
1930 fuse_log(FUSE_LOG_DEBUG,
"flags=0x%08x\n", arg->flags);
1931 fuse_log(FUSE_LOG_DEBUG,
"max_readahead=0x%08x\n",
1932 arg->max_readahead);
1935 se->conn.proto_major = arg->major;
1936 se->conn.proto_minor = arg->minor;
1937 se->conn.capable = 0;
1940 memset(&outarg, 0,
sizeof(outarg));
1941 outarg.major = FUSE_KERNEL_VERSION;
1942 outarg.minor = FUSE_KERNEL_MINOR_VERSION;
1944 if (arg->major < 7) {
1945 fuse_log(FUSE_LOG_ERR,
"fuse: unsupported protocol version: %u.%u\n",
1946 arg->major, arg->minor);
1951 if (arg->major > 7) {
1953 send_reply_ok(req, &outarg,
sizeof(outarg));
1957 if (arg->minor >= 6) {
1958 if (arg->max_readahead < se->conn.max_readahead)
1959 se->conn.max_readahead = arg->max_readahead;
1960 inargflags = arg->flags;
1961 if (inargflags & FUSE_INIT_EXT)
1962 inargflags = inargflags | (uint64_t) arg->flags2 << 32;
1963 if (inargflags & FUSE_ASYNC_READ)
1965 if (inargflags & FUSE_POSIX_LOCKS)
1967 if (inargflags & FUSE_ATOMIC_O_TRUNC)
1969 if (inargflags & FUSE_EXPORT_SUPPORT)
1971 if (inargflags & FUSE_DONT_MASK)
1973 if (inargflags & FUSE_FLOCK_LOCKS)
1975 if (inargflags & FUSE_AUTO_INVAL_DATA)
1977 if (inargflags & FUSE_DO_READDIRPLUS)
1979 if (inargflags & FUSE_READDIRPLUS_AUTO)
1981 if (inargflags & FUSE_ASYNC_DIO)
1983 if (inargflags & FUSE_WRITEBACK_CACHE)
1985 if (inargflags & FUSE_NO_OPEN_SUPPORT)
1987 if (inargflags & FUSE_PARALLEL_DIROPS)
1989 if (inargflags & FUSE_POSIX_ACL)
1991 if (inargflags & FUSE_HANDLE_KILLPRIV)
1993 if (inargflags & FUSE_CACHE_SYMLINKS)
1995 if (inargflags & FUSE_NO_OPENDIR_SUPPORT)
1997 if (inargflags & FUSE_EXPLICIT_INVAL_DATA)
1999 if (!(inargflags & FUSE_MAX_PAGES)) {
2000 size_t max_bufsize =
2001 FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
2002 + FUSE_BUFFER_HEADER_SIZE;
2003 if (bufsize > max_bufsize) {
2004 bufsize = max_bufsize;
2007 if (arg->minor >= 38)
2010 se->conn.max_readahead = 0;
2013 if (se->conn.proto_minor >= 14) {
2015 #ifdef HAVE_VMSPLICE
2016 if ((se->io == NULL) || (se->io->splice_send != NULL)) {
2020 if ((se->io == NULL) || (se->io->splice_receive != NULL)) {
2025 if (se->conn.proto_minor >= 18)
2035 #define LL_SET_DEFAULT(cond, cap) \
2036 if ((cond) && (se->conn.capable & (cap))) \
2037 se->conn.want |= (cap)
2046 LL_SET_DEFAULT(se->op.getlk && se->op.setlk,
2050 LL_SET_DEFAULT(se->op.readdirplus && se->op.readdir,
2052 se->conn.time_gran = 1;
2054 if (bufsize < FUSE_MIN_READ_BUFFER) {
2055 fuse_log(FUSE_LOG_ERR,
"fuse: warning: buffer size too small: %zu\n",
2057 bufsize = FUSE_MIN_READ_BUFFER;
2059 se->bufsize = bufsize;
2061 if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE)
2062 se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE;
2066 se->op.init(se->userdata, &se->conn);
2068 if (se->conn.want & (~se->conn.capable)) {
2069 fuse_log(FUSE_LOG_ERR,
"fuse: error: filesystem requested capabilities "
2070 "0x%x that are not supported by kernel, aborting.\n",
2071 se->conn.want & (~se->conn.capable));
2073 se->error = -EPROTO;
2078 unsigned max_read_mo = get_max_read(se->mo);
2079 if (se->conn.max_read != max_read_mo) {
2080 fuse_log(FUSE_LOG_ERR,
"fuse: error: init() and fuse_session_new() "
2081 "requested different maximum read size (%u vs %u)\n",
2082 se->conn.max_read, max_read_mo);
2084 se->error = -EPROTO;
2089 if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE) {
2090 se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
2092 if (arg->flags & FUSE_MAX_PAGES) {
2093 outarg.flags |= FUSE_MAX_PAGES;
2094 outarg.max_pages = (se->conn.max_write - 1) / getpagesize() + 1;
2096 outargflags = outarg.flags;
2099 outargflags |= FUSE_BIG_WRITES;
2102 outargflags |= FUSE_ASYNC_READ;
2104 outargflags |= FUSE_POSIX_LOCKS;
2106 outargflags |= FUSE_ATOMIC_O_TRUNC;
2108 outargflags |= FUSE_EXPORT_SUPPORT;
2110 outargflags |= FUSE_DONT_MASK;
2112 outargflags |= FUSE_FLOCK_LOCKS;
2114 outargflags |= FUSE_AUTO_INVAL_DATA;
2116 outargflags |= FUSE_DO_READDIRPLUS;
2118 outargflags |= FUSE_READDIRPLUS_AUTO;
2120 outargflags |= FUSE_ASYNC_DIO;
2122 outargflags |= FUSE_WRITEBACK_CACHE;
2124 outargflags |= FUSE_POSIX_ACL;
2126 outargflags |= FUSE_CACHE_SYMLINKS;
2128 outargflags |= FUSE_EXPLICIT_INVAL_DATA;
2130 if (inargflags & FUSE_INIT_EXT) {
2131 outargflags |= FUSE_INIT_EXT;
2132 outarg.flags2 = outargflags >> 32;
2135 outarg.flags = outargflags;
2137 outarg.max_readahead = se->conn.max_readahead;
2138 outarg.max_write = se->conn.max_write;
2139 if (se->conn.proto_minor >= 13) {
2140 if (se->conn.max_background >= (1 << 16))
2141 se->conn.max_background = (1 << 16) - 1;
2142 if (se->conn.congestion_threshold > se->conn.max_background)
2143 se->conn.congestion_threshold = se->conn.max_background;
2144 if (!se->conn.congestion_threshold) {
2145 se->conn.congestion_threshold =
2146 se->conn.max_background * 3 / 4;
2149 outarg.max_background = se->conn.max_background;
2150 outarg.congestion_threshold = se->conn.congestion_threshold;
2152 if (se->conn.proto_minor >= 23)
2153 outarg.time_gran = se->conn.time_gran;
2156 fuse_log(FUSE_LOG_DEBUG,
" INIT: %u.%u\n", outarg.major, outarg.minor);
2157 fuse_log(FUSE_LOG_DEBUG,
" flags=0x%08x\n", outarg.flags);
2158 fuse_log(FUSE_LOG_DEBUG,
" max_readahead=0x%08x\n",
2159 outarg.max_readahead);
2160 fuse_log(FUSE_LOG_DEBUG,
" max_write=0x%08x\n", outarg.max_write);
2161 fuse_log(FUSE_LOG_DEBUG,
" max_background=%i\n",
2162 outarg.max_background);
2163 fuse_log(FUSE_LOG_DEBUG,
" congestion_threshold=%i\n",
2164 outarg.congestion_threshold);
2165 fuse_log(FUSE_LOG_DEBUG,
" time_gran=%u\n",
2169 outargsize = FUSE_COMPAT_INIT_OUT_SIZE;
2170 else if (arg->minor < 23)
2171 outargsize = FUSE_COMPAT_22_INIT_OUT_SIZE;
2173 send_reply_ok(req, &outarg, outargsize);
2178 struct fuse_session *se = req->se;
2183 se->got_destroy = 1;
2185 se->op.destroy(se->userdata);
2187 send_reply_ok(req, NULL, 0);
2190 static void list_del_nreq(
struct fuse_notify_req *nreq)
2192 struct fuse_notify_req *prev = nreq->prev;
2193 struct fuse_notify_req *next = nreq->next;
2198 static void list_add_nreq(
struct fuse_notify_req *nreq,
2199 struct fuse_notify_req *next)
2201 struct fuse_notify_req *prev = next->prev;
2208 static void list_init_nreq(
struct fuse_notify_req *nreq)
2215 const void *inarg,
const struct fuse_buf *buf)
2217 struct fuse_session *se = req->se;
2218 struct fuse_notify_req *nreq;
2219 struct fuse_notify_req *head;
2221 pthread_mutex_lock(&se->lock);
2222 head = &se->notify_list;
2223 for (nreq = head->next; nreq != head; nreq = nreq->next) {
2224 if (nreq->unique == req->unique) {
2225 list_del_nreq(nreq);
2229 pthread_mutex_unlock(&se->lock);
2232 nreq->reply(nreq, req, nodeid, inarg, buf);
2235 static int send_notify_iov(
struct fuse_session *se,
int notify_code,
2236 struct iovec *iov,
int count)
2238 struct fuse_out_header out;
2244 out.error = notify_code;
2245 iov[0].iov_base = &out;
2246 iov[0].iov_len =
sizeof(
struct fuse_out_header);
2248 return fuse_send_msg(se, NULL, iov, count);
2254 struct fuse_notify_poll_wakeup_out outarg;
2255 struct iovec iov[2];
2259 iov[1].iov_base = &outarg;
2260 iov[1].iov_len =
sizeof(outarg);
2262 return send_notify_iov(ph->se, FUSE_NOTIFY_POLL, iov, 2);
2269 off_t off, off_t len)
2271 struct fuse_notify_inval_inode_out outarg;
2272 struct iovec iov[2];
2277 if (se->conn.proto_minor < 12)
2284 iov[1].iov_base = &outarg;
2285 iov[1].iov_len =
sizeof(outarg);
2287 return send_notify_iov(se, FUSE_NOTIFY_INVAL_INODE, iov, 2);
2291 const char *name,
size_t namelen,
2294 struct fuse_notify_inval_entry_out outarg;
2295 struct iovec iov[3];
2300 if (se->conn.proto_minor < 12)
2303 outarg.parent = parent;
2304 outarg.namelen = namelen;
2306 if (flags & FUSE_LL_EXPIRE_ONLY)
2307 outarg.flags |= FUSE_EXPIRE_ONLY;
2309 iov[1].iov_base = &outarg;
2310 iov[1].iov_len =
sizeof(outarg);
2311 iov[2].iov_base = (
void *)name;
2312 iov[2].iov_len = namelen + 1;
2314 return send_notify_iov(se, FUSE_NOTIFY_INVAL_ENTRY, iov, 3);
2318 const char *name,
size_t namelen)
2326 const char *name,
size_t namelen)
2328 struct fuse_notify_delete_out outarg;
2329 struct iovec iov[3];
2334 if (se->conn.proto_minor < 18)
2337 outarg.parent = parent;
2338 outarg.child = child;
2339 outarg.namelen = namelen;
2342 iov[1].iov_base = &outarg;
2343 iov[1].iov_len =
sizeof(outarg);
2344 iov[2].iov_base = (
void *)name;
2345 iov[2].iov_len = namelen + 1;
2347 return send_notify_iov(se, FUSE_NOTIFY_DELETE, iov, 3);
2354 struct fuse_out_header out;
2355 struct fuse_notify_store_out outarg;
2356 struct iovec iov[3];
2363 if (se->conn.proto_minor < 15)
2367 out.error = FUSE_NOTIFY_STORE;
2369 outarg.nodeid = ino;
2370 outarg.offset = offset;
2374 iov[0].iov_base = &out;
2375 iov[0].iov_len =
sizeof(out);
2376 iov[1].iov_base = &outarg;
2377 iov[1].iov_len =
sizeof(outarg);
2379 res = fuse_send_data_iov(se, NULL, iov, 2, bufv, flags);
2386 struct fuse_retrieve_req {
2387 struct fuse_notify_req nreq;
2391 static void fuse_ll_retrieve_reply(
struct fuse_notify_req *nreq,
2396 struct fuse_session *se = req->se;
2397 struct fuse_retrieve_req *rreq =
2398 container_of(nreq,
struct fuse_retrieve_req, nreq);
2399 const struct fuse_notify_retrieve_in *arg = inarg;
2406 bufv.
buf[0].
mem = PARAM(arg);
2408 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
2409 sizeof(struct fuse_notify_retrieve_in);
2411 if (bufv.
buf[0].
size < arg->size) {
2412 fuse_log(FUSE_LOG_ERR,
"fuse: retrieve reply: buffer size too small\n");
2418 if (se->op.retrieve_reply) {
2419 se->op.retrieve_reply(req, rreq->cookie, ino,
2420 arg->offset, &bufv);
2427 fuse_ll_clear_pipe(se);
2431 size_t size, off_t offset,
void *cookie)
2433 struct fuse_notify_retrieve_out outarg;
2434 struct iovec iov[2];
2435 struct fuse_retrieve_req *rreq;
2441 if (se->conn.proto_minor < 15)
2444 rreq = malloc(
sizeof(*rreq));
2448 pthread_mutex_lock(&se->lock);
2449 rreq->cookie = cookie;
2450 rreq->nreq.unique = se->notify_ctr++;
2451 rreq->nreq.reply = fuse_ll_retrieve_reply;
2452 list_add_nreq(&rreq->nreq, &se->notify_list);
2453 pthread_mutex_unlock(&se->lock);
2455 outarg.notify_unique = rreq->nreq.unique;
2456 outarg.nodeid = ino;
2457 outarg.offset = offset;
2461 iov[1].iov_base = &outarg;
2462 iov[1].iov_len =
sizeof(outarg);
2464 err = send_notify_iov(se, FUSE_NOTIFY_RETRIEVE, iov, 2);
2466 pthread_mutex_lock(&se->lock);
2467 list_del_nreq(&rreq->nreq);
2468 pthread_mutex_unlock(&se->lock);
2477 return req->se->userdata;
2488 pthread_mutex_lock(&req->lock);
2489 pthread_mutex_lock(&req->se->lock);
2490 req->u.ni.func = func;
2491 req->u.ni.data = data;
2492 pthread_mutex_unlock(&req->se->lock);
2493 if (req->interrupted && func)
2495 pthread_mutex_unlock(&req->lock);
2502 pthread_mutex_lock(&req->se->lock);
2503 interrupted = req->interrupted;
2504 pthread_mutex_unlock(&req->se->lock);
2513 [FUSE_LOOKUP] = { do_lookup,
"LOOKUP" },
2514 [FUSE_FORGET] = { do_forget,
"FORGET" },
2515 [FUSE_GETATTR] = { do_getattr,
"GETATTR" },
2516 [FUSE_SETATTR] = { do_setattr,
"SETATTR" },
2517 [FUSE_READLINK] = { do_readlink,
"READLINK" },
2518 [FUSE_SYMLINK] = { do_symlink,
"SYMLINK" },
2519 [FUSE_MKNOD] = { do_mknod,
"MKNOD" },
2520 [FUSE_MKDIR] = { do_mkdir,
"MKDIR" },
2521 [FUSE_UNLINK] = { do_unlink,
"UNLINK" },
2522 [FUSE_RMDIR] = { do_rmdir,
"RMDIR" },
2523 [FUSE_RENAME] = { do_rename,
"RENAME" },
2524 [FUSE_LINK] = { do_link,
"LINK" },
2525 [FUSE_OPEN] = { do_open,
"OPEN" },
2526 [FUSE_READ] = { do_read,
"READ" },
2527 [FUSE_WRITE] = { do_write,
"WRITE" },
2528 [FUSE_STATFS] = { do_statfs,
"STATFS" },
2529 [FUSE_RELEASE] = { do_release,
"RELEASE" },
2530 [FUSE_FSYNC] = { do_fsync,
"FSYNC" },
2531 [FUSE_SETXATTR] = { do_setxattr,
"SETXATTR" },
2532 [FUSE_GETXATTR] = { do_getxattr,
"GETXATTR" },
2533 [FUSE_LISTXATTR] = { do_listxattr,
"LISTXATTR" },
2534 [FUSE_REMOVEXATTR] = { do_removexattr,
"REMOVEXATTR" },
2535 [FUSE_FLUSH] = { do_flush,
"FLUSH" },
2536 [FUSE_INIT] = { do_init,
"INIT" },
2537 [FUSE_OPENDIR] = { do_opendir,
"OPENDIR" },
2538 [FUSE_READDIR] = { do_readdir,
"READDIR" },
2539 [FUSE_RELEASEDIR] = { do_releasedir,
"RELEASEDIR" },
2540 [FUSE_FSYNCDIR] = { do_fsyncdir,
"FSYNCDIR" },
2541 [FUSE_GETLK] = { do_getlk,
"GETLK" },
2542 [FUSE_SETLK] = { do_setlk,
"SETLK" },
2543 [FUSE_SETLKW] = { do_setlkw,
"SETLKW" },
2544 [FUSE_ACCESS] = { do_access,
"ACCESS" },
2545 [FUSE_CREATE] = { do_create,
"CREATE" },
2546 [FUSE_INTERRUPT] = { do_interrupt,
"INTERRUPT" },
2547 [FUSE_BMAP] = { do_bmap,
"BMAP" },
2548 [FUSE_IOCTL] = { do_ioctl,
"IOCTL" },
2549 [FUSE_POLL] = { do_poll,
"POLL" },
2550 [FUSE_FALLOCATE] = { do_fallocate,
"FALLOCATE" },
2551 [FUSE_DESTROY] = { do_destroy,
"DESTROY" },
2552 [FUSE_NOTIFY_REPLY] = { (
void *) 1,
"NOTIFY_REPLY" },
2553 [FUSE_BATCH_FORGET] = { do_batch_forget,
"BATCH_FORGET" },
2554 [FUSE_READDIRPLUS] = { do_readdirplus,
"READDIRPLUS"},
2555 [FUSE_RENAME2] = { do_rename2,
"RENAME2" },
2556 [FUSE_COPY_FILE_RANGE] = { do_copy_file_range,
"COPY_FILE_RANGE" },
2557 [FUSE_LSEEK] = { do_lseek,
"LSEEK" },
2558 [CUSE_INIT] = { cuse_lowlevel_init,
"CUSE_INIT" },
2561 #define FUSE_MAXOP (sizeof(fuse_ll_ops) / sizeof(fuse_ll_ops[0]))
2563 static const char *opname(
enum fuse_opcode opcode)
2565 if (opcode >= FUSE_MAXOP || !fuse_ll_ops[opcode].name)
2568 return fuse_ll_ops[opcode].name;
2571 static int fuse_ll_copy_from_pipe(
struct fuse_bufvec *dst,
2576 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n", strerror(-res));
2580 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: short read\n");
2589 fuse_session_process_buf_int(se, buf, NULL);
2592 void fuse_session_process_buf_int(
struct fuse_session *se,
2593 const struct fuse_buf *buf,
struct fuse_chan *ch)
2595 const size_t write_header_size =
sizeof(
struct fuse_in_header) +
2596 sizeof(struct fuse_write_in);
2598 struct fuse_bufvec tmpbuf = FUSE_BUFVEC_INIT(write_header_size);
2599 struct fuse_in_header *in;
2601 struct fuse_req *req;
2610 mbuf = malloc(tmpbuf.
buf[0].
size);
2612 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate header\n");
2615 tmpbuf.
buf[0].
mem = mbuf;
2617 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
2628 "unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n",
2629 (
unsigned long long) in->unique,
2630 opname((
enum fuse_opcode) in->opcode), in->opcode,
2631 (
unsigned long long) in->nodeid, buf->
size, in->pid);
2634 req = fuse_ll_alloc_req(se);
2636 struct fuse_out_header out = {
2637 .unique = in->unique,
2640 struct iovec iov = {
2642 .iov_len =
sizeof(
struct fuse_out_header),
2645 fuse_send_msg(se, ch, &iov, 1);
2649 req->unique = in->unique;
2650 req->ctx.uid = in->uid;
2651 req->ctx.gid = in->gid;
2652 req->ctx.pid = in->pid;
2653 req->ch = ch ? fuse_chan_get(ch) : NULL;
2656 if (!se->got_init) {
2657 enum fuse_opcode expected;
2659 expected = se->cuse_data ? CUSE_INIT : FUSE_INIT;
2660 if (in->opcode != expected)
2662 }
else if (in->opcode == FUSE_INIT || in->opcode == CUSE_INIT)
2667 if (se->deny_others && in->uid != se->owner && in->uid != 0 &&
2668 in->opcode != FUSE_INIT && in->opcode != FUSE_READ &&
2669 in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC &&
2670 in->opcode != FUSE_RELEASE && in->opcode != FUSE_READDIR &&
2671 in->opcode != FUSE_FSYNCDIR && in->opcode != FUSE_RELEASEDIR &&
2672 in->opcode != FUSE_NOTIFY_REPLY &&
2673 in->opcode != FUSE_READDIRPLUS)
2677 if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func)
2679 if (in->opcode != FUSE_INTERRUPT) {
2680 struct fuse_req *intr;
2681 pthread_mutex_lock(&se->lock);
2682 intr = check_interrupt(se, req);
2683 list_add_req(req, &se->list);
2684 pthread_mutex_unlock(&se->lock);
2690 (in->opcode != FUSE_WRITE || !se->op.write_buf) &&
2691 in->opcode != FUSE_NOTIFY_REPLY) {
2695 newmbuf = realloc(mbuf, buf->
size);
2696 if (newmbuf == NULL)
2700 tmpbuf = FUSE_BUFVEC_INIT(buf->
size - write_header_size);
2701 tmpbuf.
buf[0].
mem = (
char *)mbuf + write_header_size;
2703 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
2711 inarg = (
void *) &in[1];
2712 if (in->opcode == FUSE_WRITE && se->op.write_buf)
2713 do_write_buf(req, in->nodeid, inarg, buf);
2714 else if (in->opcode == FUSE_NOTIFY_REPLY)
2715 do_notify_reply(req, in->nodeid, inarg, buf);
2717 fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
2727 fuse_ll_clear_pipe(se);
2731 #define LL_OPTION(n,o,v) \
2732 { n, offsetof(struct fuse_session, o), v }
2734 static const struct fuse_opt fuse_ll_opts[] = {
2735 LL_OPTION(
"debug", debug, 1),
2736 LL_OPTION(
"-d", debug, 1),
2737 LL_OPTION(
"--debug", debug, 1),
2738 LL_OPTION(
"allow_root", deny_others, 1),
2744 printf(
"using FUSE kernel interface version %i.%i\n",
2745 FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
2746 fuse_mount_version();
2754 " -o allow_other allow access by all users\n"
2755 " -o allow_root allow access by root\n"
2756 " -o auto_unmount auto unmount on process termination\n");
2761 struct fuse_ll_pipe *llp;
2763 if (se->got_init && !se->got_destroy) {
2765 se->op.destroy(se->userdata);
2767 llp = pthread_getspecific(se->pipe_key);
2769 fuse_ll_pipe_free(llp);
2770 pthread_key_delete(se->pipe_key);
2771 pthread_mutex_destroy(&se->lock);
2772 free(se->cuse_data);
2777 destroy_mount_opts(se->mo);
2782 static void fuse_ll_pipe_destructor(
void *data)
2784 struct fuse_ll_pipe *llp = data;
2785 fuse_ll_pipe_free(llp);
2790 return fuse_session_receive_buf_int(se, buf, NULL);
2793 int fuse_session_receive_buf_int(
struct fuse_session *se,
struct fuse_buf *buf,
2794 struct fuse_chan *ch)
2799 size_t bufsize = se->bufsize;
2800 struct fuse_ll_pipe *llp;
2806 llp = fuse_ll_get_pipe(se);
2810 if (llp->size < bufsize) {
2811 if (llp->can_grow) {
2812 res = fcntl(llp->pipe[0], F_SETPIPE_SZ, bufsize);
2815 res = grow_pipe_to_max(llp->pipe[0]);
2822 if (llp->size < bufsize)
2826 if (se->io != NULL && se->io->splice_receive != NULL) {
2827 res = se->io->splice_receive(ch ? ch->fd : se->fd, NULL,
2828 llp->pipe[1], NULL, bufsize, 0,
2831 res = splice(ch ? ch->fd : se->fd, NULL, llp->pipe[1], NULL,
2840 if (err == ENODEV) {
2846 if (err != EINTR && err != EAGAIN)
2847 perror(
"fuse: splice from device");
2851 if (res <
sizeof(
struct fuse_in_header)) {
2852 fuse_log(FUSE_LOG_ERR,
"short splice from fuse device\n");
2867 if (res <
sizeof(
struct fuse_in_header) +
2868 sizeof(
struct fuse_write_in) + pagesize) {
2873 buf->
mem = malloc(se->bufsize);
2876 "fuse: failed to allocate read buffer\n");
2886 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n",
2888 fuse_ll_clear_pipe(se);
2891 if (res < tmpbuf.size) {
2892 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: short read\n");
2893 fuse_ll_clear_pipe(se);
2896 assert(res == tmpbuf.size);
2900 buf->
fd = tmpbuf.fd;
2910 buf->
mem = malloc(se->bufsize);
2913 "fuse: failed to allocate read buffer\n");
2919 if (se->io != NULL) {
2922 res = se->io->read(ch ? ch->fd : se->fd,
buf->
mem, se->bufsize,
2925 res = read(ch ? ch->fd : se->fd,
buf->
mem, se->bufsize);
2937 if (err == ENODEV) {
2946 if (err != EINTR && err != EAGAIN)
2947 perror(
"fuse: reading device");
2950 if ((
size_t) res <
sizeof(
struct fuse_in_header)) {
2951 fuse_log(FUSE_LOG_ERR,
"short read on fuse device\n");
2962 size_t op_size,
void *userdata)
2965 struct fuse_session *se;
2966 struct mount_opts *mo;
2969 fuse_log(FUSE_LOG_ERR,
"fuse: warning: library too old, some operations may not work\n");
2973 if (args->
argc == 0) {
2974 fuse_log(FUSE_LOG_ERR,
"fuse: empty argv passed to fuse_session_new().\n");
2978 se = (
struct fuse_session *) calloc(1,
sizeof(
struct fuse_session));
2980 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate fuse object\n");
2984 se->conn.max_write = UINT_MAX;
2985 se->conn.max_readahead = UINT_MAX;
2990 if(se->deny_others) {
3000 mo = parse_mount_opts(args);
3004 if(args->
argc == 1 &&
3005 args->
argv[0][0] ==
'-') {
3006 fuse_log(FUSE_LOG_ERR,
"fuse: warning: argv[0] looks like an option, but "
3007 "will be ignored\n");
3008 }
else if (args->
argc != 1) {
3010 fuse_log(FUSE_LOG_ERR,
"fuse: unknown option(s): `");
3011 for(i = 1; i < args->
argc-1; i++)
3018 fuse_log(FUSE_LOG_DEBUG,
"FUSE library version: %s\n", PACKAGE_VERSION);
3020 se->bufsize = FUSE_MAX_MAX_PAGES * getpagesize() +
3021 FUSE_BUFFER_HEADER_SIZE;
3023 list_init_req(&se->list);
3024 list_init_req(&se->interrupts);
3025 list_init_nreq(&se->notify_list);
3027 pthread_mutex_init(&se->lock, NULL);
3029 err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor);
3031 fuse_log(FUSE_LOG_ERR,
"fuse: failed to create thread specific key: %s\n",
3036 memcpy(&se->op, op, op_size);
3037 se->owner = getuid();
3038 se->userdata = userdata;
3044 pthread_mutex_destroy(&se->lock);
3049 destroy_mount_opts(mo);
3060 fuse_log(FUSE_LOG_ERR,
"Invalid file descriptor value %d passed to "
3061 "fuse_session_custom_io()\n", fd);
3065 fuse_log(FUSE_LOG_ERR,
"No custom IO passed to "
3066 "fuse_session_custom_io()\n");
3068 }
else if (io->read == NULL || io->writev == NULL) {
3073 fuse_log(FUSE_LOG_ERR,
"io passed to fuse_session_custom_io() must "
3074 "implement both io->read() and io->writev\n");
3078 se->io = malloc(
sizeof(
struct fuse_custom_io));
3079 if (se->io == NULL) {
3080 fuse_log(FUSE_LOG_ERR,
"Failed to allocate memory for custom io. "
3081 "Error: %s\n", strerror(errno));
3099 fd = open(
"/dev/null", O_RDWR);
3102 }
while (fd >= 0 && fd <= 2);
3110 fd = fuse_mnt_parse_fuse_fd(mountpoint);
3112 if (fcntl(fd, F_GETFD) == -1) {
3114 "fuse: Invalid file descriptor /dev/fd/%u\n",
3123 fd = fuse_kern_mount(mountpoint, se->mo);
3129 se->mountpoint = strdup(mountpoint);
3130 if (se->mountpoint == NULL)
3136 fuse_kern_unmount(mountpoint, fd);
3147 if (se->mountpoint != NULL) {
3148 fuse_kern_unmount(se->mountpoint, se->fd);
3150 free(se->mountpoint);
3151 se->mountpoint = NULL;
3159 size_t bufsize = 1024;
3163 unsigned long pid = req->ctx.pid;
3166 sprintf(path,
"/proc/%lu/task/%lu/status", pid, pid);
3169 buf = malloc(bufsize);
3174 fd = open(path, O_RDONLY);
3178 ret = read(fd, buf, bufsize);
3185 if ((
size_t)ret == bufsize) {
3192 s = strstr(buf,
"\nGroups:");
3200 unsigned long val = strtoul(s, &end, 0);
3220 (void) req; (void) size; (void) list;
3227 __attribute__((no_sanitize_thread))
3233 __attribute__((no_sanitize_thread))
3240 __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 cache_readdir