diff options
author | Joe Gorse <jhgorse@gmail.com> | 2019-04-25 15:26:52 +0200 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2019-05-07 17:48:44 +0200 |
commit | b10494af4989d2d20679d0e3b7d1a45c2f8f8f1a (patch) | |
tree | 27a9fcdea021ddcb324da97695aa2efb8326ff69 /fs/afs/xattr.c | |
parent | afs: Get an AFS3 ACL as an xattr (diff) | |
download | linux-b10494af4989d2d20679d0e3b7d1a45c2f8f8f1a.tar.xz linux-b10494af4989d2d20679d0e3b7d1a45c2f8f8f1a.zip |
afs: implement acl setting
Implements the setting of ACLs in AFS by means of setting the
afs.acl extended attribute on the file.
Signed-off-by: Joe Gorse <jhgorse@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs/xattr.c')
-rw-r--r-- | fs/afs/xattr.c | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c index b7d3d714d8ff..31db360947a6 100644 --- a/fs/afs/xattr.c +++ b/fs/afs/xattr.c @@ -80,9 +80,57 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler, return ret; } +/* + * Set a file's AFS3 ACL. + */ +static int afs_xattr_set_acl(const struct xattr_handler *handler, + struct dentry *dentry, + struct inode *inode, const char *name, + const void *buffer, size_t size, int flags) +{ + struct afs_fs_cursor fc; + struct afs_vnode *vnode = AFS_FS_I(inode); + struct afs_acl *acl = NULL; + struct key *key; + int ret; + + if (flags == XATTR_CREATE) + return -EINVAL; + + key = afs_request_key(vnode->volume->cell); + if (IS_ERR(key)) + return PTR_ERR(key); + + acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL); + if (!acl) { + key_put(key); + return -ENOMEM; + } + + acl->size = size; + memcpy(acl->data, buffer, size); + + ret = -ERESTARTSYS; + if (afs_begin_vnode_operation(&fc, vnode, key)) { + while (afs_select_fileserver(&fc)) { + fc.cb_break = afs_calc_vnode_cb_break(vnode); + afs_fs_store_acl(&fc, acl); + } + + afs_check_for_remote_deletion(&fc, fc.vnode); + afs_vnode_commit_status(&fc, vnode, fc.cb_break); + ret = afs_end_vnode_operation(&fc); + } + + kfree(acl); + key_put(key); + return ret; +} + static const struct xattr_handler afs_xattr_afs_acl_handler = { - .name = "afs.acl", - .get = afs_xattr_get_acl, + .name = "afs.acl", + .get = afs_xattr_get_acl, + .set = afs_xattr_set_acl, }; /* |