Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 218946
b: refs/heads/master
c: 6e8dc55
h: refs/heads/master
v: v3
  • Loading branch information
Aneesh Kumar K.V authored and Eric Van Hensbergen committed Oct 28, 2010
1 parent cf11d5e commit 337ec19
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 22d8dcdf8f8a3882d98757e78169014bb0bc6b23
refs/heads/master: 6e8dc55550273084b7fb5846df2f44439f5d03d9
55 changes: 55 additions & 0 deletions trunk/fs/9p/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,61 @@ int v9fs_check_acl(struct inode *inode, int mask)
return -EAGAIN;
}

static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl)
{
int retval;
char *name;
size_t size;
void *buffer;
struct inode *inode = dentry->d_inode;

set_cached_acl(inode, type, acl);
/* Set a setxattr request to server */
size = posix_acl_xattr_size(acl->a_count);
buffer = kmalloc(size, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
retval = posix_acl_to_xattr(acl, buffer, size);
if (retval < 0)
goto err_free_out;
switch (type) {
case ACL_TYPE_ACCESS:
name = POSIX_ACL_XATTR_ACCESS;
break;
case ACL_TYPE_DEFAULT:
name = POSIX_ACL_XATTR_DEFAULT;
break;
default:
BUG();
}
retval = v9fs_xattr_set(dentry, name, buffer, size, 0);
err_free_out:
kfree(buffer);
return retval;
}

int v9fs_acl_chmod(struct dentry *dentry)
{
int retval = 0;
struct posix_acl *acl, *clone;
struct inode *inode = dentry->d_inode;

if (S_ISLNK(inode->i_mode))
return -EOPNOTSUPP;
acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS);
if (acl) {
clone = posix_acl_clone(acl, GFP_KERNEL);
posix_acl_release(acl);
if (!clone)
return -ENOMEM;
retval = posix_acl_chmod_masq(clone, inode->i_mode);
if (!retval)
retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, clone);
posix_acl_release(clone);
}
return retval;
}

static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
{
Expand Down
5 changes: 5 additions & 0 deletions trunk/fs/9p/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
#ifdef CONFIG_9P_FS_POSIX_ACL
extern int v9fs_get_acl(struct inode *, struct p9_fid *);
extern int v9fs_check_acl(struct inode *inode, int mask);
extern int v9fs_acl_chmod(struct dentry *);
#else
#define v9fs_check_acl NULL
static inline int v9fs_get_acl(struct inode *inode, struct p9_fid *fid)
{
return 0;
}
static inline int v9fs_acl_chmod(struct dentry *dentry)
{
return 0;
}
#endif
#endif /* FS_9P_XATTR_H */
6 changes: 6 additions & 0 deletions trunk/fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,12 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)

setattr_copy(dentry->d_inode, iattr);
mark_inode_dirty(dentry->d_inode);
if (iattr->ia_valid & ATTR_MODE) {
/* We also want to update ACL when we update mode bits */
retval = v9fs_acl_chmod(dentry);
if (retval < 0)
return retval;
}
return 0;
}

Expand Down

0 comments on commit 337ec19

Please sign in to comment.