|
@@ -156,48 +156,25 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
|
|
return ERR_PTR(-EINVAL);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
}
|
|
|
|
|
|
-static struct posix_acl *jffs2_iget_acl(struct inode *inode, struct posix_acl **i_acl)
|
|
|
|
-{
|
|
|
|
- struct posix_acl *acl = JFFS2_ACL_NOT_CACHED;
|
|
|
|
-
|
|
|
|
- spin_lock(&inode->i_lock);
|
|
|
|
- if (*i_acl != JFFS2_ACL_NOT_CACHED)
|
|
|
|
- acl = posix_acl_dup(*i_acl);
|
|
|
|
- spin_unlock(&inode->i_lock);
|
|
|
|
- return acl;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static void jffs2_iset_acl(struct inode *inode, struct posix_acl **i_acl, struct posix_acl *acl)
|
|
|
|
-{
|
|
|
|
- spin_lock(&inode->i_lock);
|
|
|
|
- if (*i_acl != JFFS2_ACL_NOT_CACHED)
|
|
|
|
- posix_acl_release(*i_acl);
|
|
|
|
- *i_acl = posix_acl_dup(acl);
|
|
|
|
- spin_unlock(&inode->i_lock);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
|
|
static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
|
|
{
|
|
{
|
|
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
|
|
|
struct posix_acl *acl;
|
|
struct posix_acl *acl;
|
|
char *value = NULL;
|
|
char *value = NULL;
|
|
int rc, xprefix;
|
|
int rc, xprefix;
|
|
|
|
|
|
|
|
+ acl = get_cached_acl(inode, type);
|
|
|
|
+ if (acl != ACL_NOT_CACHED)
|
|
|
|
+ return acl;
|
|
|
|
+
|
|
switch (type) {
|
|
switch (type) {
|
|
case ACL_TYPE_ACCESS:
|
|
case ACL_TYPE_ACCESS:
|
|
- acl = jffs2_iget_acl(inode, &f->i_acl_access);
|
|
|
|
- if (acl != JFFS2_ACL_NOT_CACHED)
|
|
|
|
- return acl;
|
|
|
|
xprefix = JFFS2_XPREFIX_ACL_ACCESS;
|
|
xprefix = JFFS2_XPREFIX_ACL_ACCESS;
|
|
break;
|
|
break;
|
|
case ACL_TYPE_DEFAULT:
|
|
case ACL_TYPE_DEFAULT:
|
|
- acl = jffs2_iget_acl(inode, &f->i_acl_default);
|
|
|
|
- if (acl != JFFS2_ACL_NOT_CACHED)
|
|
|
|
- return acl;
|
|
|
|
xprefix = JFFS2_XPREFIX_ACL_DEFAULT;
|
|
xprefix = JFFS2_XPREFIX_ACL_DEFAULT;
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- return ERR_PTR(-EINVAL);
|
|
|
|
|
|
+ BUG();
|
|
}
|
|
}
|
|
rc = do_jffs2_getxattr(inode, xprefix, "", NULL, 0);
|
|
rc = do_jffs2_getxattr(inode, xprefix, "", NULL, 0);
|
|
if (rc > 0) {
|
|
if (rc > 0) {
|
|
@@ -215,16 +192,8 @@ static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
|
|
}
|
|
}
|
|
if (value)
|
|
if (value)
|
|
kfree(value);
|
|
kfree(value);
|
|
- if (!IS_ERR(acl)) {
|
|
|
|
- switch (type) {
|
|
|
|
- case ACL_TYPE_ACCESS:
|
|
|
|
- jffs2_iset_acl(inode, &f->i_acl_access, acl);
|
|
|
|
- break;
|
|
|
|
- case ACL_TYPE_DEFAULT:
|
|
|
|
- jffs2_iset_acl(inode, &f->i_acl_default, acl);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (!IS_ERR(acl))
|
|
|
|
+ set_cached_acl(inode, type, acl);
|
|
return acl;
|
|
return acl;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -249,7 +218,6 @@ static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *a
|
|
|
|
|
|
static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
|
|
static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
|
|
{
|
|
{
|
|
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
|
|
|
int rc, xprefix;
|
|
int rc, xprefix;
|
|
|
|
|
|
if (S_ISLNK(inode->i_mode))
|
|
if (S_ISLNK(inode->i_mode))
|
|
@@ -285,16 +253,8 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
rc = __jffs2_set_acl(inode, xprefix, acl);
|
|
rc = __jffs2_set_acl(inode, xprefix, acl);
|
|
- if (!rc) {
|
|
|
|
- switch(type) {
|
|
|
|
- case ACL_TYPE_ACCESS:
|
|
|
|
- jffs2_iset_acl(inode, &f->i_acl_access, acl);
|
|
|
|
- break;
|
|
|
|
- case ACL_TYPE_DEFAULT:
|
|
|
|
- jffs2_iset_acl(inode, &f->i_acl_default, acl);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (!rc)
|
|
|
|
+ set_cached_acl(inode, type, acl);
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -321,12 +281,11 @@ int jffs2_permission(struct inode *inode, int mask)
|
|
|
|
|
|
int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
|
|
int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
|
|
{
|
|
{
|
|
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
|
|
|
struct posix_acl *acl, *clone;
|
|
struct posix_acl *acl, *clone;
|
|
int rc;
|
|
int rc;
|
|
|
|
|
|
- f->i_acl_default = NULL;
|
|
|
|
- f->i_acl_access = NULL;
|
|
|
|
|
|
+ inode->i_default_acl = NULL;
|
|
|
|
+ inode->i_acl = NULL;
|
|
|
|
|
|
if (S_ISLNK(*i_mode))
|
|
if (S_ISLNK(*i_mode))
|
|
return 0; /* Symlink always has no-ACL */
|
|
return 0; /* Symlink always has no-ACL */
|
|
@@ -339,7 +298,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
|
|
*i_mode &= ~current_umask();
|
|
*i_mode &= ~current_umask();
|
|
} else {
|
|
} else {
|
|
if (S_ISDIR(*i_mode))
|
|
if (S_ISDIR(*i_mode))
|
|
- jffs2_iset_acl(inode, &f->i_acl_default, acl);
|
|
|
|
|
|
+ set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
|
|
|
|
|
|
clone = posix_acl_clone(acl, GFP_KERNEL);
|
|
clone = posix_acl_clone(acl, GFP_KERNEL);
|
|
if (!clone)
|
|
if (!clone)
|
|
@@ -350,7 +309,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
if (rc > 0)
|
|
if (rc > 0)
|
|
- jffs2_iset_acl(inode, &f->i_acl_access, clone);
|
|
|
|
|
|
+ set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
|
|
|
|
|
|
posix_acl_release(clone);
|
|
posix_acl_release(clone);
|
|
}
|
|
}
|
|
@@ -359,17 +318,16 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
|
|
|
|
|
|
int jffs2_init_acl_post(struct inode *inode)
|
|
int jffs2_init_acl_post(struct inode *inode)
|
|
{
|
|
{
|
|
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
|
|
|
int rc;
|
|
int rc;
|
|
|
|
|
|
- if (f->i_acl_default) {
|
|
|
|
- rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_DEFAULT, f->i_acl_default);
|
|
|
|
|
|
+ if (inode->i_default_acl) {
|
|
|
|
+ rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_DEFAULT, inode->i_default_acl);
|
|
if (rc)
|
|
if (rc)
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
- if (f->i_acl_access) {
|
|
|
|
- rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_ACCESS, f->i_acl_access);
|
|
|
|
|
|
+ if (inode->i_acl) {
|
|
|
|
+ rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_ACCESS, inode->i_acl);
|
|
if (rc)
|
|
if (rc)
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
@@ -377,18 +335,6 @@ int jffs2_init_acl_post(struct inode *inode)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-void jffs2_clear_acl(struct jffs2_inode_info *f)
|
|
|
|
-{
|
|
|
|
- if (f->i_acl_access && f->i_acl_access != JFFS2_ACL_NOT_CACHED) {
|
|
|
|
- posix_acl_release(f->i_acl_access);
|
|
|
|
- f->i_acl_access = JFFS2_ACL_NOT_CACHED;
|
|
|
|
- }
|
|
|
|
- if (f->i_acl_default && f->i_acl_default != JFFS2_ACL_NOT_CACHED) {
|
|
|
|
- posix_acl_release(f->i_acl_default);
|
|
|
|
- f->i_acl_default = JFFS2_ACL_NOT_CACHED;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
int jffs2_acl_chmod(struct inode *inode)
|
|
int jffs2_acl_chmod(struct inode *inode)
|
|
{
|
|
{
|
|
struct posix_acl *acl, *clone;
|
|
struct posix_acl *acl, *clone;
|