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         pthread_mutex_destroy(&req->lock);
   133         struct fuse_session *se = req->se;
   135         pthread_mutex_lock(&se->lock);
   136         req->u.ni.func = NULL;
   137         req->u.ni.data = NULL;
   140         fuse_chan_put(req->ch);
   142         pthread_mutex_unlock(&se->lock);
   147 static struct fuse_req *fuse_ll_alloc_req(
struct fuse_session *se)
   149         struct fuse_req *req;
   151         req = (
struct fuse_req *) calloc(1, 
sizeof(
struct fuse_req));
   153                 fuse_log(FUSE_LOG_ERR, 
"fuse: failed to allocate request\n");
   158                 fuse_mutex_init(&req->lock);
   165 static int fuse_send_msg(
struct fuse_session *se, 
struct fuse_chan *ch,
   166                          struct iovec *iov, 
int count)
   168         struct fuse_out_header *out = iov[0].iov_base;
   170         out->len = iov_length(iov, count);
   172                 if (out->unique == 0) {
   173                         fuse_log(FUSE_LOG_DEBUG, 
"NOTIFY: code=%d length=%u\n",
   174                                 out->error, out->len);
   175                 } 
else if (out->error) {
   177                                 "   unique: %llu, error: %i (%s), outsize: %i\n",
   178                                 (
unsigned long long) out->unique, out->error,
   179                                 strerror(-out->error), out->len);
   182                                 "   unique: %llu, success, outsize: %i\n",
   183                                 (
unsigned long long) out->unique, out->len);
   187         ssize_t res = writev(ch ? ch->fd : se->fd,
   196                         perror(
"fuse: writing device");
   204 int fuse_send_reply_iov_nofree(
fuse_req_t req, 
int error, 
struct iovec *iov,
   207         struct fuse_out_header out;
   209         if (error <= -1000 || error > 0) {
   210                 fuse_log(FUSE_LOG_ERR, 
"fuse: bad error value: %i\n",   error);
   214         out.unique = req->unique;
   217         iov[0].iov_base = &out;
   218         iov[0].iov_len = 
sizeof(
struct fuse_out_header);
   220         return fuse_send_msg(req->se, req->ch, iov, count);
   223 static int send_reply_iov(
fuse_req_t req, 
int error, 
struct iovec *iov,
   228         res = fuse_send_reply_iov_nofree(req, error, iov, count);
   233 static int send_reply(
fuse_req_t req, 
int error, 
const void *arg,
   239                 iov[1].iov_base = (
void *) arg;
   240                 iov[1].iov_len = argsize;
   243         return send_reply_iov(req, error, iov, count);
   249         struct iovec *padded_iov;
   251         padded_iov = malloc((count + 1) * 
sizeof(
struct iovec));
   252         if (padded_iov == NULL)
   255         memcpy(padded_iov + 1, iov, count * 
sizeof(
struct iovec));
   258         res = send_reply_iov(req, 0, padded_iov, count);
   268                          const char *name, 
const struct stat *stbuf, off_t off)
   273         size_t entlen_padded;
   274         struct fuse_dirent *dirent;
   276         namelen = strlen(name);
   277         entlen = FUSE_NAME_OFFSET + namelen;
   278         entlen_padded = FUSE_DIRENT_ALIGN(entlen);
   280         if ((buf == NULL) || (entlen_padded > bufsize))
   281           return entlen_padded;
   283         dirent = (
struct fuse_dirent*) buf;
   284         dirent->ino = stbuf->st_ino;
   286         dirent->namelen = namelen;
   287         dirent->type = (stbuf->st_mode & S_IFMT) >> 12;
   288         memcpy(dirent->name, name, namelen);
   289         memset(dirent->name + namelen, 0, entlen_padded - entlen);
   291         return entlen_padded;
   294 static void convert_statfs(
const struct statvfs *stbuf,
   295                            struct fuse_kstatfs *kstatfs)
   297         kstatfs->bsize   = stbuf->f_bsize;
   298         kstatfs->frsize  = stbuf->f_frsize;
   299         kstatfs->blocks  = stbuf->f_blocks;
   300         kstatfs->bfree   = stbuf->f_bfree;
   301         kstatfs->bavail  = stbuf->f_bavail;
   302         kstatfs->files   = stbuf->f_files;
   303         kstatfs->ffree   = stbuf->f_ffree;
   304         kstatfs->namelen = stbuf->f_namemax;
   307 static int send_reply_ok(
fuse_req_t req, 
const void *arg, 
size_t argsize)
   309         return send_reply(req, 0, arg, argsize);
   314         return send_reply(req, -err, NULL, 0);
   322 static unsigned long calc_timeout_sec(
double t)
   324         if (t > (
double) ULONG_MAX)
   329                 return (
unsigned long) t;
   332 static unsigned int calc_timeout_nsec(
double t)
   334         double f = t - (double) calc_timeout_sec(t);
   337         else if (f >= 0.999999999)
   340                 return (
unsigned int) (f * 1.0e9);
   343 static void fill_entry(
struct fuse_entry_out *arg,
   346         arg->nodeid = e->
ino;
   351         arg->attr_valid_nsec = calc_timeout_nsec(e->
attr_timeout);
   352         convert_stat(&e->
attr, &arg->attr);
   364         size_t entlen_padded;
   366         namelen = strlen(name);
   367         entlen = FUSE_NAME_OFFSET_DIRENTPLUS + namelen;
   368         entlen_padded = FUSE_DIRENT_ALIGN(entlen);
   369         if ((buf == NULL) || (entlen_padded > bufsize))
   370           return entlen_padded;
   372         struct fuse_direntplus *dp = (
struct fuse_direntplus *) buf;
   373         memset(&dp->entry_out, 0, 
sizeof(dp->entry_out));
   374         fill_entry(&dp->entry_out, e);
   376         struct fuse_dirent *dirent = &dp->dirent;
   377         dirent->ino = e->
attr.st_ino;
   379         dirent->namelen = namelen;
   380         dirent->type = (e->
attr.st_mode & S_IFMT) >> 12;
   381         memcpy(dirent->name, name, namelen);
   382         memset(dirent->name + namelen, 0, entlen_padded - entlen);
   384         return entlen_padded;
   387 static void fill_open(
struct fuse_open_out *arg,
   392                 arg->open_flags |= FOPEN_DIRECT_IO;
   394                 arg->open_flags |= FOPEN_KEEP_CACHE;
   396                 arg->open_flags |= FOPEN_CACHE_DIR;
   398                 arg->open_flags |= FOPEN_NONSEEKABLE;
   403         struct fuse_entry_out arg;
   404         size_t size = req->se->conn.proto_minor < 9 ?
   405                 FUSE_COMPAT_ENTRY_OUT_SIZE : 
sizeof(arg);
   409         if (!e->
ino && req->se->conn.proto_minor < 4)
   412         memset(&arg, 0, 
sizeof(arg));
   414         return send_reply_ok(req, &arg, size);
   420         char buf[
sizeof(
struct fuse_entry_out) + sizeof(struct fuse_open_out)];
   421         size_t entrysize = req->se->conn.proto_minor < 9 ?
   422                 FUSE_COMPAT_ENTRY_OUT_SIZE : 
sizeof(
struct fuse_entry_out);
   423         struct fuse_entry_out *earg = (
struct fuse_entry_out *) buf;
   424         struct fuse_open_out *oarg = (
struct fuse_open_out *) (buf + entrysize);
   426         memset(buf, 0, 
sizeof(buf));
   429         return send_reply_ok(req, buf,
   430                              entrysize + 
sizeof(
struct fuse_open_out));
   436         struct fuse_attr_out arg;
   437         size_t size = req->se->conn.proto_minor < 9 ?
   438                 FUSE_COMPAT_ATTR_OUT_SIZE : 
sizeof(arg);
   440         memset(&arg, 0, 
sizeof(arg));
   441         arg.attr_valid = calc_timeout_sec(attr_timeout);
   442         arg.attr_valid_nsec = calc_timeout_nsec(attr_timeout);
   443         convert_stat(attr, &arg.attr);
   445         return send_reply_ok(req, &arg, size);
   450         return send_reply_ok(req, linkname, strlen(linkname));
   455         struct fuse_open_out arg;
   457         memset(&arg, 0, 
sizeof(arg));
   459         return send_reply_ok(req, &arg, 
sizeof(arg));
   464         struct fuse_write_out arg;
   466         memset(&arg, 0, 
sizeof(arg));
   469         return send_reply_ok(req, &arg, 
sizeof(arg));
   474         return send_reply_ok(req, buf, size);
   477 static int fuse_send_data_iov_fallback(
struct fuse_session *se,
   478                                        struct fuse_chan *ch,
   479                                        struct iovec *iov, 
int iov_count,
   483         struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
   488         if (buf->
count == 1 && buf->
idx == 0 && buf->
off == 0 &&
   493                 iov[iov_count].iov_base = buf->
buf[0].
mem;
   494                 iov[iov_count].iov_len = len;
   496                 return fuse_send_msg(se, ch, iov, iov_count);
   499         res = posix_memalign(&mbuf, pagesize, len);
   503         mem_buf.
buf[0].
mem = mbuf;
   511         iov[iov_count].iov_base = mbuf;
   512         iov[iov_count].iov_len = len;
   514         res = fuse_send_msg(se, ch, iov, iov_count);
   520 struct fuse_ll_pipe {
   526 static void fuse_ll_pipe_free(
struct fuse_ll_pipe *llp)
   534 #if !defined(HAVE_PIPE2) || !defined(O_CLOEXEC)   535 static int fuse_pipe(
int fds[2])
   542         if (fcntl(fds[0], F_SETFL, O_NONBLOCK) == -1 ||
   543             fcntl(fds[1], F_SETFL, O_NONBLOCK) == -1 ||
   544             fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
   545             fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
   553 static int fuse_pipe(
int fds[2])
   555         return pipe2(fds, O_CLOEXEC | O_NONBLOCK);
   559 static struct fuse_ll_pipe *fuse_ll_get_pipe(
struct fuse_session *se)
   561         struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
   565                 llp = malloc(
sizeof(
struct fuse_ll_pipe));
   569                 res = fuse_pipe(llp->pipe);
   578                 llp->size = pagesize * 16;
   581                 pthread_setspecific(se->pipe_key, llp);
   588 static void fuse_ll_clear_pipe(
struct fuse_session *se)
   590         struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
   592                 pthread_setspecific(se->pipe_key, NULL);
   593                 fuse_ll_pipe_free(llp);
   597 #if defined(HAVE_SPLICE) && defined(HAVE_VMSPLICE)   598 static int read_back(
int fd, 
char *buf, 
size_t len)
   602         res = read(fd, buf, len);
   604                 fuse_log(FUSE_LOG_ERR, 
"fuse: internal error: failed to read back from pipe: %s\n", strerror(errno));
   608                 fuse_log(FUSE_LOG_ERR, 
"fuse: internal error: short read back from pipe: %i from %zi\n", res, len);
   614 static int grow_pipe_to_max(
int pipefd)
   621         maxfd = open(
"/proc/sys/fs/pipe-max-size", O_RDONLY);
   625         res = read(maxfd, buf, 
sizeof(buf) - 1);
   637         res = fcntl(pipefd, F_SETPIPE_SZ, max);
   643 static int fuse_send_data_iov(
struct fuse_session *se, 
struct fuse_chan *ch,
   644                                struct iovec *iov, 
int iov_count,
   649         struct fuse_out_header *out = iov[0].iov_base;
   650         struct fuse_ll_pipe *llp;
   653         size_t total_fd_size;
   656         struct fuse_bufvec pipe_buf = FUSE_BUFVEC_INIT(len);
   658         if (se->broken_splice_nonblock)
   665         for (idx = buf->
idx; idx < buf->count; idx++) {
   669                                 total_fd_size -= buf->
off;
   672         if (total_fd_size < 2 * pagesize)
   675         if (se->conn.proto_minor < 14 ||
   679         llp = fuse_ll_get_pipe(se);
   684         headerlen = iov_length(iov, iov_count);
   686         out->len = headerlen + len;
   692         pipesize = pagesize * (iov_count + buf->
count + 1) + out->len;
   694         if (llp->size < pipesize) {
   696                         res = fcntl(llp->pipe[0], F_SETPIPE_SZ, pipesize);
   698                                 res = grow_pipe_to_max(llp->pipe[0]);
   706                 if (llp->size < pipesize)
   711         res = vmsplice(llp->pipe[1], iov, iov_count, SPLICE_F_NONBLOCK);
   715         if (res != headerlen) {
   717                 fuse_log(FUSE_LOG_ERR, 
"fuse: short vmsplice to pipe: %u/%zu\n", res,
   723         pipe_buf.
buf[0].
fd = llp->pipe[1];
   728                 if (res == -EAGAIN || res == -EINVAL) {
   740                                 se->broken_splice_nonblock = 1;
   742                         pthread_setspecific(se->pipe_key, NULL);
   743                         fuse_ll_pipe_free(llp);
   750         if (res != 0 && res < len) {
   751                 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
   753                 size_t now_len = res;
   763                 res = posix_memalign(&mbuf, pagesize, len);
   767                 mem_buf.
buf[0].
mem = mbuf;
   768                 mem_buf.
off = now_len;
   772                         size_t extra_len = res;
   778                         tmpbuf = malloc(headerlen);
   779                         if (tmpbuf == NULL) {
   784                         res = read_back(llp->pipe[0], tmpbuf, headerlen);
   790                         res = read_back(llp->pipe[0], mbuf, now_len);
   795                         len = now_len + extra_len;
   796                         iov[iov_count].iov_base = mbuf;
   797                         iov[iov_count].iov_len = len;
   799                         res = fuse_send_msg(se, ch, iov, iov_count);
   807         out->len = headerlen + len;
   811                         "   unique: %llu, success, outsize: %i (splice)\n",
   812                         (
unsigned long long) out->unique, out->len);
   818                 splice_flags |= SPLICE_F_MOVE;
   820         res = splice(llp->pipe[0], NULL, ch ? ch->fd : se->fd,
   821                      NULL, out->len, splice_flags);
   824                 perror(
"fuse: splice from pipe");
   827         if (res != out->len) {
   829                 fuse_log(FUSE_LOG_ERR, 
"fuse: short splice from pipe: %u/%u\n",
   836         fuse_ll_clear_pipe(se);
   840         return fuse_send_data_iov_fallback(se, ch, iov, iov_count, buf, len);
   843 static int fuse_send_data_iov(
struct fuse_session *se, 
struct fuse_chan *ch,
   844                                struct iovec *iov, 
int iov_count,
   850         return fuse_send_data_iov_fallback(se, ch, iov, iov_count, buf, len);
   858         struct fuse_out_header out;
   861         iov[0].iov_base = &out;
   862         iov[0].iov_len = 
sizeof(
struct fuse_out_header);
   864         out.unique = req->unique;
   867         res = fuse_send_data_iov(req->se, req->ch, iov, 1, bufv, flags);
   878         struct fuse_statfs_out arg;
   879         size_t size = req->se->conn.proto_minor < 4 ?
   880                 FUSE_COMPAT_STATFS_SIZE : 
sizeof(arg);
   882         memset(&arg, 0, 
sizeof(arg));
   883         convert_statfs(stbuf, &arg.st);
   885         return send_reply_ok(req, &arg, size);
   890         struct fuse_getxattr_out arg;
   892         memset(&arg, 0, 
sizeof(arg));
   895         return send_reply_ok(req, &arg, 
sizeof(arg));
   900         struct fuse_lk_out arg;
   902         memset(&arg, 0, 
sizeof(arg));
   903         arg.lk.type = lock->l_type;
   904         if (lock->l_type != F_UNLCK) {
   905                 arg.lk.start = lock->l_start;
   906                 if (lock->l_len == 0)
   907                         arg.lk.end = OFFSET_MAX;
   909                         arg.lk.end = lock->l_start + lock->l_len - 1;
   911         arg.lk.pid = lock->l_pid;
   912         return send_reply_ok(req, &arg, 
sizeof(arg));
   917         struct fuse_bmap_out arg;
   919         memset(&arg, 0, 
sizeof(arg));
   922         return send_reply_ok(req, &arg, 
sizeof(arg));
   925 static struct fuse_ioctl_iovec *fuse_ioctl_iovec_copy(
const struct iovec *iov,
   928         struct fuse_ioctl_iovec *fiov;
   931         fiov = malloc(
sizeof(fiov[0]) * count);
   935         for (i = 0; i < count; i++) {
   936                 fiov[i].base = (uintptr_t) iov[i].iov_base;
   937                 fiov[i].len = iov[i].iov_len;
   944                            const struct iovec *in_iov, 
size_t in_count,
   945                            const struct iovec *out_iov, 
size_t out_count)
   947         struct fuse_ioctl_out arg;
   948         struct fuse_ioctl_iovec *in_fiov = NULL;
   949         struct fuse_ioctl_iovec *out_fiov = NULL;
   954         memset(&arg, 0, 
sizeof(arg));
   955         arg.flags |= FUSE_IOCTL_RETRY;
   956         arg.in_iovs = in_count;
   957         arg.out_iovs = out_count;
   958         iov[count].iov_base = &arg;
   959         iov[count].iov_len = 
sizeof(arg);
   962         if (req->se->conn.proto_minor < 16) {
   964                         iov[count].iov_base = (
void *)in_iov;
   965                         iov[count].iov_len = 
sizeof(in_iov[0]) * in_count;
   970                         iov[count].iov_base = (
void *)out_iov;
   971                         iov[count].iov_len = 
sizeof(out_iov[0]) * out_count;
   976                 if (
sizeof(
void *) == 4 && req->ioctl_64bit) {
   982                         in_fiov = fuse_ioctl_iovec_copy(in_iov, in_count);
   986                         iov[count].iov_base = (
void *)in_fiov;
   987                         iov[count].iov_len = 
sizeof(in_fiov[0]) * in_count;
   991                         out_fiov = fuse_ioctl_iovec_copy(out_iov, out_count);
   995                         iov[count].iov_base = (
void *)out_fiov;
   996                         iov[count].iov_len = 
sizeof(out_fiov[0]) * out_count;
  1001         res = send_reply_iov(req, 0, iov, count);
  1015         struct fuse_ioctl_out arg;
  1016         struct iovec iov[3];
  1019         memset(&arg, 0, 
sizeof(arg));
  1020         arg.result = result;
  1021         iov[count].iov_base = &arg;
  1022         iov[count].iov_len = 
sizeof(arg);
  1026                 iov[count].iov_base = (
char *) buf;
  1027                 iov[count].iov_len = size;
  1031         return send_reply_iov(req, 0, iov, count);
  1037         struct iovec *padded_iov;
  1038         struct fuse_ioctl_out arg;
  1041         padded_iov = malloc((count + 2) * 
sizeof(
struct iovec));
  1042         if (padded_iov == NULL)
  1045         memset(&arg, 0, 
sizeof(arg));
  1046         arg.result = result;
  1047         padded_iov[1].iov_base = &arg;
  1048         padded_iov[1].iov_len = 
sizeof(arg);
  1050         memcpy(&padded_iov[2], iov, count * 
sizeof(
struct iovec));
  1052         res = send_reply_iov(req, 0, padded_iov, count + 2);
  1060         struct fuse_poll_out arg;
  1062         memset(&arg, 0, 
sizeof(arg));
  1063         arg.revents = revents;
  1065         return send_reply_ok(req, &arg, 
sizeof(arg));
  1070         struct fuse_lseek_out arg;
  1072         memset(&arg, 0, 
sizeof(arg));
  1075         return send_reply_ok(req, &arg, 
sizeof(arg));
  1080         char *name = (
char *) inarg;
  1082         if (req->se->op.lookup)
  1083                 req->se->op.lookup(req, nodeid, name);
  1090         struct fuse_forget_in *arg = (
struct fuse_forget_in *) inarg;
  1092         if (req->se->op.forget)
  1093                 req->se->op.forget(req, nodeid, arg->nlookup);
  1101         struct fuse_batch_forget_in *arg = (
void *) inarg;
  1102         struct fuse_forget_one *param = (
void *) PARAM(arg);
  1107         if (req->se->op.forget_multi) {
  1108                 req->se->op.forget_multi(req, arg->count,
  1109                                      (
struct fuse_forget_data *) param);
  1110         } 
else if (req->se->op.forget) {
  1111                 for (i = 0; i < arg->count; i++) {
  1112                         struct fuse_forget_one *forget = ¶m[i];
  1113                         struct fuse_req *dummy_req;
  1115                         dummy_req = fuse_ll_alloc_req(req->se);
  1116                         if (dummy_req == NULL)
  1119                         dummy_req->unique = req->unique;
  1120                         dummy_req->ctx = req->ctx;
  1121                         dummy_req->ch = NULL;
  1123                         req->se->op.forget(dummy_req, forget->nodeid,
  1137         if (req->se->conn.proto_minor >= 9) {
  1138                 struct fuse_getattr_in *arg = (
struct fuse_getattr_in *) inarg;
  1140                 if (arg->getattr_flags & FUSE_GETATTR_FH) {
  1141                         memset(&fi, 0, 
sizeof(fi));
  1147         if (req->se->op.getattr)
  1148                 req->se->op.getattr(req, nodeid, fip);
  1155         struct fuse_setattr_in *arg = (
struct fuse_setattr_in *) inarg;
  1157         if (req->se->op.setattr) {
  1161                 memset(&stbuf, 0, 
sizeof(stbuf));
  1162                 convert_attr(arg, &stbuf);
  1163                 if (arg->valid & FATTR_FH) {
  1164                         arg->valid &= ~FATTR_FH;
  1165                         memset(&fi_store, 0, 
sizeof(fi_store));
  1170                         FUSE_SET_ATTR_MODE      |
  1173                         FUSE_SET_ATTR_SIZE      |
  1174                         FUSE_SET_ATTR_ATIME     |
  1175                         FUSE_SET_ATTR_MTIME     |
  1176                         FUSE_SET_ATTR_ATIME_NOW |
  1177                         FUSE_SET_ATTR_MTIME_NOW |
  1178                         FUSE_SET_ATTR_CTIME;
  1180                 req->se->op.setattr(req, nodeid, &stbuf, arg->valid, fi);
  1187         struct fuse_access_in *arg = (
struct fuse_access_in *) inarg;
  1189         if (req->se->op.access)
  1190                 req->se->op.access(req, nodeid, arg->mask);
  1199         if (req->se->op.readlink)
  1200                 req->se->op.readlink(req, nodeid);
  1207         struct fuse_mknod_in *arg = (
struct fuse_mknod_in *) inarg;
  1208         char *name = PARAM(arg);
  1210         if (req->se->conn.proto_minor >= 12)
  1211                 req->ctx.umask = arg->umask;
  1213                 name = (
char *) inarg + FUSE_COMPAT_MKNOD_IN_SIZE;
  1215         if (req->se->op.mknod)
  1216                 req->se->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
  1223         struct fuse_mkdir_in *arg = (
struct fuse_mkdir_in *) inarg;
  1225         if (req->se->conn.proto_minor >= 12)
  1226                 req->ctx.umask = arg->umask;
  1228         if (req->se->op.mkdir)
  1229                 req->se->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
  1236         char *name = (
char *) inarg;
  1238         if (req->se->op.unlink)
  1239                 req->se->op.unlink(req, nodeid, name);
  1246         char *name = (
char *) inarg;
  1248         if (req->se->op.rmdir)
  1249                 req->se->op.rmdir(req, nodeid, name);
  1256         char *name = (
char *) inarg;
  1257         char *linkname = ((
char *) inarg) + strlen((
char *) inarg) + 1;
  1259         if (req->se->op.symlink)
  1260                 req->se->op.symlink(req, linkname, nodeid, name);
  1267         struct fuse_rename_in *arg = (
struct fuse_rename_in *) inarg;
  1268         char *oldname = PARAM(arg);
  1269         char *newname = oldname + strlen(oldname) + 1;
  1271         if (req->se->op.rename)
  1272                 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
  1280         struct fuse_rename2_in *arg = (
struct fuse_rename2_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_link_in *arg = (
struct fuse_link_in *) inarg;
  1295         if (req->se->op.link)
  1296                 req->se->op.link(req, arg->oldnodeid, nodeid, PARAM(arg));
  1303         struct fuse_create_in *arg = (
struct fuse_create_in *) inarg;
  1305         if (req->se->op.create) {
  1307                 char *name = PARAM(arg);
  1309                 memset(&fi, 0, 
sizeof(fi));
  1310                 fi.
flags = arg->flags;
  1312                 if (req->se->conn.proto_minor >= 12)
  1313                         req->ctx.umask = arg->umask;
  1315                         name = (
char *) inarg + 
sizeof(
struct fuse_open_in);
  1317                 req->se->op.create(req, nodeid, name, arg->mode, &fi);
  1324         struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
  1327         memset(&fi, 0, 
sizeof(fi));
  1328         fi.
flags = arg->flags;
  1330         if (req->se->op.open)
  1331                 req->se->op.open(req, nodeid, &fi);
  1338         struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
  1340         if (req->se->op.read) {
  1343                 memset(&fi, 0, 
sizeof(fi));
  1345                 if (req->se->conn.proto_minor >= 9) {
  1347                         fi.
flags = arg->flags;
  1349                 req->se->op.read(req, nodeid, arg->size, arg->offset, &fi);
  1356         struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
  1360         memset(&fi, 0, 
sizeof(fi));
  1362         fi.
writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
  1364         if (req->se->conn.proto_minor < 9) {
  1365                 param = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
  1368                 fi.
flags = arg->flags;
  1372         if (req->se->op.write)
  1373                 req->se->op.write(req, nodeid, param, arg->size,
  1382         struct fuse_session *se = req->se;
  1387         struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
  1390         memset(&fi, 0, 
sizeof(fi));
  1392         fi.
writepage = arg->write_flags & FUSE_WRITE_CACHE;
  1394         if (se->conn.proto_minor < 9) {
  1395                 bufv.
buf[0].
mem = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
  1396                 bufv.
buf[0].
size -= 
sizeof(
struct fuse_in_header) +
  1397                         FUSE_COMPAT_WRITE_IN_SIZE;
  1398                 assert(!(bufv.
buf[0].
flags & FUSE_BUF_IS_FD));
  1401                 fi.
flags = arg->flags;
  1402                 if (!(bufv.
buf[0].
flags & FUSE_BUF_IS_FD))
  1403                         bufv.
buf[0].
mem = PARAM(arg);
  1405                 bufv.
buf[0].
size -= 
sizeof(
struct fuse_in_header) +
  1406                         sizeof(struct fuse_write_in);
  1408         if (bufv.
buf[0].
size < arg->size) {
  1409                 fuse_log(FUSE_LOG_ERR, 
"fuse: do_write_buf: buffer size too small\n");
  1415         se->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
  1419         if ((ibuf->
flags & FUSE_BUF_IS_FD) && bufv.
idx < bufv.
count)
  1420                 fuse_ll_clear_pipe(se);
  1425         struct fuse_flush_in *arg = (
struct fuse_flush_in *) inarg;
  1428         memset(&fi, 0, 
sizeof(fi));
  1431         if (req->se->conn.proto_minor >= 7)
  1434         if (req->se->op.flush)
  1435                 req->se->op.flush(req, nodeid, &fi);
  1442         struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
  1445         memset(&fi, 0, 
sizeof(fi));
  1446         fi.
flags = arg->flags;
  1448         if (req->se->conn.proto_minor >= 8) {
  1449                 fi.
flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
  1452         if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) {
  1453                 fi.flock_release = 1;
  1457         if (req->se->op.release)
  1458                 req->se->op.release(req, nodeid, &fi);
  1465         struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
  1467         int datasync = arg->fsync_flags & 1;
  1469         memset(&fi, 0, 
sizeof(fi));
  1472         if (req->se->op.fsync)
  1473                 req->se->op.fsync(req, nodeid, datasync, &fi);
  1480         struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
  1483         memset(&fi, 0, 
sizeof(fi));
  1484         fi.
flags = arg->flags;
  1486         if (req->se->op.opendir)
  1487                 req->se->op.opendir(req, nodeid, &fi);
  1494         struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
  1497         memset(&fi, 0, 
sizeof(fi));
  1500         if (req->se->op.readdir)
  1501                 req->se->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
  1508         struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
  1511         memset(&fi, 0, 
sizeof(fi));
  1514         if (req->se->op.readdirplus)
  1515                 req->se->op.readdirplus(req, nodeid, arg->size, arg->offset, &fi);
  1522         struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
  1525         memset(&fi, 0, 
sizeof(fi));
  1526         fi.
flags = arg->flags;
  1529         if (req->se->op.releasedir)
  1530                 req->se->op.releasedir(req, nodeid, &fi);
  1537         struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
  1539         int datasync = arg->fsync_flags & 1;
  1541         memset(&fi, 0, 
sizeof(fi));
  1544         if (req->se->op.fsyncdir)
  1545                 req->se->op.fsyncdir(req, nodeid, datasync, &fi);
  1555         if (req->se->op.statfs)
  1556                 req->se->op.statfs(req, nodeid);
  1558                 struct statvfs buf = {
  1568         struct fuse_setxattr_in *arg = (
struct fuse_setxattr_in *) inarg;
  1569         char *name = PARAM(arg);
  1570         char *value = name + strlen(name) + 1;
  1572         if (req->se->op.setxattr)
  1573                 req->se->op.setxattr(req, nodeid, name, value, arg->size,
  1581         struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
  1583         if (req->se->op.getxattr)
  1584                 req->se->op.getxattr(req, nodeid, PARAM(arg), arg->size);
  1591         struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
  1593         if (req->se->op.listxattr)
  1594                 req->se->op.listxattr(req, nodeid, arg->size);
  1601         char *name = (
char *) inarg;
  1603         if (req->se->op.removexattr)
  1604                 req->se->op.removexattr(req, nodeid, name);
  1609 static void convert_fuse_file_lock(
struct fuse_file_lock *fl,
  1610                                    struct flock *flock)
  1612         memset(flock, 0, 
sizeof(
struct flock));
  1613         flock->l_type = fl->type;
  1614         flock->l_whence = SEEK_SET;
  1615         flock->l_start = fl->start;
  1616         if (fl->end == OFFSET_MAX)
  1619                 flock->l_len = fl->end - fl->start + 1;
  1620         flock->l_pid = fl->pid;
  1625         struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
  1629         memset(&fi, 0, 
sizeof(fi));
  1633         convert_fuse_file_lock(&arg->lk, &flock);
  1634         if (req->se->op.getlk)
  1635                 req->se->op.getlk(req, nodeid, &fi, &flock);
  1641                             const void *inarg, 
int sleep)
  1643         struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
  1647         memset(&fi, 0, 
sizeof(fi));
  1651         if (arg->lk_flags & FUSE_LK_FLOCK) {
  1654                 switch (arg->lk.type) {
  1668                 if (req->se->op.flock)
  1669                         req->se->op.flock(req, nodeid, &fi, op);
  1673                 convert_fuse_file_lock(&arg->lk, &flock);
  1674                 if (req->se->op.setlk)
  1675                         req->se->op.setlk(req, nodeid, &fi, &flock, sleep);
  1683         do_setlk_common(req, nodeid, inarg, 0);
  1688         do_setlk_common(req, nodeid, inarg, 1);
  1691 static int find_interrupted(
struct fuse_session *se, 
struct fuse_req *req)
  1693         struct fuse_req *curr;
  1695         for (curr = se->list.next; curr != &se->list; curr = curr->next) {
  1696                 if (curr->unique == req->u.i.unique) {
  1701                         pthread_mutex_unlock(&se->lock);
  1704                         pthread_mutex_lock(&curr->lock);
  1705                         pthread_mutex_lock(&se->lock);
  1706                         curr->interrupted = 1;
  1707                         func = curr->u.ni.func;
  1708                         data = curr->u.ni.data;
  1709                         pthread_mutex_unlock(&se->lock);
  1712                         pthread_mutex_unlock(&curr->lock);
  1714                         pthread_mutex_lock(&se->lock);
  1722         for (curr = se->interrupts.next; curr != &se->interrupts;
  1723              curr = curr->next) {
  1724                 if (curr->u.i.unique == req->u.i.unique)
  1732         struct fuse_interrupt_in *arg = (
struct fuse_interrupt_in *) inarg;
  1733         struct fuse_session *se = req->se;
  1737                 fuse_log(FUSE_LOG_DEBUG, 
"INTERRUPT: %llu\n",
  1738                         (
unsigned long long) arg->unique);
  1740         req->u.i.unique = arg->unique;
  1742         pthread_mutex_lock(&se->lock);
  1743         if (find_interrupted(se, req))
  1746                 list_add_req(req, &se->interrupts);
  1747         pthread_mutex_unlock(&se->lock);
  1750 static struct fuse_req *check_interrupt(
struct fuse_session *se,
  1751                                         struct fuse_req *req)
  1753         struct fuse_req *curr;
  1755         for (curr = se->interrupts.next; curr != &se->interrupts;
  1756              curr = curr->next) {
  1757                 if (curr->u.i.unique == req->unique) {
  1758                         req->interrupted = 1;
  1764         curr = se->interrupts.next;
  1765         if (curr != &se->interrupts) {
  1767                 list_init_req(curr);
  1775         struct fuse_bmap_in *arg = (
struct fuse_bmap_in *) inarg;
  1777         if (req->se->op.bmap)
  1778                 req->se->op.bmap(req, nodeid, arg->blocksize, arg->block);
  1785         struct fuse_ioctl_in *arg = (
struct fuse_ioctl_in *) inarg;
  1786         unsigned int flags = arg->flags;
  1787         void *in_buf = arg->in_size ? PARAM(arg) : NULL;
  1790         if (flags & FUSE_IOCTL_DIR &&
  1796         memset(&fi, 0, 
sizeof(fi));
  1799         if (
sizeof(
void *) == 4 && req->se->conn.proto_minor >= 16 &&
  1800             !(flags & FUSE_IOCTL_32BIT)) {
  1801                 req->ioctl_64bit = 1;
  1804         if (req->se->op.ioctl)
  1805                 req->se->op.ioctl(req, nodeid, arg->cmd,
  1806                                  (
void *)(uintptr_t)arg->arg, &fi, flags,
  1807                                  in_buf, arg->in_size, arg->out_size);
  1819         struct fuse_poll_in *arg = (
struct fuse_poll_in *) inarg;
  1822         memset(&fi, 0, 
sizeof(fi));
  1826         if (req->se->op.poll) {
  1827                 struct fuse_pollhandle *ph = NULL;
  1829                 if (arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) {
  1830                         ph = malloc(
sizeof(
struct fuse_pollhandle));
  1839                 req->se->op.poll(req, nodeid, &fi, ph);
  1847         struct fuse_fallocate_in *arg = (
struct fuse_fallocate_in *) inarg;
  1850         memset(&fi, 0, 
sizeof(fi));
  1853         if (req->se->op.fallocate)
  1854                 req->se->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi);
  1861         struct fuse_copy_file_range_in *arg = (
struct fuse_copy_file_range_in *) inarg;
  1864         memset(&fi_in, 0, 
sizeof(fi_in));
  1865         fi_in.fh = arg->fh_in;
  1867         memset(&fi_out, 0, 
sizeof(fi_out));
  1868         fi_out.fh = arg->fh_out;
  1871         if (req->se->op.copy_file_range)
  1872                 req->se->op.copy_file_range(req, nodeid_in, arg->off_in,
  1873                                             &fi_in, arg->nodeid_out,
  1874                                             arg->off_out, &fi_out, arg->len,
  1882         struct fuse_lseek_in *arg = (
struct fuse_lseek_in *) inarg;
  1885         memset(&fi, 0, 
sizeof(fi));
  1888         if (req->se->op.lseek)
  1889                 req->se->op.lseek(req, nodeid, arg->offset, arg->whence, &fi);
  1896         struct fuse_init_in *arg = (
struct fuse_init_in *) inarg;
  1897         struct fuse_init_out outarg;
  1898         struct fuse_session *se = req->se;
  1899         size_t bufsize = se->bufsize;
  1900         size_t outargsize = 
sizeof(outarg);
  1904                 fuse_log(FUSE_LOG_DEBUG, 
"INIT: %u.%u\n", arg->major, arg->minor);
  1905                 if (arg->major == 7 && arg->minor >= 6) {
  1906                         fuse_log(FUSE_LOG_DEBUG, 
"flags=0x%08x\n", arg->flags);
  1907                         fuse_log(FUSE_LOG_DEBUG, 
"max_readahead=0x%08x\n",
  1908                                 arg->max_readahead);
  1911         se->conn.proto_major = arg->major;
  1912         se->conn.proto_minor = arg->minor;
  1913         se->conn.capable = 0;
  1916         memset(&outarg, 0, 
sizeof(outarg));
  1917         outarg.major = FUSE_KERNEL_VERSION;
  1918         outarg.minor = FUSE_KERNEL_MINOR_VERSION;
  1920         if (arg->major < 7) {
  1921                 fuse_log(FUSE_LOG_ERR, 
"fuse: unsupported protocol version: %u.%u\n",
  1922                         arg->major, arg->minor);
  1927         if (arg->major > 7) {
  1929                 send_reply_ok(req, &outarg, 
sizeof(outarg));
  1933         if (arg->minor >= 6) {
  1934                 if (arg->max_readahead < se->conn.max_readahead)
  1935                         se->conn.max_readahead = arg->max_readahead;
  1936                 if (arg->flags & FUSE_ASYNC_READ)
  1938                 if (arg->flags & FUSE_POSIX_LOCKS)
  1940                 if (arg->flags & FUSE_ATOMIC_O_TRUNC)
  1942                 if (arg->flags & FUSE_EXPORT_SUPPORT)
  1944                 if (arg->flags & FUSE_DONT_MASK)
  1946                 if (arg->flags & FUSE_FLOCK_LOCKS)
  1948                 if (arg->flags & FUSE_AUTO_INVAL_DATA)
  1950                 if (arg->flags & FUSE_DO_READDIRPLUS)
  1952                 if (arg->flags & FUSE_READDIRPLUS_AUTO)
  1954                 if (arg->flags & FUSE_ASYNC_DIO)
  1956                 if (arg->flags & FUSE_WRITEBACK_CACHE)
  1958                 if (arg->flags & FUSE_NO_OPEN_SUPPORT)
  1960                 if (arg->flags & FUSE_PARALLEL_DIROPS)
  1962                 if (arg->flags & FUSE_POSIX_ACL)
  1964                 if (arg->flags & FUSE_HANDLE_KILLPRIV)
  1966                 if (arg->flags & FUSE_NO_OPENDIR_SUPPORT)
  1968                 if (arg->flags & FUSE_EXPLICIT_INVAL_DATA)
  1970                 if (!(arg->flags & FUSE_MAX_PAGES)) {
  1971                         size_t max_bufsize =
  1972                                 FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
  1973                                 + FUSE_BUFFER_HEADER_SIZE;
  1974                         if (bufsize > max_bufsize) {
  1975                                 bufsize = max_bufsize;
  1979                 se->conn.max_readahead = 0;
  1982         if (se->conn.proto_minor >= 14) {
  1984 #ifdef HAVE_VMSPLICE  1990         if (se->conn.proto_minor >= 18)
  2000 #define LL_SET_DEFAULT(cond, cap) \  2001         if ((cond) && (se->conn.capable & (cap))) \  2002                 se->conn.want |= (cap)  2011         LL_SET_DEFAULT(se->op.getlk && se->op.setlk,
  2015         LL_SET_DEFAULT(se->op.readdirplus && se->op.readdir,
  2017         se->conn.time_gran = 1;
  2019         if (bufsize < FUSE_MIN_READ_BUFFER) {
  2020                 fuse_log(FUSE_LOG_ERR, 
"fuse: warning: buffer size too small: %zu\n",
  2022                 bufsize = FUSE_MIN_READ_BUFFER;
  2024         se->bufsize = bufsize;
  2026         if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE)
  2027                 se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE;
  2031                 se->op.init(se->userdata, &se->conn);
  2033         if (se->conn.want & (~se->conn.capable)) {
  2034                 fuse_log(FUSE_LOG_ERR, 
"fuse: error: filesystem requested capabilities "  2035                         "0x%x that are not supported by kernel, aborting.\n",
  2036                         se->conn.want & (~se->conn.capable));
  2038                 se->error = -EPROTO;
  2043         unsigned max_read_mo = get_max_read(se->mo);
  2044         if (se->conn.max_read != max_read_mo) {
  2045                 fuse_log(FUSE_LOG_ERR, 
"fuse: error: init() and fuse_session_new() "  2046                         "requested different maximum read size (%u vs %u)\n",
  2047                         se->conn.max_read, max_read_mo);
  2049                 se->error = -EPROTO;
  2054         if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE) {
  2055                 se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
  2057         if (arg->flags & FUSE_MAX_PAGES) {
  2058                 outarg.flags |= FUSE_MAX_PAGES;
  2059                 outarg.max_pages = (se->conn.max_write - 1) / getpagesize() + 1;
  2064         outarg.flags |= FUSE_BIG_WRITES;
  2067                 outarg.flags |= FUSE_ASYNC_READ;
  2069                 outarg.flags |= FUSE_POSIX_LOCKS;
  2071                 outarg.flags |= FUSE_ATOMIC_O_TRUNC;
  2073                 outarg.flags |= FUSE_EXPORT_SUPPORT;
  2075                 outarg.flags |= FUSE_DONT_MASK;
  2077                 outarg.flags |= FUSE_FLOCK_LOCKS;
  2079                 outarg.flags |= FUSE_AUTO_INVAL_DATA;
  2081                 outarg.flags |= FUSE_DO_READDIRPLUS;
  2083                 outarg.flags |= FUSE_READDIRPLUS_AUTO;
  2085                 outarg.flags |= FUSE_ASYNC_DIO;
  2087                 outarg.flags |= FUSE_WRITEBACK_CACHE;
  2089                 outarg.flags |= FUSE_POSIX_ACL;
  2091                 outarg.flags |= FUSE_EXPLICIT_INVAL_DATA;
  2092         outarg.max_readahead = se->conn.max_readahead;
  2093         outarg.max_write = se->conn.max_write;
  2094         if (se->conn.proto_minor >= 13) {
  2095                 if (se->conn.max_background >= (1 << 16))
  2096                         se->conn.max_background = (1 << 16) - 1;
  2097                 if (se->conn.congestion_threshold > se->conn.max_background)
  2098                         se->conn.congestion_threshold = se->conn.max_background;
  2099                 if (!se->conn.congestion_threshold) {
  2100                         se->conn.congestion_threshold =
  2101                                 se->conn.max_background * 3 / 4;
  2104                 outarg.max_background = se->conn.max_background;
  2105                 outarg.congestion_threshold = se->conn.congestion_threshold;
  2107         if (se->conn.proto_minor >= 23)
  2108                 outarg.time_gran = se->conn.time_gran;
  2111                 fuse_log(FUSE_LOG_DEBUG, 
"   INIT: %u.%u\n", outarg.major, outarg.minor);
  2112                 fuse_log(FUSE_LOG_DEBUG, 
"   flags=0x%08x\n", outarg.flags);
  2113                 fuse_log(FUSE_LOG_DEBUG, 
"   max_readahead=0x%08x\n",
  2114                         outarg.max_readahead);
  2115                 fuse_log(FUSE_LOG_DEBUG, 
"   max_write=0x%08x\n", outarg.max_write);
  2116                 fuse_log(FUSE_LOG_DEBUG, 
"   max_background=%i\n",
  2117                         outarg.max_background);
  2118                 fuse_log(FUSE_LOG_DEBUG, 
"   congestion_threshold=%i\n",
  2119                         outarg.congestion_threshold);
  2120                 fuse_log(FUSE_LOG_DEBUG, 
"   time_gran=%u\n",
  2124                 outargsize = FUSE_COMPAT_INIT_OUT_SIZE;
  2125         else if (arg->minor < 23)
  2126                 outargsize = FUSE_COMPAT_22_INIT_OUT_SIZE;
  2128         send_reply_ok(req, &outarg, outargsize);
  2133         struct fuse_session *se = req->se;
  2138         se->got_destroy = 1;
  2140                 se->op.destroy(se->userdata);
  2142         send_reply_ok(req, NULL, 0);
  2145 static void list_del_nreq(
struct fuse_notify_req *nreq)
  2147         struct fuse_notify_req *prev = nreq->prev;
  2148         struct fuse_notify_req *next = nreq->next;
  2153 static void list_add_nreq(
struct fuse_notify_req *nreq,
  2154                           struct fuse_notify_req *next)
  2156         struct fuse_notify_req *prev = next->prev;
  2163 static void list_init_nreq(
struct fuse_notify_req *nreq)
  2170                             const void *inarg, 
const struct fuse_buf *buf)
  2172         struct fuse_session *se = req->se;
  2173         struct fuse_notify_req *nreq;
  2174         struct fuse_notify_req *head;
  2176         pthread_mutex_lock(&se->lock);
  2177         head = &se->notify_list;
  2178         for (nreq = head->next; nreq != head; nreq = nreq->next) {
  2179                 if (nreq->unique == req->unique) {
  2180                         list_del_nreq(nreq);
  2184         pthread_mutex_unlock(&se->lock);
  2187                 nreq->reply(nreq, req, nodeid, inarg, buf);
  2190 static int send_notify_iov(
struct fuse_session *se, 
int notify_code,
  2191                            struct iovec *iov, 
int count)
  2193         struct fuse_out_header out;
  2199         out.error = notify_code;
  2200         iov[0].iov_base = &out;
  2201         iov[0].iov_len = 
sizeof(
struct fuse_out_header);
  2203         return fuse_send_msg(se, NULL, iov, count);
  2209                 struct fuse_notify_poll_wakeup_out outarg;
  2210                 struct iovec iov[2];
  2214                 iov[1].iov_base = &outarg;
  2215                 iov[1].iov_len = 
sizeof(outarg);
  2217                 return send_notify_iov(ph->se, FUSE_NOTIFY_POLL, iov, 2);
  2224                                      off_t off, off_t len)
  2226         struct fuse_notify_inval_inode_out outarg;
  2227         struct iovec iov[2];
  2232         if (se->conn.proto_minor < 12)
  2239         iov[1].iov_base = &outarg;
  2240         iov[1].iov_len = 
sizeof(outarg);
  2242         return send_notify_iov(se, FUSE_NOTIFY_INVAL_INODE, iov, 2);
  2246                                      const char *name, 
size_t namelen)
  2248         struct fuse_notify_inval_entry_out outarg;
  2249         struct iovec iov[3];
  2254         if (se->conn.proto_minor < 12)
  2257         outarg.parent = parent;
  2258         outarg.namelen = namelen;
  2261         iov[1].iov_base = &outarg;
  2262         iov[1].iov_len = 
sizeof(outarg);
  2263         iov[2].iov_base = (
void *)name;
  2264         iov[2].iov_len = namelen + 1;
  2266         return send_notify_iov(se, FUSE_NOTIFY_INVAL_ENTRY, iov, 3);
  2271                                 const char *name, 
size_t namelen)
  2273         struct fuse_notify_delete_out outarg;
  2274         struct iovec iov[3];
  2279         if (se->conn.proto_minor < 18)
  2282         outarg.parent = parent;
  2283         outarg.child = child;
  2284         outarg.namelen = namelen;
  2287         iov[1].iov_base = &outarg;
  2288         iov[1].iov_len = 
sizeof(outarg);
  2289         iov[2].iov_base = (
void *)name;
  2290         iov[2].iov_len = namelen + 1;
  2292         return send_notify_iov(se, FUSE_NOTIFY_DELETE, iov, 3);
  2299         struct fuse_out_header out;
  2300         struct fuse_notify_store_out outarg;
  2301         struct iovec iov[3];
  2308         if (se->conn.proto_minor < 15)
  2312         out.error = FUSE_NOTIFY_STORE;
  2314         outarg.nodeid = ino;
  2315         outarg.offset = offset;
  2319         iov[0].iov_base = &out;
  2320         iov[0].iov_len = 
sizeof(out);
  2321         iov[1].iov_base = &outarg;
  2322         iov[1].iov_len = 
sizeof(outarg);
  2324         res = fuse_send_data_iov(se, NULL, iov, 2, bufv, flags);
  2331 struct fuse_retrieve_req {
  2332         struct fuse_notify_req nreq;
  2336 static void fuse_ll_retrieve_reply(
struct fuse_notify_req *nreq,
  2341         struct fuse_session *se = req->se;
  2342         struct fuse_retrieve_req *rreq =
  2343                 container_of(nreq, 
struct fuse_retrieve_req, nreq);
  2344         const struct fuse_notify_retrieve_in *arg = inarg;
  2350         if (!(bufv.
buf[0].
flags & FUSE_BUF_IS_FD))
  2351                 bufv.
buf[0].
mem = PARAM(arg);
  2353         bufv.
buf[0].
size -= 
sizeof(
struct fuse_in_header) +
  2354                 sizeof(struct fuse_notify_retrieve_in);
  2356         if (bufv.
buf[0].
size < arg->size) {
  2357                 fuse_log(FUSE_LOG_ERR, 
"fuse: retrieve reply: buffer size too small\n");
  2363         if (se->op.retrieve_reply) {
  2364                 se->op.retrieve_reply(req, rreq->cookie, ino,
  2365                                           arg->offset, &bufv);
  2371         if ((ibuf->
flags & FUSE_BUF_IS_FD) && bufv.
idx < bufv.
count)
  2372                 fuse_ll_clear_pipe(se);
  2376                                   size_t size, off_t offset, 
void *cookie)
  2378         struct fuse_notify_retrieve_out outarg;
  2379         struct iovec iov[2];
  2380         struct fuse_retrieve_req *rreq;
  2386         if (se->conn.proto_minor < 15)
  2389         rreq = malloc(
sizeof(*rreq));
  2393         pthread_mutex_lock(&se->lock);
  2394         rreq->cookie = cookie;
  2395         rreq->nreq.unique = se->notify_ctr++;
  2396         rreq->nreq.reply = fuse_ll_retrieve_reply;
  2397         list_add_nreq(&rreq->nreq, &se->notify_list);
  2398         pthread_mutex_unlock(&se->lock);
  2400         outarg.notify_unique = rreq->nreq.unique;
  2401         outarg.nodeid = ino;
  2402         outarg.offset = offset;
  2406         iov[1].iov_base = &outarg;
  2407         iov[1].iov_len = 
sizeof(outarg);
  2409         err = send_notify_iov(se, FUSE_NOTIFY_RETRIEVE, iov, 2);
  2411                 pthread_mutex_lock(&se->lock);
  2412                 list_del_nreq(&rreq->nreq);
  2413                 pthread_mutex_unlock(&se->lock);
  2422         return req->se->userdata;
  2433         pthread_mutex_lock(&req->lock);
  2434         pthread_mutex_lock(&req->se->lock);
  2435         req->u.ni.func = func;
  2436         req->u.ni.data = data;
  2437         pthread_mutex_unlock(&req->se->lock);
  2438         if (req->interrupted && func)
  2440         pthread_mutex_unlock(&req->lock);
  2447         pthread_mutex_lock(&req->se->lock);
  2448         interrupted = req->interrupted;
  2449         pthread_mutex_unlock(&req->se->lock);
  2458         [FUSE_LOOKUP]      = { do_lookup,      
"LOOKUP"      },
  2459         [FUSE_FORGET]      = { do_forget,      
"FORGET"      },
  2460         [FUSE_GETATTR]     = { do_getattr,     
"GETATTR"     },
  2461         [FUSE_SETATTR]     = { do_setattr,     
"SETATTR"     },
  2462         [FUSE_READLINK]    = { do_readlink,    
"READLINK"    },
  2463         [FUSE_SYMLINK]     = { do_symlink,     
"SYMLINK"     },
  2464         [FUSE_MKNOD]       = { do_mknod,       
"MKNOD"       },
  2465         [FUSE_MKDIR]       = { do_mkdir,       
"MKDIR"       },
  2466         [FUSE_UNLINK]      = { do_unlink,      
"UNLINK"      },
  2467         [FUSE_RMDIR]       = { do_rmdir,       
"RMDIR"       },
  2468         [FUSE_RENAME]      = { do_rename,      
"RENAME"      },
  2469         [FUSE_LINK]        = { do_link,        
"LINK"        },
  2470         [FUSE_OPEN]        = { do_open,        
"OPEN"        },
  2471         [FUSE_READ]        = { do_read,        
"READ"        },
  2472         [FUSE_WRITE]       = { do_write,       
"WRITE"       },
  2473         [FUSE_STATFS]      = { do_statfs,      
"STATFS"      },
  2474         [FUSE_RELEASE]     = { do_release,     
"RELEASE"     },
  2475         [FUSE_FSYNC]       = { do_fsync,       
"FSYNC"       },
  2476         [FUSE_SETXATTR]    = { do_setxattr,    
"SETXATTR"    },
  2477         [FUSE_GETXATTR]    = { do_getxattr,    
"GETXATTR"    },
  2478         [FUSE_LISTXATTR]   = { do_listxattr,   
"LISTXATTR"   },
  2479         [FUSE_REMOVEXATTR] = { do_removexattr, 
"REMOVEXATTR" },
  2480         [FUSE_FLUSH]       = { do_flush,       
"FLUSH"       },
  2481         [FUSE_INIT]        = { do_init,        
"INIT"        },
  2482         [FUSE_OPENDIR]     = { do_opendir,     
"OPENDIR"     },
  2483         [FUSE_READDIR]     = { do_readdir,     
"READDIR"     },
  2484         [FUSE_RELEASEDIR]  = { do_releasedir,  
"RELEASEDIR"  },
  2485         [FUSE_FSYNCDIR]    = { do_fsyncdir,    
"FSYNCDIR"    },
  2486         [FUSE_GETLK]       = { do_getlk,       
"GETLK"       },
  2487         [FUSE_SETLK]       = { do_setlk,       
"SETLK"       },
  2488         [FUSE_SETLKW]      = { do_setlkw,      
"SETLKW"      },
  2489         [FUSE_ACCESS]      = { do_access,      
"ACCESS"      },
  2490         [FUSE_CREATE]      = { do_create,      
"CREATE"      },
  2491         [FUSE_INTERRUPT]   = { do_interrupt,   
"INTERRUPT"   },
  2492         [FUSE_BMAP]        = { do_bmap,        
"BMAP"        },
  2493         [FUSE_IOCTL]       = { do_ioctl,       
"IOCTL"       },
  2494         [FUSE_POLL]        = { do_poll,        
"POLL"        },
  2495         [FUSE_FALLOCATE]   = { do_fallocate,   
"FALLOCATE"   },
  2496         [FUSE_DESTROY]     = { do_destroy,     
"DESTROY"     },
  2497         [FUSE_NOTIFY_REPLY] = { (
void *) 1,    
"NOTIFY_REPLY" },
  2498         [FUSE_BATCH_FORGET] = { do_batch_forget, 
"BATCH_FORGET" },
  2499         [FUSE_READDIRPLUS] = { do_readdirplus,  
"READDIRPLUS"},
  2500         [FUSE_RENAME2]     = { do_rename2,      
"RENAME2"    },
  2501         [FUSE_COPY_FILE_RANGE] = { do_copy_file_range, 
"COPY_FILE_RANGE" },
  2502         [FUSE_LSEEK]       = { do_lseek,       
"LSEEK"       },
  2503         [CUSE_INIT]        = { cuse_lowlevel_init, 
"CUSE_INIT"   },
  2506 #define FUSE_MAXOP (sizeof(fuse_ll_ops) / sizeof(fuse_ll_ops[0]))  2508 static const char *opname(
enum fuse_opcode opcode)
  2510         if (opcode >= FUSE_MAXOP || !fuse_ll_ops[opcode].name)
  2513                 return fuse_ll_ops[opcode].name;
  2516 static int fuse_ll_copy_from_pipe(
struct fuse_bufvec *dst,
  2521                 fuse_log(FUSE_LOG_ERR, 
"fuse: copy from pipe: %s\n", strerror(-res));
  2525                 fuse_log(FUSE_LOG_ERR, 
"fuse: copy from pipe: short read\n");
  2534         fuse_session_process_buf_int(se, buf, NULL);
  2537 void fuse_session_process_buf_int(
struct fuse_session *se,
  2538                                   const struct fuse_buf *buf, 
struct fuse_chan *ch)
  2540         const size_t write_header_size = 
sizeof(
struct fuse_in_header) +
  2541                 sizeof(struct fuse_write_in);
  2543         struct fuse_bufvec tmpbuf = FUSE_BUFVEC_INIT(write_header_size);
  2544         struct fuse_in_header *in;
  2546         struct fuse_req *req;
  2551         if (buf->
flags & FUSE_BUF_IS_FD) {
  2555                 mbuf = malloc(tmpbuf.
buf[0].
size);
  2557                         fuse_log(FUSE_LOG_ERR, 
"fuse: failed to allocate header\n");
  2560                 tmpbuf.
buf[0].
mem = mbuf;
  2562                 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
  2573                         "unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n",
  2574                         (
unsigned long long) in->unique,
  2575                         opname((
enum fuse_opcode) in->opcode), in->opcode,
  2576                         (
unsigned long long) in->nodeid, buf->
size, in->pid);
  2579         req = fuse_ll_alloc_req(se);
  2581                 struct fuse_out_header out = {
  2582                         .unique = in->unique,
  2585                 struct iovec iov = {
  2587                         .iov_len = 
sizeof(
struct fuse_out_header),
  2590                 fuse_send_msg(se, ch, &iov, 1);
  2594         req->unique = in->unique;
  2595         req->ctx.uid = in->uid;
  2596         req->ctx.gid = in->gid;
  2597         req->ctx.pid = in->pid;
  2598         req->ch = ch ? fuse_chan_get(ch) : NULL;
  2601         if (!se->got_init) {
  2602                 enum fuse_opcode expected;
  2604                 expected = se->cuse_data ? CUSE_INIT : FUSE_INIT;
  2605                 if (in->opcode != expected)
  2607         } 
else if (in->opcode == FUSE_INIT || in->opcode == CUSE_INIT)
  2612         if (se->deny_others && in->uid != se->owner && in->uid != 0 &&
  2613                  in->opcode != FUSE_INIT && in->opcode != FUSE_READ &&
  2614                  in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC &&
  2615                  in->opcode != FUSE_RELEASE && in->opcode != FUSE_READDIR &&
  2616                  in->opcode != FUSE_FSYNCDIR && in->opcode != FUSE_RELEASEDIR &&
  2617                  in->opcode != FUSE_NOTIFY_REPLY &&
  2618                  in->opcode != FUSE_READDIRPLUS)
  2622         if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func)
  2624         if (in->opcode != FUSE_INTERRUPT) {
  2625                 struct fuse_req *intr;
  2626                 pthread_mutex_lock(&se->lock);
  2627                 intr = check_interrupt(se, req);
  2628                 list_add_req(req, &se->list);
  2629                 pthread_mutex_unlock(&se->lock);
  2634         if ((buf->
flags & FUSE_BUF_IS_FD) && write_header_size < buf->size &&
  2635             (in->opcode != FUSE_WRITE || !se->op.write_buf) &&
  2636             in->opcode != FUSE_NOTIFY_REPLY) {
  2640                 newmbuf = realloc(mbuf, buf->
size);
  2641                 if (newmbuf == NULL)
  2645                 tmpbuf = FUSE_BUFVEC_INIT(buf->
size - write_header_size);
  2646                 tmpbuf.
buf[0].
mem = (
char *)mbuf + write_header_size;
  2648                 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
  2656         inarg = (
void *) &in[1];
  2657         if (in->opcode == FUSE_WRITE && se->op.write_buf)
  2658                 do_write_buf(req, in->nodeid, inarg, buf);
  2659         else if (in->opcode == FUSE_NOTIFY_REPLY)
  2660                 do_notify_reply(req, in->nodeid, inarg, buf);
  2662                 fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
  2671         if (buf->
flags & FUSE_BUF_IS_FD)
  2672                 fuse_ll_clear_pipe(se);
  2676 #define LL_OPTION(n,o,v) \  2677         { n, offsetof(struct fuse_session, o), v }  2679 static const struct fuse_opt fuse_ll_opts[] = {
  2680         LL_OPTION(
"debug", debug, 1),
  2681         LL_OPTION(
"-d", debug, 1),
  2682         LL_OPTION(
"--debug", debug, 1),
  2683         LL_OPTION(
"allow_root", deny_others, 1),
  2689         printf(
"using FUSE kernel interface version %i.%i\n",
  2690                FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
  2691         fuse_mount_version();
  2699 "    -o allow_other         allow access by all users\n"  2700 "    -o allow_root          allow access by root\n"  2701 "    -o auto_unmount        auto unmount on process termination\n");
  2706         struct fuse_ll_pipe *llp;
  2708         if (se->got_init && !se->got_destroy) {
  2710                         se->op.destroy(se->userdata);
  2712         llp = pthread_getspecific(se->pipe_key);
  2714                 fuse_ll_pipe_free(llp);
  2715         pthread_key_delete(se->pipe_key);
  2716         pthread_mutex_destroy(&se->lock);
  2717         free(se->cuse_data);
  2720         destroy_mount_opts(se->mo);
  2725 static void fuse_ll_pipe_destructor(
void *data)
  2727         struct fuse_ll_pipe *llp = data;
  2728         fuse_ll_pipe_free(llp);
  2733         return fuse_session_receive_buf_int(se, buf, NULL);
  2736 int fuse_session_receive_buf_int(
struct fuse_session *se, 
struct fuse_buf *buf,
  2737                                  struct fuse_chan *ch)
  2742         size_t bufsize = se->bufsize;
  2743         struct fuse_ll_pipe *llp;
  2749         llp = fuse_ll_get_pipe(se);
  2753         if (llp->size < bufsize) {
  2754                 if (llp->can_grow) {
  2755                         res = fcntl(llp->pipe[0], F_SETPIPE_SZ, bufsize);
  2758                                 res = grow_pipe_to_max(llp->pipe[0]);
  2765                 if (llp->size < bufsize)
  2769         res = splice(ch ? ch->fd : se->fd,
  2770                      NULL, llp->pipe[1], NULL, bufsize, 0);
  2777                 if (err == ENODEV) {
  2783                 if (err != EINTR && err != EAGAIN)
  2784                         perror(
"fuse: splice from device");
  2788         if (res < 
sizeof(
struct fuse_in_header)) {
  2789                 fuse_log(FUSE_LOG_ERR, 
"short splice from fuse device\n");
  2804         if (res < 
sizeof(
struct fuse_in_header) +
  2805             sizeof(
struct fuse_write_in) + pagesize) {
  2810                         buf->
mem = malloc(se->bufsize);
  2813                                         "fuse: failed to allocate read buffer\n");
  2817                 buf->
size = se->bufsize;
  2823                         fuse_log(FUSE_LOG_ERR, 
"fuse: copy from pipe: %s\n",
  2825                         fuse_ll_clear_pipe(se);
  2828                 if (res < tmpbuf.size) {
  2829                         fuse_log(FUSE_LOG_ERR, 
"fuse: copy from pipe: short read\n");
  2830                         fuse_ll_clear_pipe(se);
  2833                 assert(res == tmpbuf.size);
  2837                 buf->
fd = tmpbuf.fd;
  2838                 buf->
flags = tmpbuf.flags;
  2840         buf->
size = tmpbuf.size;
  2847                 buf->
mem = malloc(se->bufsize);
  2850                                 "fuse: failed to allocate read buffer\n");
  2856         res = read(ch ? ch->fd : se->fd, buf->
mem, se->bufsize);
  2867                 if (err == ENODEV) {
  2876                 if (err != EINTR && err != EAGAIN)
  2877                         perror(
"fuse: reading device");
  2880         if ((
size_t) res < 
sizeof(
struct fuse_in_header)) {
  2881                 fuse_log(FUSE_LOG_ERR, 
"short read on fuse device\n");
  2892                                       size_t op_size, 
void *userdata)
  2895         struct fuse_session *se;
  2896         struct mount_opts *mo;
  2899                 fuse_log(FUSE_LOG_ERR, 
"fuse: warning: library too old, some operations may not work\n");
  2903         if (args->
argc == 0) {
  2904                 fuse_log(FUSE_LOG_ERR, 
"fuse: empty argv passed to fuse_session_new().\n");
  2908         se = (
struct fuse_session *) calloc(1, 
sizeof(
struct fuse_session));
  2910                 fuse_log(FUSE_LOG_ERR, 
"fuse: failed to allocate fuse object\n");
  2914         se->conn.max_write = UINT_MAX;
  2915         se->conn.max_readahead = UINT_MAX;
  2920         if(se->deny_others) {
  2930         mo = parse_mount_opts(args);
  2934         if(args->
argc == 1 &&
  2935            args->
argv[0][0] == 
'-') {
  2936                 fuse_log(FUSE_LOG_ERR, 
"fuse: warning: argv[0] looks like an option, but "  2937                         "will be ignored\n");
  2938         } 
else if (args->
argc != 1) {
  2940                 fuse_log(FUSE_LOG_ERR, 
"fuse: unknown option(s): `");
  2941                 for(i = 1; i < args->
argc-1; i++)
  2948                 fuse_log(FUSE_LOG_DEBUG, 
"FUSE library version: %s\n", PACKAGE_VERSION);
  2950         se->bufsize = FUSE_MAX_MAX_PAGES * getpagesize() +
  2951                 FUSE_BUFFER_HEADER_SIZE;
  2953         list_init_req(&se->list);
  2954         list_init_req(&se->interrupts);
  2955         list_init_nreq(&se->notify_list);
  2957         fuse_mutex_init(&se->lock);
  2959         err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor);
  2961                 fuse_log(FUSE_LOG_ERR, 
"fuse: failed to create thread specific key: %s\n",
  2966         memcpy(&se->op, op, op_size);
  2967         se->owner = getuid();
  2968         se->userdata = userdata;
  2974         pthread_mutex_destroy(&se->lock);
  2994                 fd = open(
"/dev/null", O_RDWR);
  2997         } 
while (fd >= 0 && fd <= 2);
  3005         fd = fuse_mnt_parse_fuse_fd(mountpoint);
  3007                 if (fcntl(fd, F_GETFD) == -1) {
  3009                                 "fuse: Invalid file descriptor /dev/fd/%u\n",
  3018         fd = fuse_kern_mount(mountpoint, se->mo);
  3024         se->mountpoint = strdup(mountpoint);
  3025         if (se->mountpoint == NULL)
  3031         fuse_kern_unmount(mountpoint, fd);
  3042         if (se->mountpoint != NULL) {
  3043                 fuse_kern_unmount(se->mountpoint, se->fd);
  3044                 free(se->mountpoint);
  3045                 se->mountpoint = NULL;
  3053         size_t bufsize = 1024;
  3057         unsigned long pid = req->ctx.pid;
  3060         sprintf(path, 
"/proc/%lu/task/%lu/status", pid, pid);
  3063         buf = malloc(bufsize);
  3068         fd = open(path, O_RDONLY);
  3072         ret = read(fd, buf, bufsize);
  3079         if ((
size_t)ret == bufsize) {
  3086         s = strstr(buf, 
"\nGroups:");
  3094                 unsigned long val = strtoul(s, &end, 0);
  3114         (void) req; (void) size; (void) list;
 void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func, void *data)
int fuse_opt_parse(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc)
int fuse_session_mount(struct fuse_session *se, const char *mountpoint)
int fuse_lowlevel_notify_inval_entry(struct fuse_session *se, fuse_ino_t parent, const char *name, size_t namelen)
struct fuse_req * fuse_req_t
#define FUSE_CAP_DONT_MASK
int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov, int count)
int fuse_session_exited(struct fuse_session *se)
#define FUSE_CAP_SPLICE_READ
void fuse_reply_none(fuse_req_t req)
int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf)
void fuse_session_process_buf(struct fuse_session *se, const struct fuse_buf *buf)
int fuse_reply_attr(fuse_req_t req, const struct stat *attr, double attr_timeout)
#define FUSE_CAP_ASYNC_DIO
#define FUSE_CAP_EXPORT_SUPPORT
#define FUSE_CAP_PARALLEL_DIROPS
#define FUSE_CAP_IOCTL_DIR
#define FUSE_CAP_FLOCK_LOCKS
int fuse_reply_lock(fuse_req_t req, const struct flock *lock)
#define FUSE_CAP_READDIRPLUS_AUTO
int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size)
int fuse_reply_create(fuse_req_t req, const struct fuse_entry_param *e, const struct fuse_file_info *fi)
int fuse_reply_xattr(fuse_req_t req, size_t count)
int fuse_lowlevel_notify_inval_inode(struct fuse_session *se, fuse_ino_t ino, off_t off, off_t len)
#define FUSE_CAP_NO_OPENDIR_SUPPORT
void fuse_lowlevel_version(void)
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_write(fuse_req_t req, size_t count)
int fuse_reply_lseek(fuse_req_t req, off_t off)
#define FUSE_CAP_HANDLE_KILLPRIV
int fuse_lowlevel_notify_poll(struct fuse_pollhandle *ph)
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)
#define FUSE_CAP_EXPLICIT_INVAL_DATA
#define FUSE_CAP_ASYNC_READ
struct fuse_session * fuse_session_new(struct fuse_args *args, const struct fuse_lowlevel_ops *op, size_t op_size, void *userdata)
int fuse_lowlevel_notify_retrieve(struct fuse_session *se, fuse_ino_t ino, size_t size, off_t offset, void *cookie)
int fuse_session_fd(struct fuse_session *se)
enum fuse_buf_flags flags
void fuse_session_unmount(struct fuse_session *se)
#define FUSE_CAP_NO_OPEN_SUPPORT
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
int fuse_reply_err(fuse_req_t req, int err)
#define FUSE_CAP_WRITEBACK_CACHE
void fuse_session_reset(struct fuse_session *se)
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
#define FUSE_CAP_READDIRPLUS
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)
#define FUSE_CAP_SPLICE_MOVE
#define FUSE_CAP_POSIX_LOCKS
#define FUSE_CAP_ATOMIC_O_TRUNC
size_t fuse_add_direntry(fuse_req_t req, char *buf, size_t bufsize, const char *name, const struct stat *stbuf, off_t off)
void * fuse_req_userdata(fuse_req_t req)
void fuse_opt_free_args(struct fuse_args *args)
int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e)
int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf)
const struct fuse_ctx * fuse_req_ctx(fuse_req_t req)
void fuse_session_destroy(struct fuse_session *se)
unsigned int cache_readdir
#define FUSE_CAP_SPLICE_WRITE
int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, size_t size)
int fuse_reply_data(fuse_req_t req, struct fuse_bufvec *bufv, enum fuse_buf_copy_flags flags)
int fuse_lowlevel_notify_delete(struct fuse_session *se, fuse_ino_t parent, fuse_ino_t child, const char *name, size_t namelen)
#define FUSE_CAP_POSIX_ACL
void fuse_lowlevel_help(void)
int fuse_opt_add_arg(struct fuse_args *args, const char *arg)
#define FUSE_CAP_AUTO_INVAL_DATA
void fuse_log(enum fuse_log_level level, const char *fmt,...)
int fuse_req_interrupted(fuse_req_t req)
int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *fi)
void fuse_session_exit(struct fuse_session *se)
int fuse_reply_bmap(fuse_req_t req, uint64_t idx)
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_readlink(fuse_req_t req, const char *link)
int fuse_reply_poll(fuse_req_t req, unsigned revents)
void(* fuse_interrupt_func_t)(fuse_req_t req, void *data)