diff options
Diffstat (limited to 'lib/fuse_session.c')
-rw-r--r-- | lib/fuse_session.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/lib/fuse_session.c b/lib/fuse_session.c index 040645b..6cfd462 100644 --- a/lib/fuse_session.c +++ b/lib/fuse_session.c @@ -7,6 +7,7 @@ */ #include "fuse_lowlevel.h" +#include "fuse_lowlevel_compat.h" #include <stdio.h> #include <stdlib.h> @@ -34,6 +35,8 @@ struct fuse_chan { size_t bufsize; void *data; + + int compat; }; struct fuse_session *fuse_session_new(struct fuse_session_ops *op, void *data) @@ -116,8 +119,8 @@ int fuse_session_exited(struct fuse_session *se) return se->exited; } -struct fuse_chan *fuse_chan_new(struct fuse_chan_ops *op, int fd, - size_t bufsize, void *data) +struct fuse_chan *fuse_chan_new_common(struct fuse_chan_ops *op, int fd, + size_t bufsize, void *data, int compat) { struct fuse_chan *ch = (struct fuse_chan *) malloc(sizeof(*ch)); if (ch == NULL) { @@ -130,10 +133,24 @@ struct fuse_chan *fuse_chan_new(struct fuse_chan_ops *op, int fd, ch->fd = fd; ch->bufsize = bufsize; ch->data = data; + ch->compat = compat; return ch; } +struct fuse_chan *fuse_chan_new(struct fuse_chan_ops *op, int fd, + size_t bufsize, void *data) +{ + return fuse_chan_new_common(op, fd, bufsize, data, 0); +} + +struct fuse_chan *fuse_chan_new_compat24(struct fuse_chan_ops_compat24 *op, + int fd, size_t bufsize, void *data) +{ + return fuse_chan_new_common((struct fuse_chan_ops *) op, fd, bufsize, + data, 24); +} + int fuse_chan_fd(struct fuse_chan *ch) { return ch->fd; @@ -154,14 +171,22 @@ struct fuse_session *fuse_chan_session(struct fuse_chan *ch) return ch->se; } -int fuse_chan_recv(struct fuse_chan *ch, char *buf, size_t size) +int fuse_chan_recv(struct fuse_chan **chp, char *buf, size_t size) { - return ch->op.receive(ch, buf, size); + struct fuse_chan *ch = *chp; + if (ch->compat) + return ((struct fuse_chan_ops_compat24 *) &ch->op) + ->receive(ch, buf, size); + else + return ch->op.receive(chp, buf, size); } int fuse_chan_receive(struct fuse_chan *ch, char *buf, size_t size) { - int res = fuse_chan_recv(ch, buf, size); + int res; + + assert(ch->compat); + res = fuse_chan_recv(&ch, buf, size); return res >= 0 ? res : (res != -EINTR && res != -EAGAIN) ? -1 : 0; } @@ -177,3 +202,7 @@ void fuse_chan_destroy(struct fuse_chan *ch) ch->op.destroy(ch); free(ch); } + +#ifndef __FreeBSD__ +__asm__(".symver fuse_chan_new_compat24,fuse_chan_new@FUSE_2.4"); +#endif |