fix
authorMiklos Szeredi <miklos@szeredi.hu>
Mon, 1 Aug 2005 14:49:31 +0000 (14:49 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Mon, 1 Aug 2005 14:49:31 +0000 (14:49 +0000)
ChangeLog
include/fuse.h
lib/Makefile.am
lib/fuse.c

index dbf7e1ec7342e66676d6def95e40925c8eef4760..991f023b398a16e0bc33466c3515cff07e261097 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,8 @@
 
        * Perform ACCESS operation in case of open(), if the file wasn't
        newly created
+
+       * lib (highlevel): make open method optional
  
 2005-07-28  Miklos Szeredi <miklos@szeredi.hu>
 
index bb700a7498d83f1c02be027f57ca7d78d4e1f05a..db9a417e9068dc25c4a77485c0709b2557d9e7c9 100644 (file)
@@ -24,7 +24,7 @@
 #define FUSE_MAJOR_VERSION 2
 
 /** Minor version of FUSE library interface */
-#define FUSE_MINOR_VERSION 3
+#define FUSE_MINOR_VERSION 4
 
 /* This interface uses 64 bit off_t */
 #if _FILE_OFFSET_BITS != 64
@@ -74,10 +74,9 @@ typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type,
  * negated error value (-errno) directly.
  *
  * All methods are optional, but some are essential for a useful
- * filesystem (e.g. getattr).  Flush, release, fsync, opendir,
- * releasedir, fsyncdir, init and destroy are special purpose
- * methods, without which a full featured filesystem can still be
- * implemented.
+ * filesystem (e.g. getattr).  Open, flush, release, fsync, opendir,
+ * releasedir, fsyncdir, init and destroy are special purpose methods,
+ * without which a full featured filesystem can still be implemented.
  */
 struct fuse_operations {
     /** Get file attributes.
@@ -145,7 +144,16 @@ struct fuse_operations {
      * arbitary filehandle in the fuse_file_info structure, which will
      * be passed to all file operations.
      *
+     * Open does not need to check the permission to open the file
+     * with the given flags.  In fact it cannot correctly do that
+     * since it doesn't have a way to determine if the file was just
+     * created (and hence the permission need not be checked).
+     * 
+     * If permission needs to be checked, implement the access()
+     * method, and do the check there.
+     *
      * Changed in version 2.2
+     * Optional from version 2.4
      */
     int (*open) (const char *, struct fuse_file_info *);
 
index 223b97503fa52a95d5f18c082e06a0e9390909ee..b99f9e2f8afaa5c362705b0fbb4f8bc2b1e4a971 100644 (file)
@@ -11,7 +11,7 @@ libfuse_la_SOURCES =          \
        mount.c                 \
        fuse_lowlevel_i.h
 
-libfuse_la_LDFLAGS = -lpthread -version-number 2:3:1 \
+libfuse_la_LDFLAGS = -lpthread -version-number 2:4:0 \
        -Wl,--version-script,fuse_versionscript
 
 EXTRA_DIST = fuse_versionscript
index a84964833b905e06c85ac32862d4cf4e9c699cd4..a798eaf35ab9f51f156601a2210f8f08fa2c5c23 100644 (file)
@@ -982,15 +982,14 @@ static void fuse_open(fuse_req_t req, fuse_ino_t ino,
                       struct fuse_file_info *fi)
 {
     struct fuse *f = req_fuse_prepare(req);
-    char *path;
-    int err;
+    char *path = NULL;
+    int err = 0;
 
-    err = -ENOENT;
     pthread_rwlock_rdlock(&f->tree_lock);
-    path = get_path(f, ino);
-    if (path != NULL) {
-        err = -ENOSYS;
-        if (f->op.open) {
+    if (f->op.open) {
+        err = -ENOENT;
+        path = get_path(f, ino);
+        if (path != NULL) {
             if (!f->compat)
                 err = f->op.open(path, fi);
             else
@@ -1011,7 +1010,7 @@ static void fuse_open(fuse_req_t req, fuse_ino_t ino,
         pthread_mutex_lock(&f->lock);
         if (fuse_reply_open(req, fi) == -ENOENT) {
             /* The open syscall was interrupted, so it must be cancelled */
-            if(f->op.release) {
+            if(f->op.release && path != NULL) {
                 if (!f->compat)
                     f->op.release(path, fi);
                 else