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_KILL_SUID |
1190 FUSE_SET_ATTR_KILL_SGID |
1191 FUSE_SET_ATTR_ATIME_NOW |
1192 FUSE_SET_ATTR_MTIME_NOW |
1193 FUSE_SET_ATTR_CTIME;
1195 req->se->op.setattr(req, nodeid, &stbuf, arg->valid, fi);
1202 struct fuse_access_in *arg = (
struct fuse_access_in *) inarg;
1204 if (req->se->op.access)
1205 req->se->op.access(req, nodeid, arg->mask);
1214 if (req->se->op.readlink)
1215 req->se->op.readlink(req, nodeid);
1222 struct fuse_mknod_in *arg = (
struct fuse_mknod_in *) inarg;
1223 char *name = PARAM(arg);
1225 if (req->se->conn.proto_minor >= 12)
1226 req->ctx.umask = arg->umask;
1228 name = (
char *) inarg + FUSE_COMPAT_MKNOD_IN_SIZE;
1230 if (req->se->op.mknod)
1231 req->se->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
1238 struct fuse_mkdir_in *arg = (
struct fuse_mkdir_in *) inarg;
1240 if (req->se->conn.proto_minor >= 12)
1241 req->ctx.umask = arg->umask;
1243 if (req->se->op.mkdir)
1244 req->se->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
1251 char *name = (
char *) inarg;
1253 if (req->se->op.unlink)
1254 req->se->op.unlink(req, nodeid, name);
1261 char *name = (
char *) inarg;
1263 if (req->se->op.rmdir)
1264 req->se->op.rmdir(req, nodeid, name);
1271 char *name = (
char *) inarg;
1272 char *linkname = ((
char *) inarg) + strlen((
char *) inarg) + 1;
1274 if (req->se->op.symlink)
1275 req->se->op.symlink(req, linkname, nodeid, name);
1282 struct fuse_rename_in *arg = (
struct fuse_rename_in *) inarg;
1283 char *oldname = PARAM(arg);
1284 char *newname = oldname + strlen(oldname) + 1;
1286 if (req->se->op.rename)
1287 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1295 struct fuse_rename2_in *arg = (
struct fuse_rename2_in *) inarg;
1296 char *oldname = PARAM(arg);
1297 char *newname = oldname + strlen(oldname) + 1;
1299 if (req->se->op.rename)
1300 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1308 struct fuse_link_in *arg = (
struct fuse_link_in *) inarg;
1310 if (req->se->op.link)
1311 req->se->op.link(req, arg->oldnodeid, nodeid, PARAM(arg));
1318 struct fuse_create_in *arg = (
struct fuse_create_in *) inarg;
1320 if (req->se->op.create) {
1322 char *name = PARAM(arg);
1324 memset(&fi, 0,
sizeof(fi));
1325 fi.
flags = arg->flags;
1327 if (req->se->conn.proto_minor >= 12)
1328 req->ctx.umask = arg->umask;
1330 name = (
char *) inarg +
sizeof(
struct fuse_open_in);
1332 req->se->op.create(req, nodeid, name, arg->mode, &fi);
1339 struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
1342 memset(&fi, 0,
sizeof(fi));
1343 fi.
flags = arg->flags;
1345 if (req->se->op.open)
1346 req->se->op.open(req, nodeid, &fi);
1353 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1355 if (req->se->op.read) {
1358 memset(&fi, 0,
sizeof(fi));
1360 if (req->se->conn.proto_minor >= 9) {
1362 fi.
flags = arg->flags;
1364 req->se->op.read(req, nodeid, arg->size, arg->offset, &fi);
1371 struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
1375 memset(&fi, 0,
sizeof(fi));
1377 fi.
writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
1379 if (req->se->conn.proto_minor < 9) {
1380 param = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1383 fi.
flags = arg->flags;
1387 if (req->se->op.write)
1388 req->se->op.write(req, nodeid, param, arg->size,
1397 struct fuse_session *se = req->se;
1402 struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
1405 memset(&fi, 0,
sizeof(fi));
1407 fi.
writepage = arg->write_flags & FUSE_WRITE_CACHE;
1409 if (se->conn.proto_minor < 9) {
1410 bufv.
buf[0].
mem = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1411 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1412 FUSE_COMPAT_WRITE_IN_SIZE;
1416 fi.
flags = arg->flags;
1418 bufv.
buf[0].
mem = PARAM(arg);
1420 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
1421 sizeof(struct fuse_write_in);
1423 if (bufv.
buf[0].
size < arg->size) {
1424 fuse_log(FUSE_LOG_ERR,
"fuse: do_write_buf: buffer size too small\n");
1430 se->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
1435 fuse_ll_clear_pipe(se);
1440 struct fuse_flush_in *arg = (
struct fuse_flush_in *) inarg;
1443 memset(&fi, 0,
sizeof(fi));
1446 if (req->se->conn.proto_minor >= 7)
1449 if (req->se->op.flush)
1450 req->se->op.flush(req, nodeid, &fi);
1457 struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
1460 memset(&fi, 0,
sizeof(fi));
1461 fi.
flags = arg->flags;
1463 if (req->se->conn.proto_minor >= 8) {
1464 fi.
flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
1467 if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) {
1468 fi.flock_release = 1;
1472 if (req->se->op.release)
1473 req->se->op.release(req, nodeid, &fi);
1480 struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
1482 int datasync = arg->fsync_flags & 1;
1484 memset(&fi, 0,
sizeof(fi));
1487 if (req->se->op.fsync)
1488 req->se->op.fsync(req, nodeid, datasync, &fi);
1495 struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
1498 memset(&fi, 0,
sizeof(fi));
1499 fi.
flags = arg->flags;
1501 if (req->se->op.opendir)
1502 req->se->op.opendir(req, nodeid, &fi);
1509 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1512 memset(&fi, 0,
sizeof(fi));
1515 if (req->se->op.readdir)
1516 req->se->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
1523 struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
1526 memset(&fi, 0,
sizeof(fi));
1529 if (req->se->op.readdirplus)
1530 req->se->op.readdirplus(req, nodeid, arg->size, arg->offset, &fi);
1537 struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
1540 memset(&fi, 0,
sizeof(fi));
1541 fi.
flags = arg->flags;
1544 if (req->se->op.releasedir)
1545 req->se->op.releasedir(req, nodeid, &fi);
1552 struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
1554 int datasync = arg->fsync_flags & 1;
1556 memset(&fi, 0,
sizeof(fi));
1559 if (req->se->op.fsyncdir)
1560 req->se->op.fsyncdir(req, nodeid, datasync, &fi);
1570 if (req->se->op.statfs)
1571 req->se->op.statfs(req, nodeid);
1573 struct statvfs buf = {
1583 struct fuse_setxattr_in *arg = (
struct fuse_setxattr_in *) inarg;
1584 char *name = PARAM(arg);
1585 char *value = name + strlen(name) + 1;
1587 if (req->se->op.setxattr)
1588 req->se->op.setxattr(req, nodeid, name, value, arg->size,
1596 struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
1598 if (req->se->op.getxattr)
1599 req->se->op.getxattr(req, nodeid, PARAM(arg), arg->size);
1606 struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
1608 if (req->se->op.listxattr)
1609 req->se->op.listxattr(req, nodeid, arg->size);
1616 char *name = (
char *) inarg;
1618 if (req->se->op.removexattr)
1619 req->se->op.removexattr(req, nodeid, name);
1624 static void convert_fuse_file_lock(
struct fuse_file_lock *fl,
1625 struct flock *flock)
1627 memset(flock, 0,
sizeof(
struct flock));
1628 flock->l_type = fl->type;
1629 flock->l_whence = SEEK_SET;
1630 flock->l_start = fl->start;
1631 if (fl->end == OFFSET_MAX)
1634 flock->l_len = fl->end - fl->start + 1;
1635 flock->l_pid = fl->pid;
1640 struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
1644 memset(&fi, 0,
sizeof(fi));
1648 convert_fuse_file_lock(&arg->lk, &flock);
1649 if (req->se->op.getlk)
1650 req->se->op.getlk(req, nodeid, &fi, &flock);
1656 const void *inarg,
int sleep)
1658 struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
1662 memset(&fi, 0,
sizeof(fi));
1666 if (arg->lk_flags & FUSE_LK_FLOCK) {
1669 switch (arg->lk.type) {
1683 if (req->se->op.flock)
1684 req->se->op.flock(req, nodeid, &fi, op);
1688 convert_fuse_file_lock(&arg->lk, &flock);
1689 if (req->se->op.setlk)
1690 req->se->op.setlk(req, nodeid, &fi, &flock, sleep);
1698 do_setlk_common(req, nodeid, inarg, 0);
1703 do_setlk_common(req, nodeid, inarg, 1);
1706 static int find_interrupted(
struct fuse_session *se,
struct fuse_req *req)
1708 struct fuse_req *curr;
1710 for (curr = se->list.next; curr != &se->list; curr = curr->next) {
1711 if (curr->unique == req->u.i.unique) {
1716 pthread_mutex_unlock(&se->lock);
1719 pthread_mutex_lock(&curr->lock);
1720 pthread_mutex_lock(&se->lock);
1721 curr->interrupted = 1;
1722 func = curr->u.ni.func;
1723 data = curr->u.ni.data;
1724 pthread_mutex_unlock(&se->lock);
1727 pthread_mutex_unlock(&curr->lock);
1729 pthread_mutex_lock(&se->lock);
1732 fuse_chan_put(req->ch);
1740 for (curr = se->interrupts.next; curr != &se->interrupts;
1741 curr = curr->next) {
1742 if (curr->u.i.unique == req->u.i.unique)
1750 struct fuse_interrupt_in *arg = (
struct fuse_interrupt_in *) inarg;
1751 struct fuse_session *se = req->se;
1755 fuse_log(FUSE_LOG_DEBUG,
"INTERRUPT: %llu\n",
1756 (
unsigned long long) arg->unique);
1758 req->u.i.unique = arg->unique;
1760 pthread_mutex_lock(&se->lock);
1761 if (find_interrupted(se, req)) {
1762 fuse_chan_put(req->ch);
1766 list_add_req(req, &se->interrupts);
1767 pthread_mutex_unlock(&se->lock);
1770 static struct fuse_req *check_interrupt(
struct fuse_session *se,
1771 struct fuse_req *req)
1773 struct fuse_req *curr;
1775 for (curr = se->interrupts.next; curr != &se->interrupts;
1776 curr = curr->next) {
1777 if (curr->u.i.unique == req->unique) {
1778 req->interrupted = 1;
1780 fuse_chan_put(curr->ch);
1786 curr = se->interrupts.next;
1787 if (curr != &se->interrupts) {
1789 list_init_req(curr);
1797 struct fuse_bmap_in *arg = (
struct fuse_bmap_in *) inarg;
1799 if (req->se->op.bmap)
1800 req->se->op.bmap(req, nodeid, arg->blocksize, arg->block);
1807 struct fuse_ioctl_in *arg = (
struct fuse_ioctl_in *) inarg;
1808 unsigned int flags = arg->flags;
1809 void *in_buf = arg->in_size ? PARAM(arg) : NULL;
1812 if (
flags & FUSE_IOCTL_DIR &&
1818 memset(&fi, 0,
sizeof(fi));
1821 if (
sizeof(
void *) == 4 && req->se->conn.proto_minor >= 16 &&
1822 !(
flags & FUSE_IOCTL_32BIT)) {
1823 req->ioctl_64bit = 1;
1826 if (req->se->op.ioctl)
1827 req->se->op.ioctl(req, nodeid, arg->cmd,
1828 (
void *)(uintptr_t)arg->arg, &fi,
flags,
1829 in_buf, arg->in_size, arg->out_size);
1841 struct fuse_poll_in *arg = (
struct fuse_poll_in *) inarg;
1844 memset(&fi, 0,
sizeof(fi));
1848 if (req->se->op.poll) {
1849 struct fuse_pollhandle *ph = NULL;
1851 if (arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) {
1852 ph = malloc(
sizeof(
struct fuse_pollhandle));
1861 req->se->op.poll(req, nodeid, &fi, ph);
1869 struct fuse_fallocate_in *arg = (
struct fuse_fallocate_in *) inarg;
1872 memset(&fi, 0,
sizeof(fi));
1875 if (req->se->op.fallocate)
1876 req->se->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi);
1883 struct fuse_copy_file_range_in *arg = (
struct fuse_copy_file_range_in *) inarg;
1886 memset(&fi_in, 0,
sizeof(fi_in));
1887 fi_in.fh = arg->fh_in;
1889 memset(&fi_out, 0,
sizeof(fi_out));
1890 fi_out.fh = arg->fh_out;
1893 if (req->se->op.copy_file_range)
1894 req->se->op.copy_file_range(req, nodeid_in, arg->off_in,
1895 &fi_in, arg->nodeid_out,
1896 arg->off_out, &fi_out, arg->len,
1904 struct fuse_lseek_in *arg = (
struct fuse_lseek_in *) inarg;
1907 memset(&fi, 0,
sizeof(fi));
1910 if (req->se->op.lseek)
1911 req->se->op.lseek(req, nodeid, arg->offset, arg->whence, &fi);
1918 static __attribute__((no_sanitize(
"thread")))
1921 struct fuse_init_in *arg = (
struct fuse_init_in *) inarg;
1922 struct fuse_init_out outarg;
1923 struct fuse_session *se = req->se;
1924 size_t bufsize = se->bufsize;
1925 size_t outargsize =
sizeof(outarg);
1926 uint64_t inargflags = 0;
1927 uint64_t outargflags = 0;
1930 fuse_log(FUSE_LOG_DEBUG,
"INIT: %u.%u\n", arg->major, arg->minor);
1931 if (arg->major == 7 && arg->minor >= 6) {
1932 fuse_log(FUSE_LOG_DEBUG,
"flags=0x%08x\n", arg->flags);
1933 fuse_log(FUSE_LOG_DEBUG,
"max_readahead=0x%08x\n",
1934 arg->max_readahead);
1937 se->conn.proto_major = arg->major;
1938 se->conn.proto_minor = arg->minor;
1939 se->conn.capable = 0;
1942 memset(&outarg, 0,
sizeof(outarg));
1943 outarg.major = FUSE_KERNEL_VERSION;
1944 outarg.minor = FUSE_KERNEL_MINOR_VERSION;
1946 if (arg->major < 7) {
1947 fuse_log(FUSE_LOG_ERR,
"fuse: unsupported protocol version: %u.%u\n",
1948 arg->major, arg->minor);
1953 if (arg->major > 7) {
1955 send_reply_ok(req, &outarg,
sizeof(outarg));
1959 if (arg->minor >= 6) {
1960 if (arg->max_readahead < se->conn.max_readahead)
1961 se->conn.max_readahead = arg->max_readahead;
1962 inargflags = arg->flags;
1963 if (inargflags & FUSE_INIT_EXT)
1964 inargflags = inargflags | (uint64_t) arg->flags2 << 32;
1965 if (inargflags & FUSE_ASYNC_READ)
1967 if (inargflags & FUSE_POSIX_LOCKS)
1969 if (inargflags & FUSE_ATOMIC_O_TRUNC)
1971 if (inargflags & FUSE_EXPORT_SUPPORT)
1973 if (inargflags & FUSE_DONT_MASK)
1975 if (inargflags & FUSE_FLOCK_LOCKS)
1977 if (inargflags & FUSE_AUTO_INVAL_DATA)
1979 if (inargflags & FUSE_DO_READDIRPLUS)
1981 if (inargflags & FUSE_READDIRPLUS_AUTO)
1983 if (inargflags & FUSE_ASYNC_DIO)
1985 if (inargflags & FUSE_WRITEBACK_CACHE)
1987 if (inargflags & FUSE_NO_OPEN_SUPPORT)
1989 if (inargflags & FUSE_PARALLEL_DIROPS)
1991 if (inargflags & FUSE_POSIX_ACL)
1993 if (inargflags & FUSE_HANDLE_KILLPRIV)
1995 if (inargflags & FUSE_CACHE_SYMLINKS)
1997 if (inargflags & FUSE_NO_OPENDIR_SUPPORT)
1999 if (inargflags & FUSE_EXPLICIT_INVAL_DATA)
2001 if (!(inargflags & FUSE_MAX_PAGES)) {
2002 size_t max_bufsize =
2003 FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
2004 + FUSE_BUFFER_HEADER_SIZE;
2005 if (bufsize > max_bufsize) {
2006 bufsize = max_bufsize;
2009 if (arg->minor >= 38)
2012 se->conn.max_readahead = 0;
2015 if (se->conn.proto_minor >= 14) {
2017 #ifdef HAVE_VMSPLICE
2018 if ((se->io == NULL) || (se->io->splice_send != NULL)) {
2022 if ((se->io == NULL) || (se->io->splice_receive != NULL)) {
2027 if (se->conn.proto_minor >= 18)
2037 #define LL_SET_DEFAULT(cond, cap) \
2038 if ((cond) && (se->conn.capable & (cap))) \
2039 se->conn.want |= (cap)
2048 LL_SET_DEFAULT(se->op.getlk && se->op.setlk,
2052 LL_SET_DEFAULT(se->op.readdirplus && se->op.readdir,
2054 se->conn.time_gran = 1;
2056 if (bufsize < FUSE_MIN_READ_BUFFER) {
2057 fuse_log(FUSE_LOG_ERR,
"fuse: warning: buffer size too small: %zu\n",
2059 bufsize = FUSE_MIN_READ_BUFFER;
2061 se->bufsize = bufsize;
2063 if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE)
2064 se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE;
2068 se->op.init(se->userdata, &se->conn);
2070 if (se->conn.want & (~se->conn.capable)) {
2071 fuse_log(FUSE_LOG_ERR,
"fuse: error: filesystem requested capabilities "
2072 "0x%x that are not supported by kernel, aborting.\n",
2073 se->conn.want & (~se->conn.capable));
2075 se->error = -EPROTO;
2080 unsigned max_read_mo = get_max_read(se->mo);
2081 if (se->conn.max_read != max_read_mo) {
2082 fuse_log(FUSE_LOG_ERR,
"fuse: error: init() and fuse_session_new() "
2083 "requested different maximum read size (%u vs %u)\n",
2084 se->conn.max_read, max_read_mo);
2086 se->error = -EPROTO;
2091 if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE) {
2092 se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
2094 if (arg->flags & FUSE_MAX_PAGES) {
2095 outarg.flags |= FUSE_MAX_PAGES;
2096 outarg.max_pages = (se->conn.max_write - 1) / getpagesize() + 1;
2098 outargflags = outarg.flags;
2101 outargflags |= FUSE_BIG_WRITES;
2104 outargflags |= FUSE_ASYNC_READ;
2106 outargflags |= FUSE_POSIX_LOCKS;
2108 outargflags |= FUSE_ATOMIC_O_TRUNC;
2110 outargflags |= FUSE_EXPORT_SUPPORT;
2112 outargflags |= FUSE_DONT_MASK;
2114 outargflags |= FUSE_FLOCK_LOCKS;
2116 outargflags |= FUSE_AUTO_INVAL_DATA;
2118 outargflags |= FUSE_DO_READDIRPLUS;
2120 outargflags |= FUSE_READDIRPLUS_AUTO;
2122 outargflags |= FUSE_ASYNC_DIO;
2124 outargflags |= FUSE_WRITEBACK_CACHE;
2126 outargflags |= FUSE_POSIX_ACL;
2128 outargflags |= FUSE_CACHE_SYMLINKS;
2130 outargflags |= FUSE_EXPLICIT_INVAL_DATA;
2132 if (inargflags & FUSE_INIT_EXT) {
2133 outargflags |= FUSE_INIT_EXT;
2134 outarg.flags2 = outargflags >> 32;
2137 outarg.flags = outargflags;
2139 outarg.max_readahead = se->conn.max_readahead;
2140 outarg.max_write = se->conn.max_write;
2141 if (se->conn.proto_minor >= 13) {
2142 if (se->conn.max_background >= (1 << 16))
2143 se->conn.max_background = (1 << 16) - 1;
2144 if (se->conn.congestion_threshold > se->conn.max_background)
2145 se->conn.congestion_threshold = se->conn.max_background;
2146 if (!se->conn.congestion_threshold) {
2147 se->conn.congestion_threshold =
2148 se->conn.max_background * 3 / 4;
2151 outarg.max_background = se->conn.max_background;
2152 outarg.congestion_threshold = se->conn.congestion_threshold;
2154 if (se->conn.proto_minor >= 23)
2155 outarg.time_gran = se->conn.time_gran;
2158 fuse_log(FUSE_LOG_DEBUG,
" INIT: %u.%u\n", outarg.major, outarg.minor);
2159 fuse_log(FUSE_LOG_DEBUG,
" flags=0x%08x\n", outarg.flags);
2160 fuse_log(FUSE_LOG_DEBUG,
" max_readahead=0x%08x\n",
2161 outarg.max_readahead);
2162 fuse_log(FUSE_LOG_DEBUG,
" max_write=0x%08x\n", outarg.max_write);
2163 fuse_log(FUSE_LOG_DEBUG,
" max_background=%i\n",
2164 outarg.max_background);
2165 fuse_log(FUSE_LOG_DEBUG,
" congestion_threshold=%i\n",
2166 outarg.congestion_threshold);
2167 fuse_log(FUSE_LOG_DEBUG,
" time_gran=%u\n",
2171 outargsize = FUSE_COMPAT_INIT_OUT_SIZE;
2172 else if (arg->minor < 23)
2173 outargsize = FUSE_COMPAT_22_INIT_OUT_SIZE;
2175 send_reply_ok(req, &outarg, outargsize);
2180 struct fuse_session *se = req->se;
2185 se->got_destroy = 1;
2187 se->op.destroy(se->userdata);
2189 send_reply_ok(req, NULL, 0);
2192 static void list_del_nreq(
struct fuse_notify_req *nreq)
2194 struct fuse_notify_req *prev = nreq->prev;
2195 struct fuse_notify_req *next = nreq->next;
2200 static void list_add_nreq(
struct fuse_notify_req *nreq,
2201 struct fuse_notify_req *next)
2203 struct fuse_notify_req *prev = next->prev;
2210 static void list_init_nreq(
struct fuse_notify_req *nreq)
2217 const void *inarg,
const struct fuse_buf *buf)
2219 struct fuse_session *se = req->se;
2220 struct fuse_notify_req *nreq;
2221 struct fuse_notify_req *head;
2223 pthread_mutex_lock(&se->lock);
2224 head = &se->notify_list;
2225 for (nreq = head->next; nreq != head; nreq = nreq->next) {
2226 if (nreq->unique == req->unique) {
2227 list_del_nreq(nreq);
2231 pthread_mutex_unlock(&se->lock);
2234 nreq->reply(nreq, req, nodeid, inarg, buf);
2237 static int send_notify_iov(
struct fuse_session *se,
int notify_code,
2238 struct iovec *iov,
int count)
2240 struct fuse_out_header out;
2246 out.error = notify_code;
2247 iov[0].iov_base = &out;
2248 iov[0].iov_len =
sizeof(
struct fuse_out_header);
2250 return fuse_send_msg(se, NULL, iov, count);
2256 struct fuse_notify_poll_wakeup_out outarg;
2257 struct iovec iov[2];
2261 iov[1].iov_base = &outarg;
2262 iov[1].iov_len =
sizeof(outarg);
2264 return send_notify_iov(ph->se, FUSE_NOTIFY_POLL, iov, 2);
2271 off_t off, off_t len)
2273 struct fuse_notify_inval_inode_out outarg;
2274 struct iovec iov[2];
2279 if (se->conn.proto_minor < 12)
2286 iov[1].iov_base = &outarg;
2287 iov[1].iov_len =
sizeof(outarg);
2289 return send_notify_iov(se, FUSE_NOTIFY_INVAL_INODE, iov, 2);
2293 const char *name,
size_t namelen,
2296 struct fuse_notify_inval_entry_out outarg;
2297 struct iovec iov[3];
2302 if (se->conn.proto_minor < 12)
2305 outarg.parent = parent;
2306 outarg.namelen = namelen;
2308 if (flags & FUSE_LL_EXPIRE_ONLY)
2309 outarg.flags |= FUSE_EXPIRE_ONLY;
2311 iov[1].iov_base = &outarg;
2312 iov[1].iov_len =
sizeof(outarg);
2313 iov[2].iov_base = (
void *)name;
2314 iov[2].iov_len = namelen + 1;
2316 return send_notify_iov(se, FUSE_NOTIFY_INVAL_ENTRY, iov, 3);
2320 const char *name,
size_t namelen)
2328 const char *name,
size_t namelen)
2330 struct fuse_notify_delete_out outarg;
2331 struct iovec iov[3];
2336 if (se->conn.proto_minor < 18)
2339 outarg.parent = parent;
2340 outarg.child = child;
2341 outarg.namelen = namelen;
2344 iov[1].iov_base = &outarg;
2345 iov[1].iov_len =
sizeof(outarg);
2346 iov[2].iov_base = (
void *)name;
2347 iov[2].iov_len = namelen + 1;
2349 return send_notify_iov(se, FUSE_NOTIFY_DELETE, iov, 3);
2356 struct fuse_out_header out;
2357 struct fuse_notify_store_out outarg;
2358 struct iovec iov[3];
2365 if (se->conn.proto_minor < 15)
2369 out.error = FUSE_NOTIFY_STORE;
2371 outarg.nodeid = ino;
2372 outarg.offset = offset;
2376 iov[0].iov_base = &out;
2377 iov[0].iov_len =
sizeof(out);
2378 iov[1].iov_base = &outarg;
2379 iov[1].iov_len =
sizeof(outarg);
2381 res = fuse_send_data_iov(se, NULL, iov, 2, bufv, flags);
2388 struct fuse_retrieve_req {
2389 struct fuse_notify_req nreq;
2393 static void fuse_ll_retrieve_reply(
struct fuse_notify_req *nreq,
2398 struct fuse_session *se = req->se;
2399 struct fuse_retrieve_req *rreq =
2400 container_of(nreq,
struct fuse_retrieve_req, nreq);
2401 const struct fuse_notify_retrieve_in *arg = inarg;
2408 bufv.
buf[0].
mem = PARAM(arg);
2410 bufv.
buf[0].
size -=
sizeof(
struct fuse_in_header) +
2411 sizeof(struct fuse_notify_retrieve_in);
2413 if (bufv.
buf[0].
size < arg->size) {
2414 fuse_log(FUSE_LOG_ERR,
"fuse: retrieve reply: buffer size too small\n");
2420 if (se->op.retrieve_reply) {
2421 se->op.retrieve_reply(req, rreq->cookie, ino,
2422 arg->offset, &bufv);
2429 fuse_ll_clear_pipe(se);
2433 size_t size, off_t offset,
void *cookie)
2435 struct fuse_notify_retrieve_out outarg;
2436 struct iovec iov[2];
2437 struct fuse_retrieve_req *rreq;
2443 if (se->conn.proto_minor < 15)
2446 rreq = malloc(
sizeof(*rreq));
2450 pthread_mutex_lock(&se->lock);
2451 rreq->cookie = cookie;
2452 rreq->nreq.unique = se->notify_ctr++;
2453 rreq->nreq.reply = fuse_ll_retrieve_reply;
2454 list_add_nreq(&rreq->nreq, &se->notify_list);
2455 pthread_mutex_unlock(&se->lock);
2457 outarg.notify_unique = rreq->nreq.unique;
2458 outarg.nodeid = ino;
2459 outarg.offset = offset;
2463 iov[1].iov_base = &outarg;
2464 iov[1].iov_len =
sizeof(outarg);
2466 err = send_notify_iov(se, FUSE_NOTIFY_RETRIEVE, iov, 2);
2468 pthread_mutex_lock(&se->lock);
2469 list_del_nreq(&rreq->nreq);
2470 pthread_mutex_unlock(&se->lock);
2479 return req->se->userdata;
2490 pthread_mutex_lock(&req->lock);
2491 pthread_mutex_lock(&req->se->lock);
2492 req->u.ni.func = func;
2493 req->u.ni.data = data;
2494 pthread_mutex_unlock(&req->se->lock);
2495 if (req->interrupted && func)
2497 pthread_mutex_unlock(&req->lock);
2504 pthread_mutex_lock(&req->se->lock);
2505 interrupted = req->interrupted;
2506 pthread_mutex_unlock(&req->se->lock);
2515 [FUSE_LOOKUP] = { do_lookup,
"LOOKUP" },
2516 [FUSE_FORGET] = { do_forget,
"FORGET" },
2517 [FUSE_GETATTR] = { do_getattr,
"GETATTR" },
2518 [FUSE_SETATTR] = { do_setattr,
"SETATTR" },
2519 [FUSE_READLINK] = { do_readlink,
"READLINK" },
2520 [FUSE_SYMLINK] = { do_symlink,
"SYMLINK" },
2521 [FUSE_MKNOD] = { do_mknod,
"MKNOD" },
2522 [FUSE_MKDIR] = { do_mkdir,
"MKDIR" },
2523 [FUSE_UNLINK] = { do_unlink,
"UNLINK" },
2524 [FUSE_RMDIR] = { do_rmdir,
"RMDIR" },
2525 [FUSE_RENAME] = { do_rename,
"RENAME" },
2526 [FUSE_LINK] = { do_link,
"LINK" },
2527 [FUSE_OPEN] = { do_open,
"OPEN" },
2528 [FUSE_READ] = { do_read,
"READ" },
2529 [FUSE_WRITE] = { do_write,
"WRITE" },
2530 [FUSE_STATFS] = { do_statfs,
"STATFS" },
2531 [FUSE_RELEASE] = { do_release,
"RELEASE" },
2532 [FUSE_FSYNC] = { do_fsync,
"FSYNC" },
2533 [FUSE_SETXATTR] = { do_setxattr,
"SETXATTR" },
2534 [FUSE_GETXATTR] = { do_getxattr,
"GETXATTR" },
2535 [FUSE_LISTXATTR] = { do_listxattr,
"LISTXATTR" },
2536 [FUSE_REMOVEXATTR] = { do_removexattr,
"REMOVEXATTR" },
2537 [FUSE_FLUSH] = { do_flush,
"FLUSH" },
2538 [FUSE_INIT] = { do_init,
"INIT" },
2539 [FUSE_OPENDIR] = { do_opendir,
"OPENDIR" },
2540 [FUSE_READDIR] = { do_readdir,
"READDIR" },
2541 [FUSE_RELEASEDIR] = { do_releasedir,
"RELEASEDIR" },
2542 [FUSE_FSYNCDIR] = { do_fsyncdir,
"FSYNCDIR" },
2543 [FUSE_GETLK] = { do_getlk,
"GETLK" },
2544 [FUSE_SETLK] = { do_setlk,
"SETLK" },
2545 [FUSE_SETLKW] = { do_setlkw,
"SETLKW" },
2546 [FUSE_ACCESS] = { do_access,
"ACCESS" },
2547 [FUSE_CREATE] = { do_create,
"CREATE" },
2548 [FUSE_INTERRUPT] = { do_interrupt,
"INTERRUPT" },
2549 [FUSE_BMAP] = { do_bmap,
"BMAP" },
2550 [FUSE_IOCTL] = { do_ioctl,
"IOCTL" },
2551 [FUSE_POLL] = { do_poll,
"POLL" },
2552 [FUSE_FALLOCATE] = { do_fallocate,
"FALLOCATE" },
2553 [FUSE_DESTROY] = { do_destroy,
"DESTROY" },
2554 [FUSE_NOTIFY_REPLY] = { (
void *) 1,
"NOTIFY_REPLY" },
2555 [FUSE_BATCH_FORGET] = { do_batch_forget,
"BATCH_FORGET" },
2556 [FUSE_READDIRPLUS] = { do_readdirplus,
"READDIRPLUS"},
2557 [FUSE_RENAME2] = { do_rename2,
"RENAME2" },
2558 [FUSE_COPY_FILE_RANGE] = { do_copy_file_range,
"COPY_FILE_RANGE" },
2559 [FUSE_LSEEK] = { do_lseek,
"LSEEK" },
2560 [CUSE_INIT] = { cuse_lowlevel_init,
"CUSE_INIT" },
2563 #define FUSE_MAXOP (sizeof(fuse_ll_ops) / sizeof(fuse_ll_ops[0]))
2565 static const char *opname(
enum fuse_opcode opcode)
2567 if (opcode >= FUSE_MAXOP || !fuse_ll_ops[opcode].name)
2570 return fuse_ll_ops[opcode].name;
2573 static int fuse_ll_copy_from_pipe(
struct fuse_bufvec *dst,
2578 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n", strerror(-res));
2582 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: short read\n");
2591 fuse_session_process_buf_int(se, buf, NULL);
2594 void fuse_session_process_buf_int(
struct fuse_session *se,
2595 const struct fuse_buf *buf,
struct fuse_chan *ch)
2597 const size_t write_header_size =
sizeof(
struct fuse_in_header) +
2598 sizeof(struct fuse_write_in);
2600 struct fuse_bufvec tmpbuf = FUSE_BUFVEC_INIT(write_header_size);
2601 struct fuse_in_header *in;
2603 struct fuse_req *req;
2612 mbuf = malloc(tmpbuf.
buf[0].
size);
2614 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate header\n");
2617 tmpbuf.
buf[0].
mem = mbuf;
2619 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
2630 "unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n",
2631 (
unsigned long long) in->unique,
2632 opname((
enum fuse_opcode) in->opcode), in->opcode,
2633 (
unsigned long long) in->nodeid, buf->
size, in->pid);
2636 req = fuse_ll_alloc_req(se);
2638 struct fuse_out_header out = {
2639 .unique = in->unique,
2642 struct iovec iov = {
2644 .iov_len =
sizeof(
struct fuse_out_header),
2647 fuse_send_msg(se, ch, &iov, 1);
2651 req->unique = in->unique;
2652 req->ctx.uid = in->uid;
2653 req->ctx.gid = in->gid;
2654 req->ctx.pid = in->pid;
2655 req->ch = ch ? fuse_chan_get(ch) : NULL;
2658 if (!se->got_init) {
2659 enum fuse_opcode expected;
2661 expected = se->cuse_data ? CUSE_INIT : FUSE_INIT;
2662 if (in->opcode != expected)
2664 }
else if (in->opcode == FUSE_INIT || in->opcode == CUSE_INIT)
2669 if (se->deny_others && in->uid != se->owner && in->uid != 0 &&
2670 in->opcode != FUSE_INIT && in->opcode != FUSE_READ &&
2671 in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC &&
2672 in->opcode != FUSE_RELEASE && in->opcode != FUSE_READDIR &&
2673 in->opcode != FUSE_FSYNCDIR && in->opcode != FUSE_RELEASEDIR &&
2674 in->opcode != FUSE_NOTIFY_REPLY &&
2675 in->opcode != FUSE_READDIRPLUS)
2679 if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func)
2681 if (in->opcode != FUSE_INTERRUPT) {
2682 struct fuse_req *intr;
2683 pthread_mutex_lock(&se->lock);
2684 intr = check_interrupt(se, req);
2685 list_add_req(req, &se->list);
2686 pthread_mutex_unlock(&se->lock);
2692 (in->opcode != FUSE_WRITE || !se->op.write_buf) &&
2693 in->opcode != FUSE_NOTIFY_REPLY) {
2697 newmbuf = realloc(mbuf, buf->
size);
2698 if (newmbuf == NULL)
2702 tmpbuf = FUSE_BUFVEC_INIT(buf->
size - write_header_size);
2703 tmpbuf.
buf[0].
mem = (
char *)mbuf + write_header_size;
2705 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
2713 inarg = (
void *) &in[1];
2714 if (in->opcode == FUSE_WRITE && se->op.write_buf)
2715 do_write_buf(req, in->nodeid, inarg, buf);
2716 else if (in->opcode == FUSE_NOTIFY_REPLY)
2717 do_notify_reply(req, in->nodeid, inarg, buf);
2719 fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
2729 fuse_ll_clear_pipe(se);
2733 #define LL_OPTION(n,o,v) \
2734 { n, offsetof(struct fuse_session, o), v }
2736 static const struct fuse_opt fuse_ll_opts[] = {
2737 LL_OPTION(
"debug", debug, 1),
2738 LL_OPTION(
"-d", debug, 1),
2739 LL_OPTION(
"--debug", debug, 1),
2740 LL_OPTION(
"allow_root", deny_others, 1),
2746 printf(
"using FUSE kernel interface version %i.%i\n",
2747 FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
2748 fuse_mount_version();
2756 " -o allow_other allow access by all users\n"
2757 " -o allow_root allow access by root\n"
2758 " -o auto_unmount auto unmount on process termination\n");
2763 struct fuse_ll_pipe *llp;
2765 if (se->got_init && !se->got_destroy) {
2767 se->op.destroy(se->userdata);
2769 llp = pthread_getspecific(se->pipe_key);
2771 fuse_ll_pipe_free(llp);
2772 pthread_key_delete(se->pipe_key);
2773 pthread_mutex_destroy(&se->lock);
2774 free(se->cuse_data);
2779 destroy_mount_opts(se->mo);
2784 static void fuse_ll_pipe_destructor(
void *data)
2786 struct fuse_ll_pipe *llp = data;
2787 fuse_ll_pipe_free(llp);
2792 return fuse_session_receive_buf_int(se, buf, NULL);
2795 int fuse_session_receive_buf_int(
struct fuse_session *se,
struct fuse_buf *buf,
2796 struct fuse_chan *ch)
2801 size_t bufsize = se->bufsize;
2802 struct fuse_ll_pipe *llp;
2808 llp = fuse_ll_get_pipe(se);
2812 if (llp->size < bufsize) {
2813 if (llp->can_grow) {
2814 res = fcntl(llp->pipe[0], F_SETPIPE_SZ, bufsize);
2817 res = grow_pipe_to_max(llp->pipe[0]);
2824 if (llp->size < bufsize)
2828 if (se->io != NULL && se->io->splice_receive != NULL) {
2829 res = se->io->splice_receive(ch ? ch->fd : se->fd, NULL,
2830 llp->pipe[1], NULL, bufsize, 0,
2833 res = splice(ch ? ch->fd : se->fd, NULL, llp->pipe[1], NULL,
2842 if (err == ENODEV) {
2848 if (err != EINTR && err != EAGAIN)
2849 perror(
"fuse: splice from device");
2853 if (res <
sizeof(
struct fuse_in_header)) {
2854 fuse_log(FUSE_LOG_ERR,
"short splice from fuse device\n");
2869 if (res <
sizeof(
struct fuse_in_header) +
2870 sizeof(
struct fuse_write_in) + pagesize) {
2875 buf->
mem = malloc(se->bufsize);
2878 "fuse: failed to allocate read buffer\n");
2888 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: %s\n",
2890 fuse_ll_clear_pipe(se);
2893 if (res < tmpbuf.size) {
2894 fuse_log(FUSE_LOG_ERR,
"fuse: copy from pipe: short read\n");
2895 fuse_ll_clear_pipe(se);
2898 assert(res == tmpbuf.size);
2902 buf->
fd = tmpbuf.fd;
2912 buf->
mem = malloc(se->bufsize);
2915 "fuse: failed to allocate read buffer\n");
2921 if (se->io != NULL) {
2924 res = se->io->read(ch ? ch->fd : se->fd,
buf->
mem, se->bufsize,
2927 res = read(ch ? ch->fd : se->fd,
buf->
mem, se->bufsize);
2939 if (err == ENODEV) {
2948 if (err != EINTR && err != EAGAIN)
2949 perror(
"fuse: reading device");
2952 if ((
size_t) res <
sizeof(
struct fuse_in_header)) {
2953 fuse_log(FUSE_LOG_ERR,
"short read on fuse device\n");
2964 size_t op_size,
void *userdata)
2967 struct fuse_session *se;
2968 struct mount_opts *mo;
2971 fuse_log(FUSE_LOG_ERR,
"fuse: warning: library too old, some operations may not work\n");
2975 if (args->
argc == 0) {
2976 fuse_log(FUSE_LOG_ERR,
"fuse: empty argv passed to fuse_session_new().\n");
2980 se = (
struct fuse_session *) calloc(1,
sizeof(
struct fuse_session));
2982 fuse_log(FUSE_LOG_ERR,
"fuse: failed to allocate fuse object\n");
2986 se->conn.max_write = UINT_MAX;
2987 se->conn.max_readahead = UINT_MAX;
2992 if(se->deny_others) {
3002 mo = parse_mount_opts(args);
3006 if(args->
argc == 1 &&
3007 args->
argv[0][0] ==
'-') {
3008 fuse_log(FUSE_LOG_ERR,
"fuse: warning: argv[0] looks like an option, but "
3009 "will be ignored\n");
3010 }
else if (args->
argc != 1) {
3012 fuse_log(FUSE_LOG_ERR,
"fuse: unknown option(s): `");
3013 for(i = 1; i < args->
argc-1; i++)
3020 fuse_log(FUSE_LOG_DEBUG,
"FUSE library version: %s\n", PACKAGE_VERSION);
3022 se->bufsize = FUSE_MAX_MAX_PAGES * getpagesize() +
3023 FUSE_BUFFER_HEADER_SIZE;
3025 list_init_req(&se->list);
3026 list_init_req(&se->interrupts);
3027 list_init_nreq(&se->notify_list);
3029 pthread_mutex_init(&se->lock, NULL);
3031 err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor);
3033 fuse_log(FUSE_LOG_ERR,
"fuse: failed to create thread specific key: %s\n",
3038 memcpy(&se->op, op, op_size);
3039 se->owner = getuid();
3040 se->userdata = userdata;
3046 pthread_mutex_destroy(&se->lock);
3051 destroy_mount_opts(mo);
3062 fuse_log(FUSE_LOG_ERR,
"Invalid file descriptor value %d passed to "
3063 "fuse_session_custom_io()\n", fd);
3067 fuse_log(FUSE_LOG_ERR,
"No custom IO passed to "
3068 "fuse_session_custom_io()\n");
3070 }
else if (io->read == NULL || io->writev == NULL) {
3075 fuse_log(FUSE_LOG_ERR,
"io passed to fuse_session_custom_io() must "
3076 "implement both io->read() and io->writev\n");
3080 se->io = malloc(
sizeof(
struct fuse_custom_io));
3081 if (se->io == NULL) {
3082 fuse_log(FUSE_LOG_ERR,
"Failed to allocate memory for custom io. "
3083 "Error: %s\n", strerror(errno));
3101 fd = open(
"/dev/null", O_RDWR);
3104 }
while (fd >= 0 && fd <= 2);
3112 fd = fuse_mnt_parse_fuse_fd(mountpoint);
3114 if (fcntl(fd, F_GETFD) == -1) {
3116 "fuse: Invalid file descriptor /dev/fd/%u\n",
3125 fd = fuse_kern_mount(mountpoint, se->mo);
3131 se->mountpoint = strdup(mountpoint);
3132 if (se->mountpoint == NULL)
3138 fuse_kern_unmount(mountpoint, fd);
3149 if (se->mountpoint != NULL) {
3150 fuse_kern_unmount(se->mountpoint, se->fd);
3152 free(se->mountpoint);
3153 se->mountpoint = NULL;
3161 size_t bufsize = 1024;
3165 unsigned long pid = req->ctx.pid;
3168 sprintf(path,
"/proc/%lu/task/%lu/status", pid, pid);
3171 buf = malloc(bufsize);
3176 fd = open(path, O_RDONLY);
3180 ret = read(fd, buf, bufsize);
3187 if ((
size_t)ret == bufsize) {
3194 s = strstr(buf,
"\nGroups:");
3202 unsigned long val = strtoul(s, &end, 0);
3222 (void) req; (void) size; (void) list;
3229 __attribute__((no_sanitize_thread))
3235 __attribute__((no_sanitize_thread))
3242 __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