getdir related API change
authorMiklos Szeredi <miklos@szeredi.hu>
Mon, 8 Nov 2004 14:48:52 +0000 (14:48 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Mon, 8 Nov 2004 14:48:52 +0000 (14:48 +0000)
ChangeLog
example/fusexmp.c
example/hello.c
include/fuse.h
lib/fuse.c

index b2fb5aa8ae5bbdb74f472fc80e7c0887c0bf958d..b065e2ad432090a3b9864e91041a38e1f7ceee9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-11-08  Miklos Szeredi <miklos@szeredi.hu>
+
+       * Add ino argument to 'fuse_dirfil_t'.  NOTE: this is a backward
+       compatible change (if "use_ino" mount option is not specified),
+       but causes a warning when compiling filesystems not converted to
+       the new type.
 2004-11-02  Miklos Szeredi <miklos@szeredi.hu>
 
        * Added "use_ino" mount option.  This enables the filesystems to
index 9b86a4c3f0900ceb10889a0aa37881e209c06976..57045be58e80f231a82f3d281a1783eddfd21ca3 100644 (file)
@@ -49,7 +49,7 @@ static int xmp_readlink(const char *path, char *buf, size_t size)
 }
 
 
-static int xmp_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler)
+static int xmp_getdir(const char *path, fuse_dirh_t h, fuse_dirfil2_t filler)
 {
     DIR *dp;
     struct dirent *de;
@@ -60,7 +60,7 @@ static int xmp_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler)
         return -errno;
 
     while((de = readdir(dp)) != NULL) {
-        res = filler(h, de->d_name, de->d_type);
+        res = filler(h, de->d_name, de->d_type, de->d_ino);
         if(res != 0)
             break;
     }
index c7a0c1c4f625b32c82fcff37f45b5e982db1d21f..37020b29380cf82ff0b72e0a68d55c76369d922d 100644 (file)
@@ -35,14 +35,14 @@ static int hello_getattr(const char *path, struct stat *stbuf)
     return res;
 }
 
-static int hello_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler)
+static int hello_getdir(const char *path, fuse_dirh_t h, fuse_dirfil2_t filler)
 {
     if(strcmp(path, "/") != 0)
         return -ENOENT;
 
-    filler(h, ".", 0);
-    filler(h, "..", 0);
-    filler(h, hello_path + 1, 0);
+    filler(h, ".", 0, 0);
+    filler(h, "..", 0, 0);
+    filler(h, hello_path + 1, 0, 0);
 
     return 0;
 }
index 705c4fdb6de6e7c647aa20e41834b332196132c5..8a0fd3ccd386129b2202e7fbb59b58c2722e1a17 100644 (file)
 #include <sys/statfs.h>
 #include <utime.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* ----------------------------------------------------------- *
  * Basic FUSE API                                              *
  * ----------------------------------------------------------- */
@@ -42,8 +46,14 @@ typedef struct fuse_dirhandle *fuse_dirh_t;
  * @param h the handle passed to the getdir() operation
  * @param name the file name of the directory entry
  * @param type the file type (0 if unknown)  see <dirent.h>
+ * @param ino the inode number, ignored if "use_ino" mount option is
+ *            not specified
  * @return 0 on success, -errno on error
  */
+typedef int (*fuse_dirfil2_t) (fuse_dirh_t h, const char *name, int type,
+                               ino_t ino);
+
+/** Obsolete version of the above function */
 typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type);
 
 /**
@@ -106,7 +116,7 @@ typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type);
 struct fuse_operations {
     int (*getattr)     (const char *, struct stat *);
     int (*readlink)    (const char *, char *, size_t);
-    int (*getdir)      (const char *, fuse_dirh_t, fuse_dirfil_t);
+    int (*getdir)      (const char *, fuse_dirh_t, fuse_dirfil2_t);
     int (*mknod)       (const char *, mode_t, dev_t);
     int (*mkdir)       (const char *, mode_t);
     int (*unlink)      (const char *);
@@ -137,12 +147,9 @@ struct fuse_context {
     uid_t uid;
     gid_t gid;
     pid_t pid;
+    void *private_data;
 };
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /*
  * Main function of FUSE.
  *
@@ -271,7 +278,6 @@ int fuse_invalidate(struct fuse *f, const char *path);
  */
 int fuse_is_lib_option(const char *opt);
 
-
 /* ----------------------------------------------------------- *
  * Advanced API for event handling, don't worry about this...  *
  * ----------------------------------------------------------- */
index 6b42252bfcdeb08a6ef0498a7a9f5fd5e433fcc9..ddb7ce315a404e33f7cc1ba03b573786a999d53d 100644 (file)
@@ -429,13 +429,17 @@ static void convert_stat(struct stat *stbuf, struct fuse_attr *attr)
 #endif
 }
 
-static int fill_dir(struct fuse_dirhandle *dh, char *name, int type)
+static int fill_dir(struct fuse_dirhandle *dh, const char *name, int type,
+                    ino_t ino)
 {
     struct fuse_dirent dirent;
     size_t reclen;
     size_t res;
 
-    dirent.ino = (unsigned long) -1;
+    if ((dh->fuse->flags & FUSE_USE_INO))
+        dirent.ino = ino;
+    else
+        dirent.ino = (unsigned long) -1;
     dirent.namelen = strlen(name);
     strncpy(dirent.name, name, sizeof(dirent.name));
     dirent.type = type;
@@ -821,7 +825,7 @@ static void do_getdir(struct fuse *f, struct fuse_in_header *in)
         if (path != NULL) {
             res = -ENOSYS;
             if (f->op.getdir)
-                res = f->op.getdir(path, &dh, (fuse_dirfil_t) fill_dir);
+                res = f->op.getdir(path, &dh, fill_dir);
             free(path);
         }
         fflush(dh.fp);