Skip to content

Commit

Permalink
[PATCH] FUSE: add access call
Browse files Browse the repository at this point in the history
Add a new access call, which will only be called if ->permission is invoked
from sys_access().  In all other cases permission checking is delayed until
the actual filesystem operation.

Signed-off-by: Miklos Szeredi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
szmi authored and Linus Torvalds committed Nov 7, 2005
1 parent 5b62073 commit 31d40d7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
35 changes: 35 additions & 0 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,38 @@ static int fuse_revalidate(struct dentry *entry)
return fuse_do_getattr(inode);
}

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;
}

static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
{
struct fuse_conn *fc = get_fuse_conn(inode);
Expand Down Expand Up @@ -493,6 +525,9 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
int mode = inode->i_mode;
if ((mask & MAY_EXEC) && !S_ISDIR(mode) && !(mode & S_IXUGO))
return -EACCES;

if (nd && (nd->flags & LOOKUP_ACCESS))
return fuse_access(inode, mask);
return 0;
}
}
Expand Down
3 changes: 3 additions & 0 deletions fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ struct fuse_conn {
/** Is removexattr not implemented by fs? */
unsigned no_removexattr : 1;

/** Is access not implemented by fs? */
unsigned no_access : 1;

/** Backing dev info */
struct backing_dev_info bdi;
};
Expand Down
8 changes: 7 additions & 1 deletion include/linux/fuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ enum fuse_opcode {
FUSE_OPENDIR = 27,
FUSE_READDIR = 28,
FUSE_RELEASEDIR = 29,
FUSE_FSYNCDIR = 30
FUSE_FSYNCDIR = 30,
FUSE_ACCESS = 34
};

/* Conservative buffer size for the client */
Expand Down Expand Up @@ -222,6 +223,11 @@ struct fuse_getxattr_out {
__u32 padding;
};

struct fuse_access_in {
__u32 mask;
__u32 padding;
};

struct fuse_init_in_out {
__u32 major;
__u32 minor;
Expand Down

0 comments on commit 31d40d7

Please sign in to comment.