acl = posix_acl_alloc(count, GFP_KERNEL); if (!acl) return ERR_PTR(-ENOMEM);
for (i = 0; i < count; i++) {
acl_e = &acl->a_entries[i];
ace = &aclp->acl_entry[i];
/* * The tag is 32 bits on disk and 16 bits in core. * * Because every access to it goes through the core * format first this is not a problem.
*/
acl_e->e_tag = be32_to_cpu(ace->ae_tag);
acl_e->e_perm = be16_to_cpu(ace->ae_perm);
switch (acl_e->e_tag) { case ACL_USER:
acl_e->e_uid = make_kuid(&init_user_ns,
be32_to_cpu(ace->ae_id)); break; case ACL_GROUP:
acl_e->e_gid = make_kgid(&init_user_ns,
be32_to_cpu(ace->ae_id)); break; case ACL_USER_OBJ: case ACL_GROUP_OBJ: case ACL_MASK: case ACL_OTHER: break; default: goto fail;
}
} return acl;
/* * If the attribute doesn't exist make sure we have a negative cache * entry, for any other error assume it is transient.
*/
error = xfs_attr_get(&args); if (!error) {
acl = xfs_acl_from_disk(mp, args.value, args.valuelen,
XFS_ACL_MAX_ENTRIES(mp));
} elseif (error != -ENOATTR) {
acl = ERR_PTR(error);
}
kvfree(args.value); return acl;
}
int
__xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
{ struct xfs_inode *ip = XFS_I(inode); struct xfs_da_args args = {
.dp = ip,
.attr_filter = XFS_ATTR_ROOT,
}; int error;
switch (type) { case ACL_TYPE_ACCESS:
args.name = SGI_ACL_FILE; break; case ACL_TYPE_DEFAULT: if (!S_ISDIR(inode->i_mode)) return acl ? -EACCES : 0;
args.name = SGI_ACL_DEFAULT; break; default: return -EINVAL;
}
args.namelen = strlen(args.name);
if (acl) {
args.valuelen = XFS_ACL_SIZE(acl->a_count);
args.value = kvzalloc(args.valuelen, GFP_KERNEL); if (!args.value) return -ENOMEM;
xfs_acl_to_disk(args.value, acl);
error = xfs_attr_change(&args, XFS_ATTRUPDATE_UPSERT);
kvfree(args.value);
} else {
error = xfs_attr_change(&args, XFS_ATTRUPDATE_REMOVE); /* * If the attribute didn't exist to start with that's fine.
*/ if (error == -ENOATTR)
error = 0;
}
if (!error)
set_cached_acl(inode, type, acl); return error;
}
if (xfs_has_wsync(mp))
xfs_trans_set_sync(tp); return xfs_trans_commit(tp);
}
int
xfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, struct posix_acl *acl, int type)
{
umode_t mode; bool set_mode = false; int error = 0; struct inode *inode = d_inode(dentry);
if (!acl) goto set_acl;
error = -E2BIG; if (acl->a_count > XFS_ACL_MAX_ENTRIES(XFS_M(inode->i_sb))) return error;
if (type == ACL_TYPE_ACCESS) {
error = posix_acl_update_mode(idmap, inode, &mode, &acl); if (error) return error;
set_mode = true;
}
set_acl: /* * We set the mode after successfully updating the ACL xattr because the * xattr update can fail at ENOSPC and we don't want to change the mode * if the ACL update hasn't been applied.
*/
error = __xfs_set_acl(inode, acl, type); if (!error && set_mode && mode != inode->i_mode)
error = xfs_acl_set_mode(inode, mode); return error;
}
/* * Invalidate any cached ACLs if the user has bypassed the ACL interface. * We don't validate the content whatsoever so it is caller responsibility to * provide data in valid format and ensure i_mode is consistent.
*/ void
xfs_forget_acl( struct inode *inode, constchar *name)
{ if (!strcmp(name, SGI_ACL_FILE))
forget_cached_acl(inode, ACL_TYPE_ACCESS); elseif (!strcmp(name, SGI_ACL_DEFAULT))
forget_cached_acl(inode, ACL_TYPE_DEFAULT);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.