From 8fb48feb5024d2aa9083690e472f1b1072cb8169 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 8 Nov 2004 14:48:52 +0000 Subject: [PATCH] getdir related API change --- ChangeLog | 7 +++++++ example/fusexmp.c | 4 ++-- example/hello.c | 8 ++++---- include/fuse.h | 18 ++++++++++++------ lib/fuse.c | 10 +++++++--- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index b2fb5aa..b065e2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-11-08 Miklos Szeredi + + * 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 * Added "use_ino" mount option. This enables the filesystems to diff --git a/example/fusexmp.c b/example/fusexmp.c index 9b86a4c..57045be 100644 --- a/example/fusexmp.c +++ b/example/fusexmp.c @@ -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; } diff --git a/example/hello.c b/example/hello.c index c7a0c1c..37020b2 100644 --- a/example/hello.c +++ b/example/hello.c @@ -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; } diff --git a/include/fuse.h b/include/fuse.h index 705c4fd..8a0fd3c 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -27,6 +27,10 @@ #include #include +#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 + * @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... * * ----------------------------------------------------------- */ diff --git a/lib/fuse.c b/lib/fuse.c index 6b42252..ddb7ce3 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -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); -- 2.30.2