From 31066bb5b8fbfa95545893a3a81a358430bfdd44 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 1 Aug 2005 14:49:31 +0000 Subject: [PATCH] fix --- ChangeLog | 2 ++ include/fuse.h | 18 +++++++++++++----- lib/Makefile.am | 2 +- lib/fuse.c | 15 +++++++-------- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index dbf7e1e..991f023 100644 --- 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 diff --git a/include/fuse.h b/include/fuse.h index bb700a7..db9a417 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -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 *); diff --git a/lib/Makefile.am b/lib/Makefile.am index 223b975..b99f9e2 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 diff --git a/lib/fuse.c b/lib/fuse.c index a849648..a798eaf 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -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 -- 2.30.2