Lines Matching defs:req
101 static void list_init_req(struct fuse_req *req)
103 req->next = req;
104 req->prev = 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)
118 req->next = next;
119 req->prev = prev;
120 prev->next = req;
121 next->prev = req;
124 static void destroy_req(fuse_req_t req)
126 assert(req->ch == NULL);
127 pthread_mutex_destroy(&req->lock);
128 free(req);
131 void fuse_free_req(fuse_req_t req)
134 struct fuse_session *se = req->se;
137 req->u.ni.func = NULL;
138 req->u.ni.data = NULL;
139 list_del_req(req);
140 ctr = --req->ctr;
141 fuse_chan_put(req->ch);
142 req->ch = NULL;
145 destroy_req(req);
150 struct fuse_req *req;
152 req = (struct fuse_req *) calloc(1, sizeof(struct fuse_req));
153 if (req == NULL) {
156 req->se = se;
157 req->ctr = 1;
158 list_init_req(req);
159 pthread_mutex_init(&req->lock, NULL);
162 return req;
211 int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,
226 out.unique = req->unique;
232 return fuse_send_msg(req->se, req->ch, iov, count);
235 static int send_reply_iov(fuse_req_t req, int error, struct iovec *iov,
240 res = fuse_send_reply_iov_nofree(req, error, iov, count);
241 fuse_free_req(req);
245 static int send_reply(fuse_req_t req, int error, const void *arg,
255 return send_reply_iov(req, error, iov, count);
258 int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)
265 return fuse_reply_err(req, ENOMEM);
270 res = send_reply_iov(req, 0, padded_iov, count);
279 size_t fuse_add_direntry(fuse_req_t req, char *buf, size_t bufsize,
282 (void)req;
319 static int send_reply_ok(fuse_req_t req, const void *arg, size_t argsize)
321 return send_reply(req, 0, arg, argsize);
324 int fuse_reply_err(fuse_req_t req, int err)
326 return send_reply(req, -err, NULL, 0);
329 void fuse_reply_none(fuse_req_t req)
331 fuse_free_req(req);
369 size_t fuse_add_direntry_plus(fuse_req_t req, char *buf, size_t bufsize,
373 (void)req;
417 int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e)
420 size_t size = req->se->conn.proto_minor < 9 ?
425 if (!e->ino && req->se->conn.proto_minor < 4)
426 return fuse_reply_err(req, ENOENT);
430 return send_reply_ok(req, &arg, size);
433 int fuse_reply_create(fuse_req_t req, const struct fuse_entry_param *e,
437 size_t entrysize = req->se->conn.proto_minor < 9 ?
445 return send_reply_ok(req, buf,
449 int fuse_reply_attr(fuse_req_t req, const struct stat *attr,
453 size_t size = req->se->conn.proto_minor < 9 ?
461 return send_reply_ok(req, &arg, size);
464 int fuse_reply_readlink(fuse_req_t req, const char *linkname)
466 return send_reply_ok(req, linkname, strlen(linkname));
469 int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *f)
475 return send_reply_ok(req, &arg, sizeof(arg));
478 int fuse_reply_write(fuse_req_t req, size_t count)
485 return send_reply_ok(req, &arg, sizeof(arg));
488 int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size)
490 return send_reply_ok(req, buf, size);
874 int fuse_reply_data(fuse_req_t req, struct fuse_bufvec *bufv,
884 out.unique = req->unique;
887 res = fuse_send_data_iov(req->se, req->ch, iov, 1, bufv, flags);
889 fuse_free_req(req);
892 return fuse_reply_err(req, res);
896 int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf)
899 size_t size = req->se->conn.proto_minor < 4 ?
905 return send_reply_ok(req, &arg, size);
908 int fuse_reply_xattr(fuse_req_t req, size_t count)
915 return send_reply_ok(req, &arg, sizeof(arg));
918 int fuse_reply_lock(fuse_req_t req, const struct flock *lock)
932 return send_reply_ok(req, &arg, sizeof(arg));
935 int fuse_reply_bmap(fuse_req_t req, uint64_t idx)
942 return send_reply_ok(req, &arg, sizeof(arg));
963 int fuse_reply_ioctl_retry(fuse_req_t req,
982 if (req->se->conn.proto_minor < 16) {
996 if (sizeof(void *) == 4 && req->ioctl_64bit) {
997 res = fuse_reply_err(req, EINVAL);
1021 res = send_reply_iov(req, 0, iov, count);
1029 res = fuse_reply_err(req, ENOMEM);
1033 int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, size_t size)
1051 return send_reply_iov(req, 0, iov, count);
1054 int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov,
1063 return fuse_reply_err(req, ENOMEM);
1072 res = send_reply_iov(req, 0, padded_iov, count + 2);
1078 int fuse_reply_poll(fuse_req_t req, unsigned revents)
1085 return send_reply_ok(req, &arg, sizeof(arg));
1088 int fuse_reply_lseek(fuse_req_t req, off_t off)
1095 return send_reply_ok(req, &arg, sizeof(arg));
1098 static void do_lookup(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1102 if (req->se->op.lookup)
1103 req->se->op.lookup(req, nodeid, name);
1105 fuse_reply_err(req, ENOSYS);
1108 static void do_forget(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1112 if (req->se->op.forget)
1113 req->se->op.forget(req, nodeid, arg->nlookup);
1115 fuse_reply_none(req);
1118 static void do_batch_forget(fuse_req_t req, fuse_ino_t nodeid,
1127 if (req->se->op.forget_multi) {
1128 req->se->op.forget_multi(req, arg->count,
1130 } else if (req->se->op.forget) {
1135 dummy_req = fuse_ll_alloc_req(req->se);
1139 dummy_req->unique = req->unique;
1140 dummy_req->ctx = req->ctx;
1143 req->se->op.forget(dummy_req, forget->nodeid,
1146 fuse_reply_none(req);
1148 fuse_reply_none(req);
1152 static void do_getattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1157 if (req->se->conn.proto_minor >= 9) {
1167 if (req->se->op.getattr)
1168 req->se->op.getattr(req, nodeid, fip);
1170 fuse_reply_err(req, ENOSYS);
1173 static void do_setattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1177 if (req->se->op.setattr) {
1202 req->se->op.setattr(req, nodeid, &stbuf, arg->valid, fi);
1204 fuse_reply_err(req, ENOSYS);
1207 static void do_access(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1211 if (req->se->op.access)
1212 req->se->op.access(req, nodeid, arg->mask);
1214 fuse_reply_err(req, ENOSYS);
1217 static void do_readlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1221 if (req->se->op.readlink)
1222 req->se->op.readlink(req, nodeid);
1224 fuse_reply_err(req, ENOSYS);
1227 static void do_mknod(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1232 if (req->se->conn.proto_minor >= 12)
1233 req->ctx.umask = arg->umask;
1237 if (req->se->op.mknod)
1238 req->se->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
1240 fuse_reply_err(req, ENOSYS);
1243 static void do_mkdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1247 if (req->se->conn.proto_minor >= 12)
1248 req->ctx.umask = arg->umask;
1250 if (req->se->op.mkdir)
1251 req->se->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
1253 fuse_reply_err(req, ENOSYS);
1256 static void do_unlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1260 if (req->se->op.unlink)
1261 req->se->op.unlink(req, nodeid, name);
1263 fuse_reply_err(req, ENOSYS);
1266 static void do_rmdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1270 if (req->se->op.rmdir)
1271 req->se->op.rmdir(req, nodeid, name);
1273 fuse_reply_err(req, ENOSYS);
1276 static void do_symlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1281 if (req->se->op.symlink)
1282 req->se->op.symlink(req, linkname, nodeid, name);
1284 fuse_reply_err(req, ENOSYS);
1287 static void do_rename(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1293 if (req->se->op.rename)
1294 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1297 fuse_reply_err(req, ENOSYS);
1300 static void do_rename2(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1306 if (req->se->op.rename)
1307 req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
1310 fuse_reply_err(req, ENOSYS);
1313 static void do_link(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1317 if (req->se->op.link)
1318 req->se->op.link(req, arg->oldnodeid, nodeid, PARAM(arg));
1320 fuse_reply_err(req, ENOSYS);
1323 static void do_create(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1327 if (req->se->op.create) {
1334 if (req->se->conn.proto_minor >= 12)
1335 req->ctx.umask = arg->umask;
1339 req->se->op.create(req, nodeid, name, arg->mode, &fi);
1341 fuse_reply_err(req, ENOSYS);
1344 static void do_open(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1352 if (req->se->op.open)
1353 req->se->op.open(req, nodeid, &fi);
1355 fuse_reply_open(req, &fi);
1358 static void do_read(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1362 if (req->se->op.read) {
1367 if (req->se->conn.proto_minor >= 9) {
1371 req->se->op.read(req, nodeid, arg->size, arg->offset, &fi);
1373 fuse_reply_err(req, ENOSYS);
1376 static void do_write(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1386 if (req->se->conn.proto_minor < 9) {
1394 if (req->se->op.write)
1395 req->se->op.write(req, nodeid, param, arg->size,
1398 fuse_reply_err(req, ENOSYS);
1401 static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid, const void *inarg,
1404 struct fuse_session *se = req->se;
1432 fuse_reply_err(req, EIO);
1437 se->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
1445 static void do_flush(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1453 if (req->se->conn.proto_minor >= 7)
1456 if (req->se->op.flush)
1457 req->se->op.flush(req, nodeid, &fi);
1459 fuse_reply_err(req, ENOSYS);
1462 static void do_release(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1470 if (req->se->conn.proto_minor >= 8) {
1479 if (req->se->op.release)
1480 req->se->op.release(req, nodeid, &fi);
1482 fuse_reply_err(req, 0);
1485 static void do_fsync(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1494 if (req->se->op.fsync)
1495 req->se->op.fsync(req, nodeid, datasync, &fi);
1497 fuse_reply_err(req, ENOSYS);
1500 static void do_opendir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1508 if (req->se->op.opendir)
1509 req->se->op.opendir(req, nodeid, &fi);
1511 fuse_reply_open(req, &fi);
1514 static void do_readdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1522 if (req->se->op.readdir)
1523 req->se->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
1525 fuse_reply_err(req, ENOSYS);
1528 static void do_readdirplus(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1536 if (req->se->op.readdirplus)
1537 req->se->op.readdirplus(req, nodeid, arg->size, arg->offset, &fi);
1539 fuse_reply_err(req, ENOSYS);
1542 static void do_releasedir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1551 if (req->se->op.releasedir)
1552 req->se->op.releasedir(req, nodeid, &fi);
1554 fuse_reply_err(req, 0);
1557 static void do_fsyncdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1566 if (req->se->op.fsyncdir)
1567 req->se->op.fsyncdir(req, nodeid, datasync, &fi);
1569 fuse_reply_err(req, ENOSYS);
1572 static void do_statfs(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1577 if (req->se->op.statfs)
1578 req->se->op.statfs(req, nodeid);
1584 fuse_reply_statfs(req, &buf);
1588 static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1590 struct fuse_session *se = req->se;
1598 if (req->se->op.setxattr)
1599 req->se->op.setxattr(req, nodeid, name, value, arg->size,
1602 fuse_reply_err(req, ENOSYS);
1605 static void do_getxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1609 if (req->se->op.getxattr)
1610 req->se->op.getxattr(req, nodeid, PARAM(arg), arg->size);
1612 fuse_reply_err(req, ENOSYS);
1615 static void do_listxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1619 if (req->se->op.listxattr)
1620 req->se->op.listxattr(req, nodeid, arg->size);
1622 fuse_reply_err(req, ENOSYS);
1625 static void do_removexattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1629 if (req->se->op.removexattr)
1630 req->se->op.removexattr(req, nodeid, name);
1632 fuse_reply_err(req, ENOSYS);
1649 static void do_getlk(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1660 if (req->se->op.getlk)
1661 req->se->op.getlk(req, nodeid, &fi, &flock);
1663 fuse_reply_err(req, ENOSYS);
1666 static void do_setlk_common(fuse_req_t req, fuse_ino_t nodeid,
1694 if (req->se->op.flock)
1695 req->se->op.flock(req, nodeid, &fi, op);
1697 fuse_reply_err(req, ENOSYS);
1700 if (req->se->op.setlk)
1701 req->se->op.setlk(req, nodeid, &fi, &flock, sleep);
1703 fuse_reply_err(req, ENOSYS);
1707 static void do_setlk(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1709 do_setlk_common(req, nodeid, inarg, 0);
1712 static void do_setlkw(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1714 do_setlk_common(req, nodeid, inarg, 1);
1717 static int find_interrupted(struct fuse_session *se, struct fuse_req *req)
1722 if (curr->unique == req->u.i.unique) {
1743 fuse_chan_put(req->ch);
1744 req->ch = NULL;
1753 if (curr->u.i.unique == req->u.i.unique)
1759 static void do_interrupt(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1762 struct fuse_session *se = req->se;
1769 req->u.i.unique = arg->unique;
1772 if (find_interrupted(se, req)) {
1773 fuse_chan_put(req->ch);
1774 req->ch = NULL;
1775 destroy_req(req);
1777 list_add_req(req, &se->interrupts);
1782 struct fuse_req *req)
1788 if (curr->u.i.unique == req->unique) {
1789 req->interrupted = 1;
1806 static void do_bmap(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1810 if (req->se->op.bmap)
1811 req->se->op.bmap(req, nodeid, arg->blocksize, arg->block);
1813 fuse_reply_err(req, ENOSYS);
1816 static void do_ioctl(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1824 !(req->se->conn.want & FUSE_CAP_IOCTL_DIR)) {
1825 fuse_reply_err(req, ENOTTY);
1832 if (sizeof(void *) == 4 && req->se->conn.proto_minor >= 16 &&
1834 req->ioctl_64bit = 1;
1837 if (req->se->op.ioctl)
1838 req->se->op.ioctl(req, nodeid, arg->cmd,
1842 fuse_reply_err(req, ENOSYS);
1850 static void do_poll(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1859 if (req->se->op.poll) {
1865 fuse_reply_err(req, ENOMEM);
1869 ph->se = req->se;
1872 req->se->op.poll(req, nodeid, &fi, ph);
1874 fuse_reply_err(req, ENOSYS);
1878 static void do_fallocate(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1886 if (req->se->op.fallocate)
1887 req->se->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi);
1889 fuse_reply_err(req, ENOSYS);
1892 static void do_copy_file_range(fuse_req_t req, fuse_ino_t nodeid_in, const void *inarg)
1904 if (req->se->op.copy_file_range)
1905 req->se->op.copy_file_range(req, nodeid_in, arg->off_in,
1910 fuse_reply_err(req, ENOSYS);
1913 static void do_lseek(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1921 if (req->se->op.lseek)
1922 req->se->op.lseek(req, nodeid, arg->offset, arg->whence, &fi);
1924 fuse_reply_err(req, ENOSYS);
1930 void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1934 struct fuse_session *se = req->se;
1960 fuse_reply_err(req, EPROTO);
1966 send_reply_ok(req, &outarg, sizeof(outarg));
2093 fuse_reply_err(req, EPROTO);
2104 fuse_reply_err(req, EPROTO);
2196 send_reply_ok(req, &outarg, outargsize);
2199 static void do_destroy(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
2201 struct fuse_session *se = req->se;
2210 send_reply_ok(req, NULL, 0);
2237 static void do_notify_reply(fuse_req_t req, fuse_ino_t nodeid,
2240 struct fuse_session *se = req->se;
2247 if (nreq->unique == req->unique) {
2255 nreq->reply(nreq, req, nodeid, inarg, buf);
2446 fuse_req_t req, fuse_ino_t ino,
2450 struct fuse_session *se = req->se;
2467 fuse_reply_none(req);
2473 se->op.retrieve_reply(req, rreq->cookie, ino,
2476 fuse_reply_none(req);
2529 void *fuse_req_userdata(fuse_req_t req)
2531 return req->se->userdata;
2534 const struct fuse_ctx *fuse_req_ctx(fuse_req_t req)
2536 return &req->ctx;
2539 void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func,
2542 pthread_mutex_lock(&req->lock);
2543 pthread_mutex_lock(&req->se->lock);
2544 req->u.ni.func = func;
2545 req->u.ni.data = data;
2546 pthread_mutex_unlock(&req->se->lock);
2547 if (req->interrupted && func)
2548 func(req, data);
2549 pthread_mutex_unlock(&req->lock);
2552 int fuse_req_interrupted(fuse_req_t req)
2556 pthread_mutex_lock(&req->se->lock);
2557 interrupted = req->interrupted;
2558 pthread_mutex_unlock(&req->se->lock);
2655 struct fuse_req *req;
2688 req = fuse_ll_alloc_req(se);
2689 if (req == NULL) {
2703 req->unique = in->unique;
2704 req->ctx.uid = in->uid;
2705 req->ctx.gid = in->gid;
2706 req->ctx.pid = in->pid;
2707 req->ch = ch ? fuse_chan_get(ch) : NULL;
2736 intr = check_interrupt(se, req);
2737 list_add_req(req, &se->list);
2767 do_write_buf(req, in->nodeid, inarg, buf);
2769 do_notify_reply(req, in->nodeid, inarg, buf);
2771 fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
2778 fuse_reply_err(req, err);
3210 int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
3217 unsigned long pid = req->ctx.pid;
3272 int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
3274 (void) req; (void) size; (void) list;