example/passthrough: close open files in release()
authorNikolaus Rath <Nikolaus@rath.org>
Fri, 7 Apr 2017 23:27:33 +0000 (16:27 -0700)
committerNikolaus Rath <Nikolaus@rath.org>
Fri, 7 Apr 2017 23:40:15 +0000 (16:40 -0700)
That way we can use the file descriptor for other operations.

example/passthrough.c

index 22e7083e6b20d876eaf7107f801d1a52633c8f05..55f770415a6f7d5332a9ed5bc30fca5106de3062 100644 (file)
@@ -284,7 +284,7 @@ static int xmp_open(const char *path, struct fuse_file_info *fi)
        if (res == -1)
                return -errno;
 
-       close(res);
+       fi->fh = res;
        return 0;
 }
 
@@ -339,11 +339,8 @@ static int xmp_statfs(const char *path, struct statvfs *stbuf)
 
 static int xmp_release(const char *path, struct fuse_file_info *fi)
 {
-       /* Just a stub.  This method is optional and can safely be left
-          unimplemented */
-
        (void) path;
-       (void) fi;
+       close(fi->fh);
        return 0;
 }