API change
authorMiklos Szeredi <miklos@szeredi.hu>
Fri, 26 Nov 2004 12:15:06 +0000 (12:15 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Fri, 26 Nov 2004 12:15:06 +0000 (12:15 +0000)
ChangeLog
configure.in
example/fusexmp.c
example/hello.c
example/null.c
include/fuse.h
kernel/configure.ac
lib/Makefile.am
lib/fuse.c
lib/fuse_i.h

index e8d2cacdb6f8dbd9816645c2ec3a93f0add18ee3..947b4109b0eca1805a3370bc3fe623fb43fafd35 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-11-26  Miklos Szeredi <miklos@szeredi.hu>
+
+       * libfuse API change: open, read, write, flush, fsync and release
+       are passed a 'struct fuse_file_info' pointer containing the open
+       flags (open and release), and the file handle.  Verion changed to
+       3.0.
+
 2004-11-23  Miklos Szeredi <miklos@szeredi.hu>
 
        * More cleanups in the kernel
index 94deca75b4bc2ae3717c5545c91a2b39a67b1d75..256bd7b2d661a999d719527a1704bf3eb4cf0ae6 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT(fuse, 2.1-pre1)
+AC_INIT(fuse, 3.0-pre0)
 AM_INIT_AUTOMAKE
 AM_CONFIG_HEADER(include/config.h)
 
index 02d0363bb4c5155eadf372a76a7d8b6caef7f932..40af8302065fc3dbb1158551f5fdef153f678e28 100644 (file)
@@ -191,11 +191,11 @@ static int xmp_utime(const char *path, struct utimbuf *buf)
 }
 
 
-static int xmp_open(const char *path, int flags)
+static int xmp_open(const char *path, struct fuse_file_info *fi)
 {
     int res;
 
-    res = open(path, flags);
+    res = open(path, fi->flags);
     if(res == -1) 
         return -errno;
 
@@ -203,11 +203,13 @@ static int xmp_open(const char *path, int flags)
     return 0;
 }
 
-static int xmp_read(const char *path, char *buf, size_t size, off_t offset)
+static int xmp_read(const char *path, char *buf, size_t size, off_t offset,
+                    struct fuse_file_info *fi)
 {
     int fd;
     int res;
 
+    (void) fi;
     fd = open(path, O_RDONLY);
     if(fd == -1)
         return -errno;
@@ -221,11 +223,12 @@ static int xmp_read(const char *path, char *buf, size_t size, off_t offset)
 }
 
 static int xmp_write(const char *path, const char *buf, size_t size,
-                     off_t offset)
+                     off_t offset, struct fuse_file_info *fi)
 {
     int fd;
     int res;
 
+    (void) fi;
     fd = open(path, O_WRONLY);
     if(fd == -1)
         return -errno;
@@ -249,23 +252,25 @@ static int xmp_statfs(const char *path, struct statfs *stbuf)
     return 0;
 }
 
-static int xmp_release(const char *path, int flags)
+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) flags;
+    (void) fi;
     return 0;
 }
 
-static int xmp_fsync(const char *path, int isdatasync)
+static int xmp_fsync(const char *path, int isdatasync,
+                     struct fuse_file_info *fi)
 {
     /* Just a stub.  This method is optional and can safely be left
        unimplemented */
 
     (void) path;
     (void) isdatasync;
+    (void) fi;
     return 0;
 }
 
index 5065fb72ef489af02054b3f7776f4320cb07c25f..75196ff1c8316fb5e7a198fc88b7e17bdfc9c349 100644 (file)
@@ -47,20 +47,22 @@ static int hello_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler)
     return 0;
 }
 
-static int hello_open(const char *path, int flags)
+static int hello_open(const char *path, struct fuse_file_info *fi)
 {
     if(strcmp(path, hello_path) != 0)
         return -ENOENT;
 
-    if((flags & 3) != O_RDONLY)
+    if((fi->flags & 3) != O_RDONLY)
         return -EACCES;
 
     return 0;
 }
 
-static int hello_read(const char *path, char *buf, size_t size, off_t offset)
+static int hello_read(const char *path, char *buf, size_t size, off_t offset,
+                      struct fuse_file_info *fi)
 {
     size_t len;
+    (void) fi;
     if(strcmp(path, hello_path) != 0)
         return -ENOENT;
     
index b854289479544f5dba8e43d4b8f432a29e315cf3..fd88a05762bc71eb4e3236ba418391c5d540e438 100644 (file)
@@ -38,7 +38,7 @@ static int null_truncate(const char *path, off_t UNUSED(size))
     return 0;
 }
 
-static int null_open(const char *path, int UNUSED(flags))
+static int null_open(const char *path, struct fuse_file_info *UNUSED(fi))
 {
     if(strcmp(path, "/") != 0)
         return -ENOENT;
@@ -47,7 +47,7 @@ static int null_open(const char *path, int UNUSED(flags))
 }
 
 static int null_read(const char *path, char *UNUSED(buf), size_t size,
-                     off_t UNUSED(offset))
+                     off_t UNUSED(offset), struct fuse_file_info *UNUSED(fi))
 {
     if(strcmp(path, "/") != 0)
         return -ENOENT;
@@ -56,7 +56,7 @@ static int null_read(const char *path, char *UNUSED(buf), size_t size,
 }
 
 static int null_write(const char *path, const char *UNUSED(buf), size_t size,
-                     off_t UNUSED(offset))
+                     off_t UNUSED(offset), struct fuse_file_info *UNUSED(fi))
 {
     if(strcmp(path, "/") != 0)
         return -ENOENT;
index a5115ee026409cbca0a446ebd0f86ac0447be742..072ac221633ee6ae31aff55f928d212cb5742df4 100644 (file)
 /* This file defines the library interface of FUSE */
 
 /** Major version of FUSE library interface */
-#define FUSE_MAJOR_VERSION 2
+#define FUSE_MAJOR_VERSION 3
 
 /** Minor version of FUSE library interface */
-#define FUSE_MINOR_VERSION 1
+#define FUSE_MINOR_VERSION 0
 
 /* This interface uses 64 bit off_t */
 #if _FILE_OFFSET_BITS != 64
@@ -53,6 +53,16 @@ typedef struct fuse_dirhandle *fuse_dirh_t;
 typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type,
                               ino_t ino);
 
+/** Information about open files */
+struct fuse_file_info {
+    /** Open flags.  Available in open() and release() */
+    int flags;
+
+    /** File handle.  May be filled in by filesystem in open().
+        Available in all other file operations */
+    unsigned long fh;
+};
+
 /**
  * The file system operations:
  *
@@ -125,13 +135,15 @@ struct fuse_operations {
     int (*chown)       (const char *, uid_t, gid_t);
     int (*truncate)    (const char *, off_t);
     int (*utime)       (const char *, struct utimbuf *);
-    int (*open)        (const char *, int);
-    int (*read)        (const char *, char *, size_t, off_t);
-    int (*write)       (const char *, const char *, size_t, off_t);
+    int (*open)        (const char *, struct fuse_file_info *);
+    int (*read)        (const char *, char *, size_t, off_t,
+                        struct fuse_file_info *);
+    int (*write)       (const char *, const char *, size_t, off_t,
+                        struct fuse_file_info *);
     int (*statfs)      (const char *, struct statfs *);
-    int (*flush)       (const char *);
-    int (*release)     (const char *, int);
-    int (*fsync)       (const char *, int);
+    int (*flush)       (const char *, struct fuse_file_info *);
+    int (*release)     (const char *, struct fuse_file_info *);
+    int (*fsync)       (const char *, int, struct fuse_file_info *);
     int (*setxattr)    (const char *, const char *, const char *, size_t, int);
     int (*getxattr)    (const char *, const char *, char *, size_t);
     int (*listxattr)   (const char *, char *, size_t);
@@ -291,16 +303,6 @@ int __fuse_loop_mt(struct fuse *f, fuse_processor_t proc, void *data);
 int __fuse_exited(struct fuse* f);
 void __fuse_set_getcontext_func(struct fuse_context *(*func)(void));
 
-
-/* ----------------------------------------------------------- *
- * Compatibility cruft                                         *
- * ----------------------------------------------------------- */
-
-#ifdef FUSE_DIRFIL_COMPAT
-typedef int (*fuse_dirfil_old_t) (fuse_dirh_t h, const char *name, int type);
-#define fuse_dirfil_t fuse_dirfil_old_t
-#endif
-
 #ifdef __cplusplus
 }
 #endif
index 7be68901225f147306c1bb8e731cf6389e527998..3b06f4656d4196fa53c92ba37aa3e37ef34ec008 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT(fuse-kernel, 2.1-pre1)
+AC_INIT(fuse-kernel, 3.0-pre0)
 AC_CONFIG_HEADERS([config.h])
 
 AC_PROG_INSTALL
index 8dcd5a8ff20945c7161a6dea42cf8659abe032ea..e370ef4eb58055bf9ac117f08eeb1b497c9d8422 100644 (file)
@@ -9,4 +9,4 @@ libfuse_la_SOURCES =    \
        mount.c         \
        fuse_i.h
 
-libfuse_la_LDFLAGS = -lpthread -version-number 2:1:0
+libfuse_la_LDFLAGS = -lpthread -version-number 3:0:0
index 59f8b453b26d6b6dd3dc643a4ef161bd57a99a0c..66474fb849c2d73f138e0d56d466b7bf1831179b 100644 (file)
@@ -1058,13 +1058,16 @@ static void do_open(struct fuse *f, struct fuse_in_header *in,
     int res;
     char *path;
     struct fuse_open_out outarg;
+    struct fuse_file_info fi;
 
+    memset(&fi, 0, sizeof(fi));
+    fi.flags = arg->flags;
     res = -ENOENT;
     path = get_path(f, in->nodeid);
     if (path != NULL) {
         res = -ENOSYS;
         if (f->op.open)
-            res = f->op.open(path, arg->flags);
+            res = f->op.open(path, &fi);
     }
     if (res == 0) {
         int res2;
@@ -1074,8 +1077,7 @@ static void do_open(struct fuse *f, struct fuse_in_header *in,
            races with rename/unlink, against which the kernel can't
            protect */
         pthread_mutex_lock(&f->lock);
-        f->fh_ctr ++;
-        outarg.fh = f->fh_ctr;
+        outarg.fh = fi.fh;
         if (f->flags & FUSE_DEBUG) {
             printf("OPEN[%lu] flags: 0x%x\n", outarg.fh, arg->flags);
             fflush(stdout);
@@ -1085,7 +1087,7 @@ static void do_open(struct fuse *f, struct fuse_in_header *in,
         if(res2 == -ENOENT) {
             /* The open syscall was interrupted, so it must be cancelled */
             if(f->op.release)
-                f->op.release(path, arg->flags);
+                f->op.release(path, &fi);
         } else
             get_node(f, in->nodeid)->open_count ++;
         pthread_mutex_unlock(&f->lock);
@@ -1102,7 +1104,10 @@ static void do_flush(struct fuse *f, struct fuse_in_header *in,
 {
     char *path;
     int res;
+    struct fuse_file_info fi;
 
+    memset(&fi, 0, sizeof(fi));
+    fi.fh = arg->fh;
     res = -ENOENT;
     path = get_path(f, in->nodeid);
     if (path != NULL) {
@@ -1112,7 +1117,7 @@ static void do_flush(struct fuse *f, struct fuse_in_header *in,
         }
         res = -ENOSYS;
         if (f->op.flush)
-            res = f->op.flush(path);
+            res = f->op.flush(path, &fi);
         free(path);
     }
     send_reply(f, in, res, NULL, 0);
@@ -1123,6 +1128,11 @@ static void do_release(struct fuse *f, struct fuse_in_header *in,
 {
     struct node *node;
     char *path;
+    struct fuse_file_info fi;
+
+    memset(&fi, 0, sizeof(fi));
+    fi.flags = arg->flags;
+    fi.fh = arg->fh;
 
     pthread_mutex_lock(&f->lock);
     node = get_node(f, in->nodeid);
@@ -1136,7 +1146,7 @@ static void do_release(struct fuse *f, struct fuse_in_header *in,
             fflush(stdout);
         }
         if (f->op.release)
-            f->op.release(path, arg->flags);
+            f->op.release(path, &fi);
 
         if(node->is_hidden && node->open_count == 0)
             /* can now clean up this hidden file */
@@ -1160,7 +1170,11 @@ static void do_read(struct fuse *f, struct fuse_in_header *in,
         char *buf = outbuf + sizeof(struct fuse_out_header);
         size_t size;
         size_t outsize;
+        struct fuse_file_info fi;
         
+        memset(&fi, 0, sizeof(fi));
+        fi.fh = arg->fh;
+
         res = -ENOENT;
         path = get_path(f, in->nodeid);
         if (path != NULL) {
@@ -1172,7 +1186,7 @@ static void do_read(struct fuse *f, struct fuse_in_header *in,
             
             res = -ENOSYS;
             if (f->op.read)
-                res = f->op.read(path, buf, arg->size, arg->offset);
+                res = f->op.read(path, buf, arg->size, arg->offset, &fi);
             free(path);
         }
         
@@ -1201,6 +1215,10 @@ static void do_write(struct fuse *f, struct fuse_in_header *in,
     int res;
     char *path;
     struct fuse_write_out outarg;
+    struct fuse_file_info fi;
+
+    memset(&fi, 0, sizeof(fi));
+    fi.fh = arg->fh;
 
     res = -ENOENT;
     path = get_path(f, in->nodeid);
@@ -1214,7 +1232,7 @@ static void do_write(struct fuse *f, struct fuse_in_header *in,
 
         res = -ENOSYS;
         if (f->op.write)
-            res = f->op.write(path, PARAM(arg), arg->size, arg->offset);
+            res = f->op.write(path, PARAM(arg), arg->size, arg->offset, &fi);
         free(path);
     }
     
@@ -1267,6 +1285,10 @@ static void do_fsync(struct fuse *f, struct fuse_in_header *in,
 {
     int res;
     char *path;
+    struct fuse_file_info fi;
+
+    memset(&fi, 0, sizeof(fi));
+    fi.fh = inarg->fh;
 
     res = -ENOENT;
     path = get_path(f, in->nodeid);
@@ -1277,7 +1299,7 @@ static void do_fsync(struct fuse *f, struct fuse_in_header *in,
         }
         res = -ENOSYS;
         if (f->op.fsync)
-            res = f->op.fsync(path, inarg->datasync);
+            res = f->op.fsync(path, inarg->datasync, &fi);
         free(path);
     }
     send_reply(f, in, res, NULL, 0);
index ca230a9bfd08c7b656f54489432f9643687e3461..b9ea90354d1171ed9154ce55a6b67d4ac96c03da 100644 (file)
@@ -51,7 +51,6 @@ struct fuse {
     nodeid_t ctr;
     unsigned int generation;
     unsigned int hidectr;
-    unsigned long fh_ctr;
     pthread_mutex_t lock;
     int numworker;
     int numavail;