23 #include <linux/module.h>
24 #include <linux/slab.h>
25 #include <linux/string.h>
62 for (n = 0; n <
count; n++) {
78 static void *ocfs2_acl_to_xattr(
const struct posix_acl *acl,
size_t *size)
91 for (n = 0; n < acl->
a_count; n++, entry++) {
101 struct buffer_head *di_bh)
129 acl = ocfs2_acl_from_xattr(value, retval);
130 else if (retval == -
ENODATA || retval == 0)
133 acl = ERR_PTR(retval);
144 static struct posix_acl *ocfs2_get_acl(
struct inode *inode,
int type)
147 struct buffer_head *di_bh =
NULL;
161 acl = ocfs2_get_acl_nolock(inode, type, di_bh);
175 static int ocfs2_acl_set_mode(
struct inode *inode,
struct buffer_head *di_bh,
178 int ret, commit_handle = 0;
190 if (handle ==
NULL) {
193 if (IS_ERR(handle)) {
194 ret = PTR_ERR(handle);
230 static int ocfs2_set_acl(handle_t *handle,
232 struct buffer_head *di_bh,
258 ret = ocfs2_acl_set_mode(inode, di_bh,
276 value = ocfs2_acl_to_xattr(acl, &size);
278 return (
int)PTR_ERR(value);
296 struct buffer_head *di_bh =
NULL;
308 acl = ocfs2_get_acl_nolock(inode, type, di_bh);
328 if (IS_ERR(acl) || !acl)
335 posix_acl_release(acl);
346 struct buffer_head *di_bh,
347 struct buffer_head *dir_bh,
365 ret = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
374 ret = ocfs2_set_acl(handle, inode, di_bh,
385 ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
392 ret = ocfs2_set_acl(handle, inode,
394 acl, meta_ac, data_ac);
398 posix_acl_release(acl);
402 static size_t ocfs2_xattr_list_acl_access(
struct dentry *
dentry,
415 if (list && size <= list_len)
420 static size_t ocfs2_xattr_list_acl_default(
struct dentry *dentry,
433 if (list && size <= list_len)
438 static int ocfs2_xattr_get_acl(
struct dentry *dentry,
const char *name,
439 void *
buffer,
size_t size,
int type)
445 if (
strcmp(name,
"") != 0)
450 acl = ocfs2_get_acl(dentry->
d_inode, type);
456 posix_acl_release(acl);
461 static int ocfs2_xattr_set_acl(
struct dentry *dentry,
const char *name,
462 const void *value,
size_t size,
int flags,
int type)
464 struct inode *inode = dentry->
d_inode;
469 if (
strcmp(name,
"") != 0)
492 posix_acl_release(acl);
499 .list = ocfs2_xattr_list_acl_access,
500 .get = ocfs2_xattr_get_acl,
501 .set = ocfs2_xattr_set_acl,
507 .list = ocfs2_xattr_list_acl_default,
508 .get = ocfs2_xattr_get_acl,
509 .set = ocfs2_xattr_set_acl,