+2005-10-26 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Add ACCESS operation. This is called from the access() system
+ call if 'default_permissions' mount option is not given
+
2005-10-18 Miklos Szeredi <miklos@szeredi.hu>
* lib: optimize buffer reallocation in fill_dir.
-AC_INIT(fuse, 2.4.1)
+AC_INIT(fuse, 2.5.0-pre0)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(include/config.h)
return 0;
}
+static int xmp_access(const char *path, int mask)
+{
+ int res;
+
+ res = access(path, mask);
+ if(res == -1)
+ return -errno;
+
+ return 0;
+}
+
static int xmp_readlink(const char *path, char *buf, size_t size)
{
int res;
static struct fuse_operations xmp_oper = {
.getattr = xmp_getattr,
+ .access = xmp_access,
.readlink = xmp_readlink,
.readdir = xmp_readdir,
.mknod = xmp_mknod,
return 0;
}
+static int xmp_access(const char *path, int mask)
+{
+ int res;
+
+ res = access(path, mask);
+ if(res == -1)
+ return -errno;
+
+ return 0;
+}
+
static int xmp_readlink(const char *path, char *buf, size_t size)
{
int res;
static struct fuse_operations xmp_oper = {
.getattr = xmp_getattr,
+ .access = xmp_access,
.readlink = xmp_readlink,
.opendir = xmp_opendir,
.readdir = xmp_readdir,
*
* All methods are optional, but some are essential for a useful
* 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.
+ * releasedir, fsyncdir, access, init and destroy are special purpose
+ * methods, without which a full featured filesystem can still be
+ * implemented.
*/
struct fuse_operations {
/** Get file attributes.
* Introduced in version 2.3
*/
void (*destroy) (void *);
+
+ /**
+ * Check file access permissions
+ *
+ * Need not be implemented. This will be called for the access()
+ * system call. If the 'default_permissions' mount option is
+ * given, this method is not called.
+ *
+ * Introduced in version 2.5
+ */
+ int (*access) (const char *, int);
};
/** Extra context that may be needed by some filesystems
#define FUSE_MAJOR_VERSION 2
/** Minor version of FUSE library interface */
-#define FUSE_MINOR_VERSION 4
+#define FUSE_MINOR_VERSION 5
#define FUSE_MAKE_VERSION(maj, min) ((maj) * 10 + (min))
#define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
* @param name of the extended attribute
*/
void (*removexattr) (fuse_req_t req, fuse_ino_t ino, const char *name);
+
+ void (*access) (fuse_req_t req, fuse_ino_t ino, int mask);
};
/**
-AC_INIT(fuse-kernel, 2.4.1)
+AC_INIT(fuse-kernel, 2.5.0-pre0)
AC_CONFIG_HEADERS([config.h])
AC_PROG_INSTALL
return fuse_do_getattr(inode);
}
+#ifdef KERNEL_2_6
+static int fuse_access(struct inode *inode, int mask)
+{
+ struct fuse_conn *fc = get_fuse_conn(inode);
+ struct fuse_req *req;
+ struct fuse_access_in inarg;
+ int err;
+
+ if (fc->no_access)
+ return 0;
+
+ req = fuse_get_request(fc);
+ if (!req)
+ return -EINTR;
+
+ memset(&inarg, 0, sizeof(inarg));
+ inarg.mask = mask;
+ req->in.h.opcode = FUSE_ACCESS;
+ req->in.h.nodeid = get_node_id(inode);
+ req->inode = inode;
+ req->in.numargs = 1;
+ req->in.args[0].size = sizeof(inarg);
+ req->in.args[0].value = &inarg;
+ request_send(fc, req);
+ err = req->out.h.error;
+ fuse_put_request(fc, req);
+ if (err == -ENOSYS) {
+ fc->no_access = 1;
+ err = 0;
+ }
+ return err;
+}
+#endif
+
static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
{
struct fuse_conn *fc = get_fuse_conn(inode);
return -EROFS;
if ((mask & MAY_EXEC) && !S_ISDIR(mode) && !(mode & S_IXUGO))
return -EACCES;
+
+#ifdef KERNEL_2_6
+ if (nd && (nd->flags & LOOKUP_ACCESS))
+ return fuse_access(inode, mask);
+#endif
return 0;
}
}
/** Is removexattr not implemented by fs? */
unsigned no_removexattr : 1;
+ /** Is access not implemented by fs? */
+ unsigned no_access : 1;
+
#ifdef KERNEL_2_6
/** Backing dev info */
struct backing_dev_info bdi;
FUSE_OPENDIR = 27,
FUSE_READDIR = 28,
FUSE_RELEASEDIR = 29,
- FUSE_FSYNCDIR = 30
+ FUSE_FSYNCDIR = 30,
+ FUSE_ACCESS = 34
};
/* Conservative buffer size for the client */
__u32 padding;
};
+struct fuse_access_in {
+ __u32 mask;
+ __u32 padding;
+};
+
struct fuse_init_in_out {
__u32 major;
__u32 minor;
helper.c \
mount.c
-libfuse_la_LDFLAGS = -lpthread -version-number 2:4:1 \
+libfuse_la_LDFLAGS = -lpthread -version-number 2:5:0 \
-Wl,--version-script,fuse_versionscript
EXTRA_DIST = fuse_versionscript
reply_err(req, err);
}
+static void fuse_access(fuse_req_t req, fuse_ino_t ino, int mask)
+{
+ struct fuse *f = req_fuse_prepare(req);
+ char *path;
+ int err;
+
+ err = -ENOENT;
+ pthread_rwlock_rdlock(&f->tree_lock);
+ path = get_path(f, ino);
+ if (path != NULL) {
+ if (f->flags & FUSE_DEBUG) {
+ printf("ACCESS %s 0%o\n", path, mask);
+ fflush(stdout);
+ }
+ err = -ENOSYS;
+ if (f->op.access)
+ err = f->op.access(path, mask);
+ free(path);
+ }
+ pthread_rwlock_unlock(&f->tree_lock);
+ reply_err(req, err);
+}
+
static void fuse_readlink(fuse_req_t req, fuse_ino_t ino)
{
struct fuse *f = req_fuse_prepare(req);
.forget = fuse_forget,
.getattr = fuse_getattr,
.setattr = fuse_setattr,
+ .access = fuse_access,
.readlink = fuse_readlink,
.mknod = fuse_mknod,
.mkdir = fuse_mkdir,
case FUSE_READDIR: return "READDIR";
case FUSE_RELEASEDIR: return "RELEASEDIR";
case FUSE_FSYNCDIR: return "FSYNCDIR";
+ case FUSE_ACCESS: return "ACCESS";
default: return "???";
}
}
fuse_reply_err(req, ENOSYS);
}
+static void do_access(fuse_req_t req, fuse_ino_t nodeid,
+ struct fuse_access_in *arg)
+{
+ if (req->f->op.access)
+ req->f->op.access(req, nodeid, arg->mask);
+ else
+ fuse_reply_err(req, ENOSYS);
+}
+
static void do_readlink(fuse_req_t req, fuse_ino_t nodeid)
{
if (req->f->op.readlink)
do_fsyncdir(req, in->nodeid, (struct fuse_fsync_in *) inarg);
break;
+ case FUSE_ACCESS:
+ do_access(req, in->nodeid, (struct fuse_access_in *) inarg);
+ break;
+
default:
fuse_reply_err(req, ENOSYS);
}