Lines Matching refs:req
124 static void list_init_req(struct fuse_req *req)
126 req->next = req;
127 req->prev = req;
130 static void list_del_req(struct fuse_req *req)
132 struct fuse_req *prev = req->prev;
133 struct fuse_req *next = req->next;
138 static void list_add_req(struct fuse_req *req, struct fuse_req *next)
141 req->next = next;
142 req->prev = prev;
143 prev->next = req;
144 next->prev = req;
147 static void destroy_req(fuse_req_t req)
149 pthread_mutex_destroy(&req->lock);
150 free(req);
153 static void free_req(fuse_req_t req)
156 struct fuse_ll *f = req->f;
158 pthread_mutex_lock(&req->lock);
159 req->u.ni.func = NULL;
160 req->u.ni.data = NULL;
161 pthread_mutex_unlock(&req->lock);
164 list_del_req(req);
165 ctr = --req->ctr;
168 destroy_req(req);
171 static int send_reply_iov(fuse_req_t req, int error, struct iovec *iov,
182 out.unique = req->unique;
188 if (req->f->debug)
192 res = fuse_chan_send(req->ch, iov, count);
193 free_req(req);
198 static int send_reply(fuse_req_t req, int error, const void *arg,
209 return send_reply_iov(req, error, iov, count);
213 int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)
220 return fuse_reply_err(req, -ENOMEM);
225 res = send_reply_iov(req, 0, padded_iov, count);
257 size_t fuse_add_direntry(fuse_req_t req, char *buf, size_t bufsize,
262 (void) req;
282 static int send_reply_ok(fuse_req_t req, const void *arg, size_t argsize)
284 return send_reply(req, 0, arg, argsize);
287 int fuse_reply_err(fuse_req_t req, int err)
289 return send_reply(req, -err, NULL, 0);
292 void fuse_reply_none(fuse_req_t req)
294 fuse_chan_send(req->ch, NULL, 0);
295 free_req(req);
342 int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e)
348 if (!e->ino && req->f->conn.proto_minor < 4)
349 return fuse_reply_err(req, ENOENT);
353 return send_reply_ok(req, &arg, (req->f->conn.proto_minor >= 12
357 int fuse_reply_create(fuse_req_t req, const struct fuse_entry_param *e,
367 if (req->f->conn.proto_minor < 12) {
370 return send_reply_ok(req, &arg,
374 return send_reply_ok(req, &arg, sizeof(arg));
378 int fuse_reply_attr(fuse_req_t req, const struct stat *attr,
388 return send_reply_ok(req, &arg, (req->f->conn.proto_minor >= 12
392 int fuse_reply_readlink(fuse_req_t req, const char *linkname)
394 return send_reply_ok(req, linkname, strlen(linkname));
397 int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *f)
403 return send_reply_ok(req, &arg, sizeof(arg));
406 int fuse_reply_write(fuse_req_t req, size_t count)
413 return send_reply_ok(req, &arg, sizeof(arg));
416 int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size)
418 return send_reply_ok(req, buf, size);
421 int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf)
424 size_t size = req->f->conn.proto_minor < 4 ? FUSE_COMPAT_STATFS_SIZE : sizeof(arg);
429 return send_reply_ok(req, &arg, size);
432 int fuse_reply_xattr(fuse_req_t req, size_t count)
439 return send_reply_ok(req, &arg, sizeof(arg));
442 int fuse_reply_lock(fuse_req_t req, struct flock *lock)
456 return send_reply_ok(req, &arg, sizeof(arg));
459 int fuse_reply_bmap(fuse_req_t req, uint64_t idx)
466 return send_reply_ok(req, &arg, sizeof(arg));
469 int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, size_t size)
488 return send_reply_iov(req, 0, iov, count);
491 static void do_lookup(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
495 if (req->f->op.lookup)
496 req->f->op.lookup(req, nodeid, name);
498 fuse_reply_err(req, ENOSYS);
501 static void do_forget(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
505 if (req->f->op.forget)
506 req->f->op.forget(req, nodeid, arg->nlookup);
508 fuse_reply_none(req);
511 static void do_getattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
515 if (req->f->op.getattr)
516 req->f->op.getattr(req, nodeid, NULL);
518 fuse_reply_err(req, ENOSYS);
521 static void do_setattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
525 if (req->f->op.setattr) {
537 req->f->op.setattr(req, nodeid, &stbuf, arg->valid & ~FATTR_FH, fi);
539 fuse_reply_err(req, ENOSYS);
542 static void do_access(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
546 if (req->f->op.access)
547 req->f->op.access(req, nodeid, arg->mask);
549 fuse_reply_err(req, ENOSYS);
552 static void do_readlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
556 if (req->f->op.readlink)
557 req->f->op.readlink(req, nodeid);
559 fuse_reply_err(req, ENOSYS);
562 static void do_mknod(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
567 if (req->f->conn.proto_minor >= 12)
568 req->ctx.umask = arg->umask;
572 if (req->f->op.mknod) {
578 req->f->op.mknod(req, nodeid, name, arg->mode,
582 req->f->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
585 fuse_reply_err(req, ENOSYS);
588 static void do_mkdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
592 if (req->f->conn.proto_minor >= 12)
593 req->ctx.umask = arg->umask;
595 if (req->f->op.mkdir)
596 req->f->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
598 fuse_reply_err(req, ENOSYS);
601 static void do_unlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
605 if (req->f->op.unlink)
606 req->f->op.unlink(req, nodeid, name);
608 fuse_reply_err(req, ENOSYS);
611 static void do_rmdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
615 if (req->f->op.rmdir)
616 req->f->op.rmdir(req, nodeid, name);
618 fuse_reply_err(req, ENOSYS);
621 static void do_symlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
626 if (req->f->op.symlink)
627 req->f->op.symlink(req, linkname, nodeid, name);
629 fuse_reply_err(req, ENOSYS);
632 static void do_rename(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
638 if (req->f->op.rename)
639 req->f->op.rename(req, nodeid, oldname, arg->newdir, newname);
641 fuse_reply_err(req, ENOSYS);
644 static void do_link(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
648 if (req->f->op.link)
649 req->f->op.link(req, arg->oldnodeid, nodeid, PARAM(arg));
651 fuse_reply_err(req, ENOSYS);
654 static void do_create(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
658 if (req->f->op.create) {
665 if (req->f->conn.proto_minor >= 12)
666 req->ctx.umask = arg->umask;
670 req->f->op.create(req, nodeid, name, arg->mode, &fi);
672 fuse_reply_err(req, ENOSYS);
675 static void do_open(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
683 if (req->f->op.open)
684 req->f->op.open(req, nodeid, &fi);
686 fuse_reply_open(req, &fi);
689 static void do_read(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
693 if (req->f->op.read) {
699 req->f->op.read(req, nodeid, arg->size, arg->offset, &fi);
701 fuse_reply_err(req, ENOSYS);
704 static void do_write(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
714 if (req->f->op.write) {
717 if (req->f->conn.proto_minor >= 12)
721 req->f->op.write(req, nodeid, buf, arg->size, arg->offset, &fi);
723 fuse_reply_err(req, ENOSYS);
726 static void do_flush(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
735 if (req->f->conn.proto_minor >= 7)
738 if (req->f->op.flush)
739 req->f->op.flush(req, nodeid, &fi);
741 fuse_reply_err(req, ENOSYS);
744 static void do_release(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
753 if (req->f->conn.proto_minor >= 8) {
758 if (req->f->op.release)
759 req->f->op.release(req, nodeid, &fi);
761 fuse_reply_err(req, 0);
764 static void do_fsync(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
773 if (req->f->op.fsync)
774 req->f->op.fsync(req, nodeid, arg->fsync_flags & 1, &fi);
776 fuse_reply_err(req, ENOSYS);
779 static void do_opendir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
787 if (req->f->op.opendir)
788 req->f->op.opendir(req, nodeid, &fi);
790 fuse_reply_open(req, &fi);
793 static void do_readdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
802 if (req->f->op.readdir)
803 req->f->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
805 fuse_reply_err(req, ENOSYS);
808 static void do_releasedir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
818 if (req->f->op.releasedir)
819 req->f->op.releasedir(req, nodeid, &fi);
821 fuse_reply_err(req, 0);
824 static void do_fsyncdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
833 if (req->f->op.fsyncdir)
834 req->f->op.fsyncdir(req, nodeid, arg->fsync_flags & 1, &fi);
836 fuse_reply_err(req, ENOSYS);
839 static void do_statfs(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
844 if (req->f->op.statfs)
845 req->f->op.statfs(req, nodeid);
851 fuse_reply_statfs(req, &buf);
855 static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
861 if (req->f->op.setxattr)
862 req->f->op.setxattr(req, nodeid, name, value, arg->size, arg->flags);
864 fuse_reply_err(req, ENOSYS);
867 static void do_getxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
871 if (req->f->op.getxattr)
872 req->f->op.getxattr(req, nodeid, PARAM(arg), arg->size);
874 fuse_reply_err(req, ENOSYS);
877 static void do_listxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
881 if (req->f->op.listxattr)
882 req->f->op.listxattr(req, nodeid, arg->size);
884 fuse_reply_err(req, ENOSYS);
887 static void do_removexattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
891 if (req->f->op.removexattr)
892 req->f->op.removexattr(req, nodeid, name);
894 fuse_reply_err(req, ENOSYS);
911 static void do_getlk(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
922 if (req->f->op.getlk)
923 req->f->op.getlk(req, nodeid, &fi, &flock);
925 fuse_reply_err(req, ENOSYS);
928 static void do_setlk_common(fuse_req_t req, fuse_ino_t nodeid,
940 if (req->f->op.setlk)
941 req->f->op.setlk(req, nodeid, &fi, &flock, should_sleep);
943 fuse_reply_err(req, ENOSYS);
946 static void do_setlk(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
948 do_setlk_common(req, nodeid, inarg, 0);
951 static void do_setlkw(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
953 do_setlk_common(req, nodeid, inarg, 1);
956 static int find_interrupted(struct fuse_ll *f, struct fuse_req *req)
961 if (curr->unique == req->u.i.unique) {
984 if (curr->u.i.unique == req->u.i.unique)
990 static void do_interrupt(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
993 struct fuse_ll *f = req->f;
999 req->u.i.unique = arg->unique;
1002 if (find_interrupted(f, req))
1003 destroy_req(req);
1005 list_add_req(req, &f->interrupts);
1009 static struct fuse_req *check_interrupt(struct fuse_ll *f, struct fuse_req *req)
1014 if (curr->u.i.unique == req->unique) {
1015 req->interrupted = 1;
1030 static void do_bmap(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1034 if (req->f->op.bmap)
1035 req->f->op.bmap(req, nodeid, arg->blocksize, arg->block);
1037 fuse_reply_err(req, ENOSYS);
1040 static void do_ioctl(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1048 !(req->f->conn.want & FUSE_CAP_IOCTL_DIR)) {
1049 fuse_reply_err(req, ENOTTY);
1056 /* TODO JPA (need req->ioctl_64bit in obscure fuse_req_t)
1059 if (sizeof(void *) == 4 && req->f->conn.proto_minor >= 16 &&
1061 req->ioctl_64bit = 1;
1065 if (req->f->op.ioctl)
1066 req->f->op.ioctl(req, nodeid, arg->cmd,
1070 fuse_reply_err(req, ENOSYS);
1073 static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1077 struct fuse_ll *f = req->f;
1078 size_t bufsize = fuse_chan_bufsize(req->ch);
1094 fuse_reply_err(req, EPROTO);
1185 send_reply_ok(req, &outarg, arg->minor < 5 ? 8 : sizeof(outarg));
1188 static void do_destroy(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1190 struct fuse_ll *f = req->f;
1199 send_reply_ok(req, NULL, 0);
1202 void *fuse_req_userdata(fuse_req_t req)
1204 return req->f->userdata;
1207 const struct fuse_ctx *fuse_req_ctx(fuse_req_t req)
1209 return &req->ctx;
1212 void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func,
1215 pthread_mutex_lock(&req->lock);
1216 req->u.ni.func = func;
1217 req->u.ni.data = data;
1218 if (req->interrupted && func)
1219 func(req, data);
1220 pthread_mutex_unlock(&req->lock);
1223 int fuse_req_interrupted(fuse_req_t req)
1227 pthread_mutex_lock(&req->f->lock);
1228 interrupted = req->interrupted;
1229 pthread_mutex_unlock(&req->f->lock);
1293 struct fuse_req *req;
1301 req = (struct fuse_req *) calloc(1, sizeof(struct fuse_req));
1302 if (req == NULL) {
1307 req->f = f;
1308 req->unique = in->unique;
1309 req->ctx.uid = in->uid;
1310 req->ctx.gid = in->gid;
1311 req->ctx.pid = in->pid;
1312 req->ch = ch;
1313 req->ctr = 1;
1314 list_init_req(req);
1315 fuse_mutex_init(&req->lock);
1318 fuse_reply_err(req, EIO);
1324 fuse_reply_err(req, EACCES);
1326 fuse_reply_err(req, ENOSYS);
1331 intr = check_interrupt(f, req);
1332 list_add_req(req, &f->list);
1337 fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);