release() changes
diff --git a/lib/fuse.c b/lib/fuse.c
index fe670d8..4919965 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -349,7 +349,7 @@
return 0;
}
-static void send_reply_raw(struct fuse *f, char *outbuf, size_t outsize)
+static int send_reply_raw(struct fuse *f, char *outbuf, size_t outsize)
{
int res;
@@ -370,12 +370,15 @@
/* ENOENT means the operation was interrupted */
if(errno != ENOENT)
perror("fuse: writing device");
+ return -errno;
}
+ return 0;
}
-static void send_reply(struct fuse *f, struct fuse_in_header *in, int error,
- void *arg, size_t argsize)
+static int send_reply(struct fuse *f, struct fuse_in_header *in, int error,
+ void *arg, size_t argsize)
{
+ int res;
char *outbuf;
size_t outsize;
struct fuse_out_header *out;
@@ -397,9 +400,10 @@
if(argsize != 0)
memcpy(outbuf + sizeof(struct fuse_out_header), arg, argsize);
- send_reply_raw(f, outbuf, outsize);
-
+ res = send_reply_raw(f, outbuf, outsize);
free(outbuf);
+
+ return res;
}
static void do_lookup(struct fuse *f, struct fuse_in_header *in, char *name)
@@ -740,6 +744,7 @@
struct fuse_open_in *arg)
{
int res;
+ int res2;
char *path;
res = -ENOENT;
@@ -748,9 +753,14 @@
res = -ENOSYS;
if(f->op.open)
res = f->op.open(path, arg->flags);
+ }
+ res2 = send_reply(f, in, res, NULL, 0);
+ if(path != NULL) {
+ /* The open syscall was interrupted, so it must be cancelled */
+ if(res == 0 && res2 == -ENOENT && f->op.release)
+ f->op.release(path);
free(path);
}
- send_reply(f, in, res, NULL, 0);
}
static void do_release(struct fuse *f, struct fuse_in_header *in)