12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/kernel.h>
15 #include <linux/slab.h>
17 #include <linux/sched.h>
18 #include <linux/time.h>
21 #include <linux/xattr.h>
26 static size_t jffs2_acl_size(
int count)
38 static int jffs2_acl_count(
size_t size)
55 static struct posix_acl *jffs2_acl_from_medium(
void *
value,
size_t size)
75 count = jffs2_acl_count(size);
85 for (i=0; i <
count; i++) {
124 posix_acl_release(acl);
128 static void *jffs2_acl_to_medium(
const struct posix_acl *acl,
size_t *size)
135 *size = jffs2_acl_size(acl->
a_count);
141 for (i=0; i < acl->
a_count; i++) {
146 switch(acl_e->
e_tag) {
181 acl = get_cached_acl(inode, type);
203 acl = jffs2_acl_from_medium(value, rc);
212 set_cached_acl(inode, type, acl);
223 value = jffs2_acl_to_medium(acl, &size);
225 return PTR_ERR(value);
235 static int jffs2_set_acl(
struct inode *inode,
int type,
struct posix_acl *acl)
250 if (inode->
i_mode != mode) {
272 rc = __jffs2_set_acl(inode, xprefix, acl);
274 set_cached_acl(inode, type, acl);
304 posix_acl_release(acl);
313 if (inode->i_default_acl) {
336 if (IS_ERR(acl) || !acl)
342 posix_acl_release(acl);
347 size_t list_size,
const char *
name,
size_t name_len,
int type)
351 if (list && retlen <= list_size)
356 static size_t jffs2_acl_default_listxattr(
struct dentry *dentry,
char *list,
357 size_t list_size,
const char *name,
size_t name_len,
int type)
361 if (list && retlen <= list_size)
366 static int jffs2_acl_getxattr(
struct dentry *dentry,
const char *name,
367 void *
buffer,
size_t size,
int type)
381 posix_acl_release(acl);
386 static int jffs2_acl_setxattr(
struct dentry *dentry,
const char *name,
387 const void *value,
size_t size,
int flags,
int type)
409 rc = jffs2_set_acl(dentry->
d_inode, type, acl);
411 posix_acl_release(acl);
418 .list = jffs2_acl_access_listxattr,
419 .get = jffs2_acl_getxattr,
420 .set = jffs2_acl_setxattr,
426 .list = jffs2_acl_default_listxattr,
427 .get = jffs2_acl_getxattr,
428 .set = jffs2_acl_setxattr,