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;
   171         out->len = iov_length(iov, count);
   173                 if (out->unique == 0) {
   174                         fuse_log(FUSE_LOG_DEBUG, 
"NOTIFY: code=%d length=%u\n",
   175                                 out->error, out->len);
   176                 } 
else if (out->error) {
   178                                 "   unique: %llu, error: %i (%s), outsize: %i\n",
   179                                 (
unsigned long long) out->unique, out->error,
   180                                 strerror(-out->error), out->len);
   183                                 "   unique: %llu, success, outsize: %i\n",
   184                                 (
unsigned long long) out->unique, out->len);
   188         ssize_t res = writev(ch ? ch->fd : se->fd,
   195                         perror(
"fuse: writing device");
   203 int fuse_send_reply_iov_nofree(
fuse_req_t req, 
int error, 
struct iovec *iov,
   206         struct fuse_out_header out;
   208         if (error <= -1000 || error > 0) {
   209                 fuse_log(FUSE_LOG_ERR, 
"fuse: bad error value: %i\n",   error);
   213         out.unique = req->unique;
   216         iov[0].iov_base = &out;
   217         iov[0].iov_len = 
sizeof(
struct fuse_out_header);
   219         return fuse_send_msg(req->se, req->ch, iov, count);
   222 static int send_reply_iov(
fuse_req_t req, 
int error, 
struct iovec *iov,
   227         res = fuse_send_reply_iov_nofree(req, error, iov, count);
   232 static int send_reply(
fuse_req_t req, 
int error, 
const void *arg,
   238                 iov[1].iov_base = (
void *) arg;
   239                 iov[1].iov_len = argsize;
   242         return send_reply_iov(req, error, iov, count);
   248         struct iovec *padded_iov;
   250         padded_iov = malloc((count + 1) * 
sizeof(
struct iovec));
   251         if (padded_iov == NULL)
   254         memcpy(padded_iov + 1, iov, count * 
sizeof(
struct iovec));
   257         res = send_reply_iov(req, 0, padded_iov, count);
   267                          const char *name, 
const struct stat *stbuf, off_t off)
   272         size_t entlen_padded;
   273         struct fuse_dirent *dirent;
   275         namelen = strlen(name);
   276         entlen = FUSE_NAME_OFFSET + namelen;
   277         entlen_padded = FUSE_DIRENT_ALIGN(entlen);
   279         if ((buf == NULL) || (entlen_padded > bufsize))
   280           return entlen_padded;
   282         dirent = (
struct fuse_dirent*) buf;
   283         dirent->ino = stbuf->st_ino;
   285         dirent->namelen = namelen;
   286         dirent->type = (stbuf->st_mode & S_IFMT) >> 12;
   287         memcpy(dirent->name, name, namelen);
   288         memset(dirent->name + namelen, 0, entlen_padded - entlen);
   290         return entlen_padded;
   293 static void convert_statfs(
const struct statvfs *stbuf,
   294                            struct fuse_kstatfs *kstatfs)
   296         kstatfs->bsize   = stbuf->f_bsize;
   297         kstatfs->frsize  = stbuf->f_frsize;
   298         kstatfs->blocks  = stbuf->f_blocks;
   299         kstatfs->bfree   = stbuf->f_bfree;
   300         kstatfs->bavail  = stbuf->f_bavail;
   301         kstatfs->files   = stbuf->f_files;
   302         kstatfs->ffree   = stbuf->f_ffree;
   303         kstatfs->namelen = stbuf->f_namemax;
   306 static int send_reply_ok(
fuse_req_t req, 
const void *arg, 
size_t argsize)
   308         return send_reply(req, 0, arg, argsize);
   313         return send_reply(req, -err, NULL, 0);
   321 static unsigned long calc_timeout_sec(
double t)
   323         if (t > (
double) ULONG_MAX)
   328                 return (
unsigned long) t;
   331 static unsigned int calc_timeout_nsec(
double t)
   333         double f = t - (double) calc_timeout_sec(t);
   336         else if (f >= 0.999999999)
   339                 return (
unsigned int) (f * 1.0e9);
   342 static void fill_entry(
struct fuse_entry_out *arg,
   345         arg->nodeid = e->
ino;
   350         arg->attr_valid_nsec = calc_timeout_nsec(e->
attr_timeout);
   351         convert_stat(&e->
attr, &arg->attr);
   363         size_t entlen_padded;
   365         namelen = strlen(name);
   366         entlen = FUSE_NAME_OFFSET_DIRENTPLUS + namelen;
   367         entlen_padded = FUSE_DIRENT_ALIGN(entlen);
   368         if ((buf == NULL) || (entlen_padded > bufsize))
   369           return entlen_padded;
   371         struct fuse_direntplus *dp = (
struct fuse_direntplus *) buf;
   372         memset(&dp->entry_out, 0, 
sizeof(dp->entry_out));
   373         fill_entry(&dp->entry_out, e);
   375         struct fuse_dirent *dirent = &dp->dirent;
   376         dirent->ino = e->
attr.st_ino;
   378         dirent->namelen = namelen;
   379         dirent->type = (e->
attr.st_mode & S_IFMT) >> 12;
   380         memcpy(dirent->name, name, namelen);
   381         memset(dirent->name + namelen, 0, entlen_padded - entlen);
   383         return entlen_padded;
   386 static void fill_open(
struct fuse_open_out *arg,
   391                 arg->open_flags |= FOPEN_DIRECT_IO;
   393                 arg->open_flags |= FOPEN_KEEP_CACHE;
   395                 arg->open_flags |= FOPEN_CACHE_DIR;
   397                 arg->open_flags |= FOPEN_NONSEEKABLE;
   402         struct fuse_entry_out arg;
   403         size_t size = req->se->conn.proto_minor < 9 ?
   404                 FUSE_COMPAT_ENTRY_OUT_SIZE : 
sizeof(arg);
   408         if (!e->
ino && req->se->conn.proto_minor < 4)
   411         memset(&arg, 0, 
sizeof(arg));
   413         return send_reply_ok(req, &arg, size);
   419         char buf[
sizeof(
struct fuse_entry_out) + sizeof(struct fuse_open_out)];
   420         size_t entrysize = req->se->conn.proto_minor < 9 ?
   421                 FUSE_COMPAT_ENTRY_OUT_SIZE : 
sizeof(
struct fuse_entry_out);
   422         struct fuse_entry_out *earg = (
struct fuse_entry_out *) buf;
   423         struct fuse_open_out *oarg = (
struct fuse_open_out *) (buf + entrysize);
   425         memset(buf, 0, 
sizeof(buf));
   428         return send_reply_ok(req, buf,
   429                              entrysize + 
sizeof(
struct fuse_open_out));
   435         struct fuse_attr_out arg;
   436         size_t size = req->se->conn.proto_minor < 9 ?
   437                 FUSE_COMPAT_ATTR_OUT_SIZE : 
sizeof(arg);
   439         memset(&arg, 0, 
sizeof(arg));
   440         arg.attr_valid = calc_timeout_sec(attr_timeout);
   441         arg.attr_valid_nsec = calc_timeout_nsec(attr_timeout);
   442         convert_stat(attr, &arg.attr);
   444         return send_reply_ok(req, &arg, size);
   449         return send_reply_ok(req, linkname, strlen(linkname));
   454         struct fuse_open_out arg;
   456         memset(&arg, 0, 
sizeof(arg));
   458         return send_reply_ok(req, &arg, 
sizeof(arg));
   463         struct fuse_write_out arg;
   465         memset(&arg, 0, 
sizeof(arg));
   468         return send_reply_ok(req, &arg, 
sizeof(arg));
   473         return send_reply_ok(req, buf, size);
   476 static int fuse_send_data_iov_fallback(
struct fuse_session *se,
   477                                        struct fuse_chan *ch,
   478                                        struct iovec *iov, 
int iov_count,
   482         struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
   487         if (buf->
count == 1 && buf->
idx == 0 && buf->
off == 0 &&
   492                 iov[iov_count].iov_base = buf->
buf[0].
mem;
   493                 iov[iov_count].iov_len = len;
   495                 return fuse_send_msg(se, ch, iov, iov_count);
   498         res = posix_memalign(&mbuf, pagesize, len);
   502         mem_buf.
buf[0].
mem = mbuf;
   510         iov[iov_count].iov_base = mbuf;
   511         iov[iov_count].iov_len = len;
   513         res = fuse_send_msg(se, ch, iov, iov_count);
   519 struct fuse_ll_pipe {
   525 static void fuse_ll_pipe_free(
struct fuse_ll_pipe *llp)
   533 #if !defined(HAVE_PIPE2) || !defined(O_CLOEXEC)   534 static int fuse_pipe(
int fds[2])
   541         if (fcntl(fds[0], F_SETFL, O_NONBLOCK) == -1 ||
   542             fcntl(fds[1], F_SETFL, O_NONBLOCK) == -1 ||
   543             fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
   544             fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
   552 static int fuse_pipe(
int fds[2])
   554         return pipe2(fds, O_CLOEXEC | O_NONBLOCK);
   558 static struct fuse_ll_pipe *fuse_ll_get_pipe(
struct fuse_session *se)
   560         struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
   564                 llp = malloc(
sizeof(
struct fuse_ll_pipe));
   568                 res = fuse_pipe(llp->pipe);
   577                 llp->size = pagesize * 16;
   580                 pthread_setspecific(se->pipe_key, llp);
   587 static void fuse_ll_clear_pipe(
struct fuse_session *se)
   589         struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
   591                 pthread_setspecific(se->pipe_key, NULL);
   592                 fuse_ll_pipe_free(llp);
   596 #if defined(HAVE_SPLICE) && defined(HAVE_VMSPLICE)   597 static int read_back(
int fd, 
char *buf, 
size_t len)
   601         res = read(fd, buf, len);
   603                 fuse_log(FUSE_LOG_ERR, 
"fuse: internal error: failed to read back from pipe: %s\n", strerror(errno));
   607                 fuse_log(FUSE_LOG_ERR, 
"fuse: internal error: short read back from pipe: %i from %zi\n", res, len);
   613 static int grow_pipe_to_max(
int pipefd)
   620         maxfd = open(
"/proc/sys/fs/pipe-max-size", O_RDONLY);
   624         res = read(maxfd, buf, 
sizeof(buf) - 1);
   636         res = fcntl(pipefd, F_SETPIPE_SZ, max);
   642 static int fuse_send_data_iov(
struct fuse_session *se, 
struct fuse_chan *ch,
   643                                struct iovec *iov, 
int iov_count,
   648         struct fuse_out_header *out = iov[0].iov_base;
   649         struct fuse_ll_pipe *llp;
   652         size_t total_buf_size;
   655         struct fuse_bufvec pipe_buf = FUSE_BUFVEC_INIT(len);
   657         if (se->broken_splice_nonblock)
   664         for (idx = buf->
idx; idx < buf->count; idx++) {
   667                         total_buf_size -= buf->
off;
   669         if (total_buf_size < 2 * pagesize)
   672         if (se->conn.proto_minor < 14 ||
   676         llp = fuse_ll_get_pipe(se);
   681         headerlen = iov_length(iov, iov_count);
   683         out->len = headerlen + len;
   689         pipesize = pagesize * (iov_count + buf->
count + 1) + out->len;
   691         if (llp->size < pipesize) {
   693                         res = fcntl(llp->pipe[0], F_SETPIPE_SZ, pipesize);
   695                                 res = grow_pipe_to_max(llp->pipe[0]);
   703                 if (llp->size < pipesize)
   708         res = vmsplice(llp->pipe[1], iov, iov_count, SPLICE_F_NONBLOCK);
   712         if (res != headerlen) {
   714                 fuse_log(FUSE_LOG_ERR, 
"fuse: short vmsplice to pipe: %u/%zu\n", res,
   720         pipe_buf.
buf[0].
fd = llp->pipe[1];
   725                 if (res == -EAGAIN || res == -EINVAL) {
   737                                 se->broken_splice_nonblock = 1;
   739                         pthread_setspecific(se->pipe_key, NULL);
   740                         fuse_ll_pipe_free(llp);
   747         if (res != 0 && res < len) {
   748                 struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
   750                 size_t now_len = res;
   760                 res = posix_memalign(&mbuf, pagesize, len);
   764                 mem_buf.
buf[0].
mem = mbuf;
   765                 mem_buf.
off = now_len;
   769                         size_t extra_len = res;
   775                         tmpbuf = malloc(headerlen);
   776                         if (tmpbuf == NULL) {
   781                         res = read_back(llp->pipe[0], tmpbuf, headerlen);
   787                         res = read_back(llp->pipe[0], mbuf, now_len);
   792                         len = now_len + extra_len;
   793                         iov[iov_count].iov_base = mbuf;
   794                         iov[iov_count].iov_len = len;
   796                         res = fuse_send_msg(se, ch, iov, iov_count);
   804         out->len = headerlen + len;
   808                         "   unique: %llu, success, outsize: %i (splice)\n",
   809                         (
unsigned long long) out->unique, out->len);
   815                 splice_flags |= SPLICE_F_MOVE;
   817         res = splice(llp->pipe[0], NULL, ch ? ch->fd : se->fd,
   818                      NULL, out->len, splice_flags);
   821                 perror(
"fuse: splice from pipe");
   824         if (res != out->len) {
   826                 fuse_log(FUSE_LOG_ERR, 
"fuse: short splice from pipe: %u/%u\n",
   833         fuse_ll_clear_pipe(se);
   837         return fuse_send_data_iov_fallback(se, ch, iov, iov_count, buf, len);
   840 static int fuse_send_data_iov(
struct fuse_session *se, 
struct fuse_chan *ch,
   841                                struct iovec *iov, 
int iov_count,
   847         return fuse_send_data_iov_fallback(se, ch, iov, iov_count, buf, len);
   855         struct fuse_out_header out;
   858         iov[0].iov_base = &out;
   859         iov[0].iov_len = 
sizeof(
struct fuse_out_header);
   861         out.unique = req->unique;
   864         res = fuse_send_data_iov(req->se, req->ch, iov, 1, bufv, flags);
   875         struct fuse_statfs_out arg;
   876         size_t size = req->se->conn.proto_minor < 4 ?
   877                 FUSE_COMPAT_STATFS_SIZE : 
sizeof(arg);
   879         memset(&arg, 0, 
sizeof(arg));
   880         convert_statfs(stbuf, &arg.st);
   882         return send_reply_ok(req, &arg, size);
   887         struct fuse_getxattr_out arg;
   889         memset(&arg, 0, 
sizeof(arg));
   892         return send_reply_ok(req, &arg, 
sizeof(arg));
   897         struct fuse_lk_out arg;
   899         memset(&arg, 0, 
sizeof(arg));
   900         arg.lk.type = lock->l_type;
   901         if (lock->l_type != F_UNLCK) {
   902                 arg.lk.start = lock->l_start;
   903                 if (lock->l_len == 0)
   904                         arg.lk.end = OFFSET_MAX;
   906                         arg.lk.end = lock->l_start + lock->l_len - 1;
   908         arg.lk.pid = lock->l_pid;
   909         return send_reply_ok(req, &arg, 
sizeof(arg));
   914         struct fuse_bmap_out arg;
   916         memset(&arg, 0, 
sizeof(arg));
   919         return send_reply_ok(req, &arg, 
sizeof(arg));
   922 static struct fuse_ioctl_iovec *fuse_ioctl_iovec_copy(
const struct iovec *iov,
   925         struct fuse_ioctl_iovec *fiov;
   928         fiov = malloc(
sizeof(fiov[0]) * count);
   932         for (i = 0; i < count; i++) {
   933                 fiov[i].base = (uintptr_t) iov[i].iov_base;
   934                 fiov[i].len = iov[i].iov_len;
   941                            const struct iovec *in_iov, 
size_t in_count,
   942                            const struct iovec *out_iov, 
size_t out_count)
   944         struct fuse_ioctl_out arg;
   945         struct fuse_ioctl_iovec *in_fiov = NULL;
   946         struct fuse_ioctl_iovec *out_fiov = NULL;
   951         memset(&arg, 0, 
sizeof(arg));
   952         arg.flags |= FUSE_IOCTL_RETRY;
   953         arg.in_iovs = in_count;
   954         arg.out_iovs = out_count;
   955         iov[count].iov_base = &arg;
   956         iov[count].iov_len = 
sizeof(arg);
   959         if (req->se->conn.proto_minor < 16) {
   961                         iov[count].iov_base = (
void *)in_iov;
   962                         iov[count].iov_len = 
sizeof(in_iov[0]) * in_count;
   967                         iov[count].iov_base = (
void *)out_iov;
   968                         iov[count].iov_len = 
sizeof(out_iov[0]) * out_count;
   973                 if (
sizeof(
void *) == 4 && req->ioctl_64bit) {
   979                         in_fiov = fuse_ioctl_iovec_copy(in_iov, in_count);
   983                         iov[count].iov_base = (
void *)in_fiov;
   984                         iov[count].iov_len = 
sizeof(in_fiov[0]) * in_count;
   988                         out_fiov = fuse_ioctl_iovec_copy(out_iov, out_count);
   992                         iov[count].iov_base = (
void *)out_fiov;
   993                         iov[count].iov_len = 
sizeof(out_fiov[0]) * out_count;
   998         res = send_reply_iov(req, 0, iov, count);
  1012         struct fuse_ioctl_out arg;
  1013         struct iovec iov[3];
  1016         memset(&arg, 0, 
sizeof(arg));
  1017         arg.result = result;
  1018         iov[count].iov_base = &arg;
  1019         iov[count].iov_len = 
sizeof(arg);
  1023                 iov[count].iov_base = (
char *) buf;
  1024                 iov[count].iov_len = size;
  1028         return send_reply_iov(req, 0, iov, count);
  1034         struct iovec *padded_iov;
  1035         struct fuse_ioctl_out arg;
  1038         padded_iov = malloc((count + 2) * 
sizeof(
struct iovec));
  1039         if (padded_iov == NULL)
  1042         memset(&arg, 0, 
sizeof(arg));
  1043         arg.result = result;
  1044         padded_iov[1].iov_base = &arg;
  1045         padded_iov[1].iov_len = 
sizeof(arg);
  1047         memcpy(&padded_iov[2], iov, count * 
sizeof(
struct iovec));
  1049         res = send_reply_iov(req, 0, padded_iov, count + 2);
  1057         struct fuse_poll_out arg;
  1059         memset(&arg, 0, 
sizeof(arg));
  1060         arg.revents = revents;
  1062         return send_reply_ok(req, &arg, 
sizeof(arg));
  1067         struct fuse_lseek_out arg;
  1069         memset(&arg, 0, 
sizeof(arg));
  1072         return send_reply_ok(req, &arg, 
sizeof(arg));
  1077         char *name = (
char *) inarg;
  1079         if (req->se->op.lookup)
  1080                 req->se->op.lookup(req, nodeid, name);
  1087         struct fuse_forget_in *arg = (
struct fuse_forget_in *) inarg;
  1089         if (req->se->op.forget)
  1090                 req->se->op.forget(req, nodeid, arg->nlookup);
  1098         struct fuse_batch_forget_in *arg = (
void *) inarg;
  1099         struct fuse_forget_one *param = (
void *) PARAM(arg);
  1104         if (req->se->op.forget_multi) {
  1105                 req->se->op.forget_multi(req, arg->count,
  1106                                      (
struct fuse_forget_data *) param);
  1107         } 
else if (req->se->op.forget) {
  1108                 for (i = 0; i < arg->count; i++) {
  1109                         struct fuse_forget_one *forget = ¶m[i];
  1110                         struct fuse_req *dummy_req;
  1112                         dummy_req = fuse_ll_alloc_req(req->se);
  1113                         if (dummy_req == NULL)
  1116                         dummy_req->unique = req->unique;
  1117                         dummy_req->ctx = req->ctx;
  1118                         dummy_req->ch = NULL;
  1120                         req->se->op.forget(dummy_req, forget->nodeid,
  1134         if (req->se->conn.proto_minor >= 9) {
  1135                 struct fuse_getattr_in *arg = (
struct fuse_getattr_in *) inarg;
  1137                 if (arg->getattr_flags & FUSE_GETATTR_FH) {
  1138                         memset(&fi, 0, 
sizeof(fi));
  1144         if (req->se->op.getattr)
  1145                 req->se->op.getattr(req, nodeid, fip);
  1152         struct fuse_setattr_in *arg = (
struct fuse_setattr_in *) inarg;
  1154         if (req->se->op.setattr) {
  1158                 memset(&stbuf, 0, 
sizeof(stbuf));
  1159                 convert_attr(arg, &stbuf);
  1160                 if (arg->valid & FATTR_FH) {
  1161                         arg->valid &= ~FATTR_FH;
  1162                         memset(&fi_store, 0, 
sizeof(fi_store));
  1167                         FUSE_SET_ATTR_MODE      |
  1170                         FUSE_SET_ATTR_SIZE      |
  1171                         FUSE_SET_ATTR_ATIME     |
  1172                         FUSE_SET_ATTR_MTIME     |
  1173                         FUSE_SET_ATTR_ATIME_NOW |
  1174                         FUSE_SET_ATTR_MTIME_NOW |
  1175                         FUSE_SET_ATTR_CTIME;
  1177                 req->se->op.setattr(req, nodeid, &stbuf, arg->valid, fi);
  1184         struct fuse_access_in *arg = (
struct fuse_access_in *) inarg;
  1186         if (req->se->op.access)
  1187                 req->se->op.access(req, nodeid, arg->mask);
  1196         if (req->se->op.readlink)
  1197                 req->se->op.readlink(req, nodeid);
  1204         struct fuse_mknod_in *arg = (
struct fuse_mknod_in *) inarg;
  1205         char *name = PARAM(arg);
  1207         if (req->se->conn.proto_minor >= 12)
  1208                 req->ctx.umask = arg->umask;
  1210                 name = (
char *) inarg + FUSE_COMPAT_MKNOD_IN_SIZE;
  1212         if (req->se->op.mknod)
  1213                 req->se->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
  1220         struct fuse_mkdir_in *arg = (
struct fuse_mkdir_in *) inarg;
  1222         if (req->se->conn.proto_minor >= 12)
  1223                 req->ctx.umask = arg->umask;
  1225         if (req->se->op.mkdir)
  1226                 req->se->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
  1233         char *name = (
char *) inarg;
  1235         if (req->se->op.unlink)
  1236                 req->se->op.unlink(req, nodeid, name);
  1243         char *name = (
char *) inarg;
  1245         if (req->se->op.rmdir)
  1246                 req->se->op.rmdir(req, nodeid, name);
  1253         char *name = (
char *) inarg;
  1254         char *linkname = ((
char *) inarg) + strlen((
char *) inarg) + 1;
  1256         if (req->se->op.symlink)
  1257                 req->se->op.symlink(req, linkname, nodeid, name);
  1264         struct fuse_rename_in *arg = (
struct fuse_rename_in *) inarg;
  1265         char *oldname = PARAM(arg);
  1266         char *newname = oldname + strlen(oldname) + 1;
  1268         if (req->se->op.rename)
  1269                 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
  1277         struct fuse_rename2_in *arg = (
struct fuse_rename2_in *) inarg;
  1278         char *oldname = PARAM(arg);
  1279         char *newname = oldname + strlen(oldname) + 1;
  1281         if (req->se->op.rename)
  1282                 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
  1290         struct fuse_link_in *arg = (
struct fuse_link_in *) inarg;
  1292         if (req->se->op.link)
  1293                 req->se->op.link(req, arg->oldnodeid, nodeid, PARAM(arg));
  1300         struct fuse_create_in *arg = (
struct fuse_create_in *) inarg;
  1302         if (req->se->op.create) {
  1304                 char *name = PARAM(arg);
  1306                 memset(&fi, 0, 
sizeof(fi));
  1307                 fi.
flags = arg->flags;
  1309                 if (req->se->conn.proto_minor >= 12)
  1310                         req->ctx.umask = arg->umask;
  1312                         name = (
char *) inarg + 
sizeof(
struct fuse_open_in);
  1314                 req->se->op.create(req, nodeid, name, arg->mode, &fi);
  1321         struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
  1324         memset(&fi, 0, 
sizeof(fi));
  1325         fi.
flags = arg->flags;
  1327         if (req->se->op.open)
  1328                 req->se->op.open(req, nodeid, &fi);
  1335         struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
  1337         if (req->se->op.read) {
  1340                 memset(&fi, 0, 
sizeof(fi));
  1342                 if (req->se->conn.proto_minor >= 9) {
  1344                         fi.
flags = arg->flags;
  1346                 req->se->op.read(req, nodeid, arg->size, arg->offset, &fi);
  1353         struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
  1357         memset(&fi, 0, 
sizeof(fi));
  1359         fi.
writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
  1361         if (req->se->conn.proto_minor < 9) {
  1362                 param = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
  1365                 fi.
flags = arg->flags;
  1369         if (req->se->op.write)
  1370                 req->se->op.write(req, nodeid, param, arg->size,
  1379         struct fuse_session *se = req->se;
  1384         struct fuse_write_in *arg = (
struct fuse_write_in *) inarg;
  1387         memset(&fi, 0, 
sizeof(fi));
  1389         fi.
writepage = arg->write_flags & FUSE_WRITE_CACHE;
  1391         if (se->conn.proto_minor < 9) {
  1392                 bufv.
buf[0].
mem = ((
char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
  1393                 bufv.
buf[0].
size -= 
sizeof(
struct fuse_in_header) +
  1394                         FUSE_COMPAT_WRITE_IN_SIZE;
  1398                 fi.
flags = arg->flags;
  1400                         bufv.
buf[0].
mem = PARAM(arg);
  1402                 bufv.
buf[0].
size -= 
sizeof(
struct fuse_in_header) +
  1403                         sizeof(struct fuse_write_in);
  1405         if (bufv.
buf[0].
size < arg->size) {
  1406                 fuse_log(FUSE_LOG_ERR, 
"fuse: do_write_buf: buffer size too small\n");
  1412         se->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
  1417                 fuse_ll_clear_pipe(se);
  1422         struct fuse_flush_in *arg = (
struct fuse_flush_in *) inarg;
  1425         memset(&fi, 0, 
sizeof(fi));
  1428         if (req->se->conn.proto_minor >= 7)
  1431         if (req->se->op.flush)
  1432                 req->se->op.flush(req, nodeid, &fi);
  1439         struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
  1442         memset(&fi, 0, 
sizeof(fi));
  1443         fi.
flags = arg->flags;
  1445         if (req->se->conn.proto_minor >= 8) {
  1446                 fi.
flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
  1449         if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) {
  1450                 fi.flock_release = 1;
  1454         if (req->se->op.release)
  1455                 req->se->op.release(req, nodeid, &fi);
  1462         struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
  1464         int datasync = arg->fsync_flags & 1;
  1466         memset(&fi, 0, 
sizeof(fi));
  1469         if (req->se->op.fsync)
  1470                 req->se->op.fsync(req, nodeid, datasync, &fi);
  1477         struct fuse_open_in *arg = (
struct fuse_open_in *) inarg;
  1480         memset(&fi, 0, 
sizeof(fi));
  1481         fi.
flags = arg->flags;
  1483         if (req->se->op.opendir)
  1484                 req->se->op.opendir(req, nodeid, &fi);
  1491         struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
  1494         memset(&fi, 0, 
sizeof(fi));
  1497         if (req->se->op.readdir)
  1498                 req->se->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
  1505         struct fuse_read_in *arg = (
struct fuse_read_in *) inarg;
  1508         memset(&fi, 0, 
sizeof(fi));
  1511         if (req->se->op.readdirplus)
  1512                 req->se->op.readdirplus(req, nodeid, arg->size, arg->offset, &fi);
  1519         struct fuse_release_in *arg = (
struct fuse_release_in *) inarg;
  1522         memset(&fi, 0, 
sizeof(fi));
  1523         fi.
flags = arg->flags;
  1526         if (req->se->op.releasedir)
  1527                 req->se->op.releasedir(req, nodeid, &fi);
  1534         struct fuse_fsync_in *arg = (
struct fuse_fsync_in *) inarg;
  1536         int datasync = arg->fsync_flags & 1;
  1538         memset(&fi, 0, 
sizeof(fi));
  1541         if (req->se->op.fsyncdir)
  1542                 req->se->op.fsyncdir(req, nodeid, datasync, &fi);
  1552         if (req->se->op.statfs)
  1553                 req->se->op.statfs(req, nodeid);
  1555                 struct statvfs buf = {
  1565         struct fuse_setxattr_in *arg = (
struct fuse_setxattr_in *) inarg;
  1566         char *name = PARAM(arg);
  1567         char *value = name + strlen(name) + 1;
  1569         if (req->se->op.setxattr)
  1570                 req->se->op.setxattr(req, nodeid, name, value, arg->size,
  1578         struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
  1580         if (req->se->op.getxattr)
  1581                 req->se->op.getxattr(req, nodeid, PARAM(arg), arg->size);
  1588         struct fuse_getxattr_in *arg = (
struct fuse_getxattr_in *) inarg;
  1590         if (req->se->op.listxattr)
  1591                 req->se->op.listxattr(req, nodeid, arg->size);
  1598         char *name = (
char *) inarg;
  1600         if (req->se->op.removexattr)
  1601                 req->se->op.removexattr(req, nodeid, name);
  1606 static void convert_fuse_file_lock(
struct fuse_file_lock *fl,
  1607                                    struct flock *flock)
  1609         memset(flock, 0, 
sizeof(
struct flock));
  1610         flock->l_type = fl->type;
  1611         flock->l_whence = SEEK_SET;
  1612         flock->l_start = fl->start;
  1613         if (fl->end == OFFSET_MAX)
  1616                 flock->l_len = fl->end - fl->start + 1;
  1617         flock->l_pid = fl->pid;
  1622         struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
  1626         memset(&fi, 0, 
sizeof(fi));
  1630         convert_fuse_file_lock(&arg->lk, &flock);
  1631         if (req->se->op.getlk)
  1632                 req->se->op.getlk(req, nodeid, &fi, &flock);
  1638                             const void *inarg, 
int sleep)
  1640         struct fuse_lk_in *arg = (
struct fuse_lk_in *) inarg;
  1644         memset(&fi, 0, 
sizeof(fi));
  1648         if (arg->lk_flags & FUSE_LK_FLOCK) {
  1651                 switch (arg->lk.type) {
  1665                 if (req->se->op.flock)
  1666                         req->se->op.flock(req, nodeid, &fi, op);
  1670                 convert_fuse_file_lock(&arg->lk, &flock);
  1671                 if (req->se->op.setlk)
  1672                         req->se->op.setlk(req, nodeid, &fi, &flock, sleep);
  1680         do_setlk_common(req, nodeid, inarg, 0);
  1685         do_setlk_common(req, nodeid, inarg, 1);
  1688 static int find_interrupted(
struct fuse_session *se, 
struct fuse_req *req)
  1690         struct fuse_req *curr;
  1692         for (curr = se->list.next; curr != &se->list; curr = curr->next) {
  1693                 if (curr->unique == req->u.i.unique) {
  1698                         pthread_mutex_unlock(&se->lock);
  1701                         pthread_mutex_lock(&curr->lock);
  1702                         pthread_mutex_lock(&se->lock);
  1703                         curr->interrupted = 1;
  1704                         func = curr->u.ni.func;
  1705                         data = curr->u.ni.data;
  1706                         pthread_mutex_unlock(&se->lock);
  1709                         pthread_mutex_unlock(&curr->lock);
  1711                         pthread_mutex_lock(&se->lock);
  1719         for (curr = se->interrupts.next; curr != &se->interrupts;
  1720              curr = curr->next) {
  1721                 if (curr->u.i.unique == req->u.i.unique)
  1729         struct fuse_interrupt_in *arg = (
struct fuse_interrupt_in *) inarg;
  1730         struct fuse_session *se = req->se;
  1734                 fuse_log(FUSE_LOG_DEBUG, 
"INTERRUPT: %llu\n",
  1735                         (
unsigned long long) arg->unique);
  1737         req->u.i.unique = arg->unique;
  1739         pthread_mutex_lock(&se->lock);
  1740         if (find_interrupted(se, req))
  1743                 list_add_req(req, &se->interrupts);
  1744         pthread_mutex_unlock(&se->lock);
  1747 static struct fuse_req *check_interrupt(
struct fuse_session *se,
  1748                                         struct fuse_req *req)
  1750         struct fuse_req *curr;
  1752         for (curr = se->interrupts.next; curr != &se->interrupts;
  1753              curr = curr->next) {
  1754                 if (curr->u.i.unique == req->unique) {
  1755                         req->interrupted = 1;
  1761         curr = se->interrupts.next;
  1762         if (curr != &se->interrupts) {
  1764                 list_init_req(curr);
  1772         struct fuse_bmap_in *arg = (
struct fuse_bmap_in *) inarg;
  1774         if (req->se->op.bmap)
  1775                 req->se->op.bmap(req, nodeid, arg->blocksize, arg->block);
  1782         struct fuse_ioctl_in *arg = (
struct fuse_ioctl_in *) inarg;
  1783         unsigned int flags = arg->flags;
  1784         void *in_buf = arg->in_size ? PARAM(arg) : NULL;
  1787         if (flags & FUSE_IOCTL_DIR &&
  1793         memset(&fi, 0, 
sizeof(fi));
  1796         if (
sizeof(
void *) == 4 && req->se->conn.proto_minor >= 16 &&
  1797             !(flags & FUSE_IOCTL_32BIT)) {
  1798                 req->ioctl_64bit = 1;
  1801         if (req->se->op.ioctl)
  1802                 req->se->op.ioctl(req, nodeid, arg->cmd,
  1803                                  (
void *)(uintptr_t)arg->arg, &fi, flags,
  1804                                  in_buf, arg->in_size, arg->out_size);
  1816         struct fuse_poll_in *arg = (
struct fuse_poll_in *) inarg;
  1819         memset(&fi, 0, 
sizeof(fi));
  1823         if (req->se->op.poll) {
  1824                 struct fuse_pollhandle *ph = NULL;
  1826                 if (arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) {
  1827                         ph = malloc(
sizeof(
struct fuse_pollhandle));
  1836                 req->se->op.poll(req, nodeid, &fi, ph);
  1844         struct fuse_fallocate_in *arg = (
struct fuse_fallocate_in *) inarg;
  1847         memset(&fi, 0, 
sizeof(fi));
  1850         if (req->se->op.fallocate)
  1851                 req->se->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi);
  1858         struct fuse_copy_file_range_in *arg = (
struct fuse_copy_file_range_in *) inarg;
  1861         memset(&fi_in, 0, 
sizeof(fi_in));
  1862         fi_in.fh = arg->fh_in;
  1864         memset(&fi_out, 0, 
sizeof(fi_out));
  1865         fi_out.fh = arg->fh_out;
  1868         if (req->se->op.copy_file_range)
  1869                 req->se->op.copy_file_range(req, nodeid_in, arg->off_in,
  1870                                             &fi_in, arg->nodeid_out,
  1871                                             arg->off_out, &fi_out, arg->len,
  1879         struct fuse_lseek_in *arg = (
struct fuse_lseek_in *) inarg;
  1882         memset(&fi, 0, 
sizeof(fi));
  1885         if (req->se->op.lseek)
  1886                 req->se->op.lseek(req, nodeid, arg->offset, arg->whence, &fi);
  1893         struct fuse_init_in *arg = (
struct fuse_init_in *) inarg;
  1894         struct fuse_init_out outarg;
  1895         struct fuse_session *se = req->se;
  1896         size_t bufsize = se->bufsize;
  1897         size_t outargsize = 
sizeof(outarg);
  1901                 fuse_log(FUSE_LOG_DEBUG, 
"INIT: %u.%u\n", arg->major, arg->minor);
  1902                 if (arg->major == 7 && arg->minor >= 6) {
  1903                         fuse_log(FUSE_LOG_DEBUG, 
"flags=0x%08x\n", arg->flags);
  1904                         fuse_log(FUSE_LOG_DEBUG, 
"max_readahead=0x%08x\n",
  1905                                 arg->max_readahead);
  1908         se->conn.proto_major = arg->major;
  1909         se->conn.proto_minor = arg->minor;
  1910         se->conn.capable = 0;
  1913         memset(&outarg, 0, 
sizeof(outarg));
  1914         outarg.major = FUSE_KERNEL_VERSION;
  1915         outarg.minor = FUSE_KERNEL_MINOR_VERSION;
  1917         if (arg->major < 7) {
  1918                 fuse_log(FUSE_LOG_ERR, 
"fuse: unsupported protocol version: %u.%u\n",
  1919                         arg->major, arg->minor);
  1924         if (arg->major > 7) {
  1926                 send_reply_ok(req, &outarg, 
sizeof(outarg));
  1930         if (arg->minor >= 6) {
  1931                 if (arg->max_readahead < se->conn.max_readahead)
  1932                         se->conn.max_readahead = arg->max_readahead;
  1933                 if (arg->flags & FUSE_ASYNC_READ)
  1935                 if (arg->flags & FUSE_POSIX_LOCKS)
  1937                 if (arg->flags & FUSE_ATOMIC_O_TRUNC)
  1939                 if (arg->flags & FUSE_EXPORT_SUPPORT)
  1941                 if (arg->flags & FUSE_DONT_MASK)
  1943                 if (arg->flags & FUSE_FLOCK_LOCKS)
  1945                 if (arg->flags & FUSE_AUTO_INVAL_DATA)
  1947                 if (arg->flags & FUSE_DO_READDIRPLUS)
  1949                 if (arg->flags & FUSE_READDIRPLUS_AUTO)
  1951                 if (arg->flags & FUSE_ASYNC_DIO)
  1953                 if (arg->flags & FUSE_WRITEBACK_CACHE)
  1955                 if (arg->flags & FUSE_NO_OPEN_SUPPORT)
  1957                 if (arg->flags & FUSE_PARALLEL_DIROPS)
  1959                 if (arg->flags & FUSE_POSIX_ACL)
  1961                 if (arg->flags & FUSE_HANDLE_KILLPRIV)
  1963                 if (arg->flags & FUSE_NO_OPENDIR_SUPPORT)
  1965                 if (arg->flags & FUSE_EXPLICIT_INVAL_DATA)
  1967                 if (!(arg->flags & FUSE_MAX_PAGES)) {
  1968                         size_t max_bufsize =
  1969                                 FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
  1970                                 + FUSE_BUFFER_HEADER_SIZE;
  1971                         if (bufsize > max_bufsize) {
  1972                                 bufsize = max_bufsize;
  1976                 se->conn.max_readahead = 0;
  1979         if (se->conn.proto_minor >= 14) {
  1981 #ifdef HAVE_VMSPLICE  1987         if (se->conn.proto_minor >= 18)
  1997 #define LL_SET_DEFAULT(cond, cap) \  1998         if ((cond) && (se->conn.capable & (cap))) \  1999                 se->conn.want |= (cap)  2008         LL_SET_DEFAULT(se->op.getlk && se->op.setlk,
  2012         LL_SET_DEFAULT(se->op.readdirplus && se->op.readdir,
  2014         se->conn.time_gran = 1;
  2016         if (bufsize < FUSE_MIN_READ_BUFFER) {
  2017                 fuse_log(FUSE_LOG_ERR, 
"fuse: warning: buffer size too small: %zu\n",
  2019                 bufsize = FUSE_MIN_READ_BUFFER;
  2021         se->bufsize = bufsize;
  2023         if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE)
  2024                 se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE;
  2028                 se->op.init(se->userdata, &se->conn);
  2030         if (se->conn.want & (~se->conn.capable)) {
  2031                 fuse_log(FUSE_LOG_ERR, 
"fuse: error: filesystem requested capabilities "  2032                         "0x%x that are not supported by kernel, aborting.\n",
  2033                         se->conn.want & (~se->conn.capable));
  2035                 se->error = -EPROTO;
  2040         unsigned max_read_mo = get_max_read(se->mo);
  2041         if (se->conn.max_read != max_read_mo) {
  2042                 fuse_log(FUSE_LOG_ERR, 
"fuse: error: init() and fuse_session_new() "  2043                         "requested different maximum read size (%u vs %u)\n",
  2044                         se->conn.max_read, max_read_mo);
  2046                 se->error = -EPROTO;
  2051         if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE) {
  2052                 se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
  2054         if (arg->flags & FUSE_MAX_PAGES) {
  2055                 outarg.flags |= FUSE_MAX_PAGES;
  2056                 outarg.max_pages = (se->conn.max_write - 1) / getpagesize() + 1;
  2061         outarg.flags |= FUSE_BIG_WRITES;
  2064                 outarg.flags |= FUSE_ASYNC_READ;
  2066                 outarg.flags |= FUSE_POSIX_LOCKS;
  2068                 outarg.flags |= FUSE_ATOMIC_O_TRUNC;
  2070                 outarg.flags |= FUSE_EXPORT_SUPPORT;
  2072                 outarg.flags |= FUSE_DONT_MASK;
  2074                 outarg.flags |= FUSE_FLOCK_LOCKS;
  2076                 outarg.flags |= FUSE_AUTO_INVAL_DATA;
  2078                 outarg.flags |= FUSE_DO_READDIRPLUS;
  2080                 outarg.flags |= FUSE_READDIRPLUS_AUTO;
  2082                 outarg.flags |= FUSE_ASYNC_DIO;
  2084                 outarg.flags |= FUSE_WRITEBACK_CACHE;
  2086                 outarg.flags |= FUSE_POSIX_ACL;
  2088                 outarg.flags |= FUSE_EXPLICIT_INVAL_DATA;
  2089         outarg.max_readahead = se->conn.max_readahead;
  2090         outarg.max_write = se->conn.max_write;
  2091         if (se->conn.proto_minor >= 13) {
  2092                 if (se->conn.max_background >= (1 << 16))
  2093                         se->conn.max_background = (1 << 16) - 1;
  2094                 if (se->conn.congestion_threshold > se->conn.max_background)
  2095                         se->conn.congestion_threshold = se->conn.max_background;
  2096                 if (!se->conn.congestion_threshold) {
  2097                         se->conn.congestion_threshold =
  2098                                 se->conn.max_background * 3 / 4;
  2101                 outarg.max_background = se->conn.max_background;
  2102                 outarg.congestion_threshold = se->conn.congestion_threshold;
  2104         if (se->conn.proto_minor >= 23)
  2105                 outarg.time_gran = se->conn.time_gran;
  2108                 fuse_log(FUSE_LOG_DEBUG, 
"   INIT: %u.%u\n", outarg.major, outarg.minor);
  2109                 fuse_log(FUSE_LOG_DEBUG, 
"   flags=0x%08x\n", outarg.flags);
  2110                 fuse_log(FUSE_LOG_DEBUG, 
"   max_readahead=0x%08x\n",
  2111                         outarg.max_readahead);
  2112                 fuse_log(FUSE_LOG_DEBUG, 
"   max_write=0x%08x\n", outarg.max_write);
  2113                 fuse_log(FUSE_LOG_DEBUG, 
"   max_background=%i\n",
  2114                         outarg.max_background);
  2115                 fuse_log(FUSE_LOG_DEBUG, 
"   congestion_threshold=%i\n",
  2116                         outarg.congestion_threshold);
  2117                 fuse_log(FUSE_LOG_DEBUG, 
"   time_gran=%u\n",
  2121                 outargsize = FUSE_COMPAT_INIT_OUT_SIZE;
  2122         else if (arg->minor < 23)
  2123                 outargsize = FUSE_COMPAT_22_INIT_OUT_SIZE;
  2125         send_reply_ok(req, &outarg, outargsize);
  2130         struct fuse_session *se = req->se;
  2135         se->got_destroy = 1;
  2137                 se->op.destroy(se->userdata);
  2139         send_reply_ok(req, NULL, 0);
  2142 static void list_del_nreq(
struct fuse_notify_req *nreq)
  2144         struct fuse_notify_req *prev = nreq->prev;
  2145         struct fuse_notify_req *next = nreq->next;
  2150 static void list_add_nreq(
struct fuse_notify_req *nreq,
  2151                           struct fuse_notify_req *next)
  2153         struct fuse_notify_req *prev = next->prev;
  2160 static void list_init_nreq(
struct fuse_notify_req *nreq)
  2167                             const void *inarg, 
const struct fuse_buf *buf)
  2169         struct fuse_session *se = req->se;
  2170         struct fuse_notify_req *nreq;
  2171         struct fuse_notify_req *head;
  2173         pthread_mutex_lock(&se->lock);
  2174         head = &se->notify_list;
  2175         for (nreq = head->next; nreq != head; nreq = nreq->next) {
  2176                 if (nreq->unique == req->unique) {
  2177                         list_del_nreq(nreq);
  2181         pthread_mutex_unlock(&se->lock);
  2184                 nreq->reply(nreq, req, nodeid, inarg, buf);
  2187 static int send_notify_iov(
struct fuse_session *se, 
int notify_code,
  2188                            struct iovec *iov, 
int count)
  2190         struct fuse_out_header out;
  2196         out.error = notify_code;
  2197         iov[0].iov_base = &out;
  2198         iov[0].iov_len = 
sizeof(
struct fuse_out_header);
  2200         return fuse_send_msg(se, NULL, iov, count);
  2206                 struct fuse_notify_poll_wakeup_out outarg;
  2207                 struct iovec iov[2];
  2211                 iov[1].iov_base = &outarg;
  2212                 iov[1].iov_len = 
sizeof(outarg);
  2214                 return send_notify_iov(ph->se, FUSE_NOTIFY_POLL, iov, 2);
  2221                                      off_t off, off_t len)
  2223         struct fuse_notify_inval_inode_out outarg;
  2224         struct iovec iov[2];
  2229         if (se->conn.proto_minor < 12)
  2236         iov[1].iov_base = &outarg;
  2237         iov[1].iov_len = 
sizeof(outarg);
  2239         return send_notify_iov(se, FUSE_NOTIFY_INVAL_INODE, iov, 2);
  2243                                      const char *name, 
size_t namelen)
  2245         struct fuse_notify_inval_entry_out outarg;
  2246         struct iovec iov[3];
  2251         if (se->conn.proto_minor < 12)
  2254         outarg.parent = parent;
  2255         outarg.namelen = namelen;
  2258         iov[1].iov_base = &outarg;
  2259         iov[1].iov_len = 
sizeof(outarg);
  2260         iov[2].iov_base = (
void *)name;
  2261         iov[2].iov_len = namelen + 1;
  2263         return send_notify_iov(se, FUSE_NOTIFY_INVAL_ENTRY, iov, 3);
  2268                                 const char *name, 
size_t namelen)
  2270         struct fuse_notify_delete_out outarg;
  2271         struct iovec iov[3];
  2276         if (se->conn.proto_minor < 18)
  2279         outarg.parent = parent;
  2280         outarg.child = child;
  2281         outarg.namelen = namelen;
  2284         iov[1].iov_base = &outarg;
  2285         iov[1].iov_len = 
sizeof(outarg);
  2286         iov[2].iov_base = (
void *)name;
  2287         iov[2].iov_len = namelen + 1;
  2289         return send_notify_iov(se, FUSE_NOTIFY_DELETE, iov, 3);
  2296         struct fuse_out_header out;
  2297         struct fuse_notify_store_out outarg;
  2298         struct iovec iov[3];
  2305         if (se->conn.proto_minor < 15)
  2309         out.error = FUSE_NOTIFY_STORE;
  2311         outarg.nodeid = ino;
  2312         outarg.offset = offset;
  2316         iov[0].iov_base = &out;
  2317         iov[0].iov_len = 
sizeof(out);
  2318         iov[1].iov_base = &outarg;
  2319         iov[1].iov_len = 
sizeof(outarg);
  2321         res = fuse_send_data_iov(se, NULL, iov, 2, bufv, flags);
  2328 struct fuse_retrieve_req {
  2329         struct fuse_notify_req nreq;
  2333 static void fuse_ll_retrieve_reply(
struct fuse_notify_req *nreq,
  2338         struct fuse_session *se = req->se;
  2339         struct fuse_retrieve_req *rreq =
  2340                 container_of(nreq, 
struct fuse_retrieve_req, nreq);
  2341         const struct fuse_notify_retrieve_in *arg = inarg;
  2348                 bufv.
buf[0].
mem = PARAM(arg);
  2350         bufv.
buf[0].
size -= 
sizeof(
struct fuse_in_header) +
  2351                 sizeof(struct fuse_notify_retrieve_in);
  2353         if (bufv.
buf[0].
size < arg->size) {
  2354                 fuse_log(FUSE_LOG_ERR, 
"fuse: retrieve reply: buffer size too small\n");
  2360         if (se->op.retrieve_reply) {
  2361                 se->op.retrieve_reply(req, rreq->cookie, ino,
  2362                                           arg->offset, &bufv);
  2369                 fuse_ll_clear_pipe(se);
  2373                                   size_t size, off_t offset, 
void *cookie)
  2375         struct fuse_notify_retrieve_out outarg;
  2376         struct iovec iov[2];
  2377         struct fuse_retrieve_req *rreq;
  2383         if (se->conn.proto_minor < 15)
  2386         rreq = malloc(
sizeof(*rreq));
  2390         pthread_mutex_lock(&se->lock);
  2391         rreq->cookie = cookie;
  2392         rreq->nreq.unique = se->notify_ctr++;
  2393         rreq->nreq.reply = fuse_ll_retrieve_reply;
  2394         list_add_nreq(&rreq->nreq, &se->notify_list);
  2395         pthread_mutex_unlock(&se->lock);
  2397         outarg.notify_unique = rreq->nreq.unique;
  2398         outarg.nodeid = ino;
  2399         outarg.offset = offset;
  2403         iov[1].iov_base = &outarg;
  2404         iov[1].iov_len = 
sizeof(outarg);
  2406         err = send_notify_iov(se, FUSE_NOTIFY_RETRIEVE, iov, 2);
  2408                 pthread_mutex_lock(&se->lock);
  2409                 list_del_nreq(&rreq->nreq);
  2410                 pthread_mutex_unlock(&se->lock);
  2419         return req->se->userdata;
  2430         pthread_mutex_lock(&req->lock);
  2431         pthread_mutex_lock(&req->se->lock);
  2432         req->u.ni.func = func;
  2433         req->u.ni.data = data;
  2434         pthread_mutex_unlock(&req->se->lock);
  2435         if (req->interrupted && func)
  2437         pthread_mutex_unlock(&req->lock);
  2444         pthread_mutex_lock(&req->se->lock);
  2445         interrupted = req->interrupted;
  2446         pthread_mutex_unlock(&req->se->lock);
  2455         [FUSE_LOOKUP]      = { do_lookup,      
"LOOKUP"      },
  2456         [FUSE_FORGET]      = { do_forget,      
"FORGET"      },
  2457         [FUSE_GETATTR]     = { do_getattr,     
"GETATTR"     },
  2458         [FUSE_SETATTR]     = { do_setattr,     
"SETATTR"     },
  2459         [FUSE_READLINK]    = { do_readlink,    
"READLINK"    },
  2460         [FUSE_SYMLINK]     = { do_symlink,     
"SYMLINK"     },
  2461         [FUSE_MKNOD]       = { do_mknod,       
"MKNOD"       },
  2462         [FUSE_MKDIR]       = { do_mkdir,       
"MKDIR"       },
  2463         [FUSE_UNLINK]      = { do_unlink,      
"UNLINK"      },
  2464         [FUSE_RMDIR]       = { do_rmdir,       
"RMDIR"       },
  2465         [FUSE_RENAME]      = { do_rename,      
"RENAME"      },
  2466         [FUSE_LINK]        = { do_link,        
"LINK"        },
  2467         [FUSE_OPEN]        = { do_open,        
"OPEN"        },
  2468         [FUSE_READ]        = { do_read,        
"READ"        },
  2469         [FUSE_WRITE]       = { do_write,       
"WRITE"       },
  2470         [FUSE_STATFS]      = { do_statfs,      
"STATFS"      },
  2471         [FUSE_RELEASE]     = { do_release,     
"RELEASE"     },
  2472         [FUSE_FSYNC]       = { do_fsync,       
"FSYNC"       },
  2473         [FUSE_SETXATTR]    = { do_setxattr,    
"SETXATTR"    },
  2474         [FUSE_GETXATTR]    = { do_getxattr,    
"GETXATTR"    },
  2475         [FUSE_LISTXATTR]   = { do_listxattr,   
"LISTXATTR"   },
  2476         [FUSE_REMOVEXATTR] = { do_removexattr, 
"REMOVEXATTR" },
  2477         [FUSE_FLUSH]       = { do_flush,       
"FLUSH"       },
  2478         [FUSE_INIT]        = { do_init,        
"INIT"        },
  2479         [FUSE_OPENDIR]     = { do_opendir,     
"OPENDIR"     },
  2480         [FUSE_READDIR]     = { do_readdir,     
"READDIR"     },
  2481         [FUSE_RELEASEDIR]  = { do_releasedir,  
"RELEASEDIR"  },
  2482         [FUSE_FSYNCDIR]    = { do_fsyncdir,    
"FSYNCDIR"    },
  2483         [FUSE_GETLK]       = { do_getlk,       
"GETLK"       },
  2484         [FUSE_SETLK]       = { do_setlk,       
"SETLK"       },
  2485         [FUSE_SETLKW]      = { do_setlkw,      
"SETLKW"      },
  2486         [FUSE_ACCESS]      = { do_access,      
"ACCESS"      },
  2487         [FUSE_CREATE]      = { do_create,      
"CREATE"      },
  2488         [FUSE_INTERRUPT]   = { do_interrupt,   
"INTERRUPT"   },
  2489         [FUSE_BMAP]        = { do_bmap,        
"BMAP"        },
  2490         [FUSE_IOCTL]       = { do_ioctl,       
"IOCTL"       },
  2491         [FUSE_POLL]        = { do_poll,        
"POLL"        },
  2492         [FUSE_FALLOCATE]   = { do_fallocate,   
"FALLOCATE"   },
  2493         [FUSE_DESTROY]     = { do_destroy,     
"DESTROY"     },
  2494         [FUSE_NOTIFY_REPLY] = { (
void *) 1,    
"NOTIFY_REPLY" },
  2495         [FUSE_BATCH_FORGET] = { do_batch_forget, 
"BATCH_FORGET" },
  2496         [FUSE_READDIRPLUS] = { do_readdirplus,  
"READDIRPLUS"},
  2497         [FUSE_RENAME2]     = { do_rename2,      
"RENAME2"    },
  2498         [FUSE_COPY_FILE_RANGE] = { do_copy_file_range, 
"COPY_FILE_RANGE" },
  2499         [FUSE_LSEEK]       = { do_lseek,       
"LSEEK"       },
  2500         [CUSE_INIT]        = { cuse_lowlevel_init, 
"CUSE_INIT"   },
  2503 #define FUSE_MAXOP (sizeof(fuse_ll_ops) / sizeof(fuse_ll_ops[0]))  2505 static const char *opname(
enum fuse_opcode opcode)
  2507         if (opcode >= FUSE_MAXOP || !fuse_ll_ops[opcode].name)
  2510                 return fuse_ll_ops[opcode].name;
  2513 static int fuse_ll_copy_from_pipe(
struct fuse_bufvec *dst,
  2518                 fuse_log(FUSE_LOG_ERR, 
"fuse: copy from pipe: %s\n", strerror(-res));
  2522                 fuse_log(FUSE_LOG_ERR, 
"fuse: copy from pipe: short read\n");
  2531         fuse_session_process_buf_int(se, buf, NULL);
  2534 void fuse_session_process_buf_int(
struct fuse_session *se,
  2535                                   const struct fuse_buf *buf, 
struct fuse_chan *ch)
  2537         const size_t write_header_size = 
sizeof(
struct fuse_in_header) +
  2538                 sizeof(struct fuse_write_in);
  2540         struct fuse_bufvec tmpbuf = FUSE_BUFVEC_INIT(write_header_size);
  2541         struct fuse_in_header *in;
  2543         struct fuse_req *req;
  2552                 mbuf = malloc(tmpbuf.
buf[0].
size);
  2554                         fuse_log(FUSE_LOG_ERR, 
"fuse: failed to allocate header\n");
  2557                 tmpbuf.
buf[0].
mem = mbuf;
  2559                 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
  2570                         "unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n",
  2571                         (
unsigned long long) in->unique,
  2572                         opname((
enum fuse_opcode) in->opcode), in->opcode,
  2573                         (
unsigned long long) in->nodeid, buf->
size, in->pid);
  2576         req = fuse_ll_alloc_req(se);
  2578                 struct fuse_out_header out = {
  2579                         .unique = in->unique,
  2582                 struct iovec iov = {
  2584                         .iov_len = 
sizeof(
struct fuse_out_header),
  2587                 fuse_send_msg(se, ch, &iov, 1);
  2591         req->unique = in->unique;
  2592         req->ctx.uid = in->uid;
  2593         req->ctx.gid = in->gid;
  2594         req->ctx.pid = in->pid;
  2595         req->ch = ch ? fuse_chan_get(ch) : NULL;
  2598         if (!se->got_init) {
  2599                 enum fuse_opcode expected;
  2601                 expected = se->cuse_data ? CUSE_INIT : FUSE_INIT;
  2602                 if (in->opcode != expected)
  2604         } 
else if (in->opcode == FUSE_INIT || in->opcode == CUSE_INIT)
  2609         if (se->deny_others && in->uid != se->owner && in->uid != 0 &&
  2610                  in->opcode != FUSE_INIT && in->opcode != FUSE_READ &&
  2611                  in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC &&
  2612                  in->opcode != FUSE_RELEASE && in->opcode != FUSE_READDIR &&
  2613                  in->opcode != FUSE_FSYNCDIR && in->opcode != FUSE_RELEASEDIR &&
  2614                  in->opcode != FUSE_NOTIFY_REPLY &&
  2615                  in->opcode != FUSE_READDIRPLUS)
  2619         if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func)
  2621         if (in->opcode != FUSE_INTERRUPT) {
  2622                 struct fuse_req *intr;
  2623                 pthread_mutex_lock(&se->lock);
  2624                 intr = check_interrupt(se, req);
  2625                 list_add_req(req, &se->list);
  2626                 pthread_mutex_unlock(&se->lock);
  2632             (in->opcode != FUSE_WRITE || !se->op.write_buf) &&
  2633             in->opcode != FUSE_NOTIFY_REPLY) {
  2637                 newmbuf = realloc(mbuf, buf->
size);
  2638                 if (newmbuf == NULL)
  2642                 tmpbuf = FUSE_BUFVEC_INIT(buf->
size - write_header_size);
  2643                 tmpbuf.
buf[0].
mem = (
char *)mbuf + write_header_size;
  2645                 res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
  2653         inarg = (
void *) &in[1];
  2654         if (in->opcode == FUSE_WRITE && se->op.write_buf)
  2655                 do_write_buf(req, in->nodeid, inarg, buf);
  2656         else if (in->opcode == FUSE_NOTIFY_REPLY)
  2657                 do_notify_reply(req, in->nodeid, inarg, buf);
  2659                 fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
  2669                 fuse_ll_clear_pipe(se);
  2673 #define LL_OPTION(n,o,v) \  2674         { n, offsetof(struct fuse_session, o), v }  2676 static const struct fuse_opt fuse_ll_opts[] = {
  2677         LL_OPTION(
"debug", debug, 1),
  2678         LL_OPTION(
"-d", debug, 1),
  2679         LL_OPTION(
"--debug", debug, 1),
  2680         LL_OPTION(
"allow_root", deny_others, 1),
  2686         printf(
"using FUSE kernel interface version %i.%i\n",
  2687                FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
  2688         fuse_mount_version();
  2696 "    -o allow_other         allow access by all users\n"  2697 "    -o allow_root          allow access by root\n"  2698 "    -o auto_unmount        auto unmount on process termination\n");
  2703         struct fuse_ll_pipe *llp;
  2705         if (se->got_init && !se->got_destroy) {
  2707                         se->op.destroy(se->userdata);
  2709         llp = pthread_getspecific(se->pipe_key);
  2711                 fuse_ll_pipe_free(llp);
  2712         pthread_key_delete(se->pipe_key);
  2713         pthread_mutex_destroy(&se->lock);
  2714         free(se->cuse_data);
  2717         destroy_mount_opts(se->mo);
  2722 static void fuse_ll_pipe_destructor(
void *data)
  2724         struct fuse_ll_pipe *llp = data;
  2725         fuse_ll_pipe_free(llp);
  2730         return fuse_session_receive_buf_int(se, buf, NULL);
  2733 int fuse_session_receive_buf_int(
struct fuse_session *se, 
struct fuse_buf *buf,
  2734                                  struct fuse_chan *ch)
  2739         size_t bufsize = se->bufsize;
  2740         struct fuse_ll_pipe *llp;
  2746         llp = fuse_ll_get_pipe(se);
  2750         if (llp->size < bufsize) {
  2751                 if (llp->can_grow) {
  2752                         res = fcntl(llp->pipe[0], F_SETPIPE_SZ, bufsize);
  2755                                 res = grow_pipe_to_max(llp->pipe[0]);
  2762                 if (llp->size < bufsize)
  2766         res = splice(ch ? ch->fd : se->fd,
  2767                      NULL, llp->pipe[1], NULL, bufsize, 0);
  2774                 if (err == ENODEV) {
  2780                 if (err != EINTR && err != EAGAIN)
  2781                         perror(
"fuse: splice from device");
  2785         if (res < 
sizeof(
struct fuse_in_header)) {
  2786                 fuse_log(FUSE_LOG_ERR, 
"short splice from fuse device\n");
  2801         if (res < 
sizeof(
struct fuse_in_header) +
  2802             sizeof(
struct fuse_write_in) + pagesize) {
  2807                         buf->
mem = malloc(se->bufsize);
  2810                                         "fuse: failed to allocate read buffer\n");
  2814                 buf->
size = se->bufsize;
  2820                         fuse_log(FUSE_LOG_ERR, 
"fuse: copy from pipe: %s\n",
  2822                         fuse_ll_clear_pipe(se);
  2825                 if (res < tmpbuf.size) {
  2826                         fuse_log(FUSE_LOG_ERR, 
"fuse: copy from pipe: short read\n");
  2827                         fuse_ll_clear_pipe(se);
  2830                 assert(res == tmpbuf.size);
  2834                 buf->
fd = tmpbuf.fd;
  2835                 buf->
flags = tmpbuf.flags;
  2837         buf->
size = tmpbuf.size;
  2844                 buf->
mem = malloc(se->bufsize);
  2847                                 "fuse: failed to allocate read buffer\n");
  2853         res = read(ch ? ch->fd : se->fd, buf->
mem, se->bufsize);
  2864                 if (err == ENODEV) {
  2873                 if (err != EINTR && err != EAGAIN)
  2874                         perror(
"fuse: reading device");
  2877         if ((
size_t) res < 
sizeof(
struct fuse_in_header)) {
  2878                 fuse_log(FUSE_LOG_ERR, 
"short read on fuse device\n");
  2889                                       size_t op_size, 
void *userdata)
  2892         struct fuse_session *se;
  2893         struct mount_opts *mo;
  2896                 fuse_log(FUSE_LOG_ERR, 
"fuse: warning: library too old, some operations may not work\n");
  2900         if (args->
argc == 0) {
  2901                 fuse_log(FUSE_LOG_ERR, 
"fuse: empty argv passed to fuse_session_new().\n");
  2905         se = (
struct fuse_session *) calloc(1, 
sizeof(
struct fuse_session));
  2907                 fuse_log(FUSE_LOG_ERR, 
"fuse: failed to allocate fuse object\n");
  2911         se->conn.max_write = UINT_MAX;
  2912         se->conn.max_readahead = UINT_MAX;
  2917         if(se->deny_others) {
  2927         mo = parse_mount_opts(args);
  2931         if(args->
argc == 1 &&
  2932            args->
argv[0][0] == 
'-') {
  2933                 fuse_log(FUSE_LOG_ERR, 
"fuse: warning: argv[0] looks like an option, but "  2934                         "will be ignored\n");
  2935         } 
else if (args->
argc != 1) {
  2937                 fuse_log(FUSE_LOG_ERR, 
"fuse: unknown option(s): `");
  2938                 for(i = 1; i < args->
argc-1; i++)
  2945                 fuse_log(FUSE_LOG_DEBUG, 
"FUSE library version: %s\n", PACKAGE_VERSION);
  2947         se->bufsize = FUSE_MAX_MAX_PAGES * getpagesize() +
  2948                 FUSE_BUFFER_HEADER_SIZE;
  2950         list_init_req(&se->list);
  2951         list_init_req(&se->interrupts);
  2952         list_init_nreq(&se->notify_list);
  2954         fuse_mutex_init(&se->lock);
  2956         err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor);
  2958                 fuse_log(FUSE_LOG_ERR, 
"fuse: failed to create thread specific key: %s\n",
  2963         memcpy(&se->op, op, op_size);
  2964         se->owner = getuid();
  2965         se->userdata = userdata;
  2971         pthread_mutex_destroy(&se->lock);
  2976                 destroy_mount_opts(mo);
  2992                 fd = open(
"/dev/null", O_RDWR);
  2995         } 
while (fd >= 0 && fd <= 2);
  3003         fd = fuse_mnt_parse_fuse_fd(mountpoint);
  3005                 if (fcntl(fd, F_GETFD) == -1) {
  3007                                 "fuse: Invalid file descriptor /dev/fd/%u\n",
  3016         fd = fuse_kern_mount(mountpoint, se->mo);
  3022         se->mountpoint = strdup(mountpoint);
  3023         if (se->mountpoint == NULL)
  3029         fuse_kern_unmount(mountpoint, fd);
  3040         if (se->mountpoint != NULL) {
  3041                 fuse_kern_unmount(se->mountpoint, se->fd);
  3043                 free(se->mountpoint);
  3044                 se->mountpoint = NULL;
  3052         size_t bufsize = 1024;
  3056         unsigned long pid = req->ctx.pid;
  3059         sprintf(path, 
"/proc/%lu/task/%lu/status", pid, pid);
  3062         buf = malloc(bufsize);
  3067         fd = open(path, O_RDONLY);
  3071         ret = read(fd, buf, bufsize);
  3078         if ((
size_t)ret == bufsize) {
  3085         s = strstr(buf, 
"\nGroups:");
  3093                 unsigned long val = strtoul(s, &end, 0);
  3113         (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)