struct posix_acl *jffs2_get_acl(struct inode *inode, int type) { struct posix_acl *acl; char *value = NULL; int rc, xprefix; switch (type) { case ACL_TYPE_ACCESS: xprefix = JFFS2_XPREFIX_ACL_ACCESS; break; case ACL_TYPE_DEFAULT: xprefix = JFFS2_XPREFIX_ACL_DEFAULT; break; default: BUG(); } rc = do_jffs2_getxattr(inode, xprefix, "", NULL, 0); if (rc > 0) { value = kmalloc(rc, GFP_KERNEL); if (!value) return ERR_PTR(-ENOMEM); rc = do_jffs2_getxattr(inode, xprefix, "", value, rc); } if (rc > 0) { acl = jffs2_acl_from_medium(value, rc); } else if (rc == -ENODATA || rc == -ENOSYS) { acl = NULL; } else { acl = ERR_PTR(rc); } kfree(value); if (!IS_ERR(acl)) set_cached_acl(inode, type, acl); return acl; }
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; char *value = NULL; int rc, xprefix; switch (type) { 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; break; 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; break; default: return ERR_PTR(-EINVAL); } rc = do_jffs2_getxattr(inode, xprefix, "", NULL, 0); if (rc > 0) { value = kmalloc(rc, GFP_KERNEL); if (!value) return ERR_PTR(-ENOMEM); rc = do_jffs2_getxattr(inode, xprefix, "", value, rc); } if (rc > 0) { acl = jffs2_acl_from_medium(value, rc); } else if (rc == -ENODATA || rc == -ENOSYS) { acl = NULL; } else { acl = ERR_PTR(rc); } if (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; } } return acl; }
static int jffs2_user_getxattr(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *buffer, size_t size) { return do_jffs2_getxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size); }
static int jffs2_user_getxattr(struct inode *inode, const char *name, void *buffer, size_t size) { if (!strcmp(name, "")) return -EINVAL; return do_jffs2_getxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size); }
static int jffs2_user_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size, int type) { if (!strcmp(name, "")) return -EINVAL; return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_USER, name, buffer, size); }