mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-16 12:14:06 +00:00
ntfs3: rework xattr handlers and switch to POSIX ACL VFS helpers
[ Upstream commita26aa12384
] The xattr code in ntfs3 is currently a bit confused. For example, it defines a POSIX ACL i_op->set_acl() method but instead of relying on the generic POSIX ACL VFS helpers it defines its own set of xattr helpers with the consequence that i_op->set_acl() is currently dead code. Switch ntfs3 to rely on the VFS POSIX ACL xattr handlers. Also remove i_op->{g,s}et_acl() methods from symlink inode operations. Symlinks don't support xattrs. This is a preliminary change for the following patches which move handling idmapped mounts directly in posix_acl_xattr_set(). This survives POSIX ACL xfstests. Fixes:be71b5cba2
("fs/ntfs3: Add attrib operations") Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Reviewed-by: Seth Forshee (DigitalOcean) <sforshee@kernel.org>> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
18d219baa0
commit
a80982785a
2 changed files with 6 additions and 98 deletions
|
@ -1942,8 +1942,6 @@ const struct inode_operations ntfs_link_inode_operations = {
|
|||
.setattr = ntfs3_setattr,
|
||||
.listxattr = ntfs_listxattr,
|
||||
.permission = ntfs_permission,
|
||||
.get_acl = ntfs_get_acl,
|
||||
.set_acl = ntfs_set_acl,
|
||||
};
|
||||
|
||||
const struct address_space_operations ntfs_aops = {
|
||||
|
|
102
fs/ntfs3/xattr.c
102
fs/ntfs3/xattr.c
|
@ -623,67 +623,6 @@ int ntfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
|
|||
return ntfs_set_acl_ex(mnt_userns, inode, acl, type, false);
|
||||
}
|
||||
|
||||
static int ntfs_xattr_get_acl(struct user_namespace *mnt_userns,
|
||||
struct inode *inode, int type, void *buffer,
|
||||
size_t size)
|
||||
{
|
||||
struct posix_acl *acl;
|
||||
int err;
|
||||
|
||||
if (!(inode->i_sb->s_flags & SB_POSIXACL)) {
|
||||
ntfs_inode_warn(inode, "add mount option \"acl\" to use acl");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
acl = ntfs_get_acl(inode, type, false);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
|
||||
if (!acl)
|
||||
return -ENODATA;
|
||||
|
||||
err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int ntfs_xattr_set_acl(struct user_namespace *mnt_userns,
|
||||
struct inode *inode, int type, const void *value,
|
||||
size_t size)
|
||||
{
|
||||
struct posix_acl *acl;
|
||||
int err;
|
||||
|
||||
if (!(inode->i_sb->s_flags & SB_POSIXACL)) {
|
||||
ntfs_inode_warn(inode, "add mount option \"acl\" to use acl");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
if (!inode_owner_or_capable(mnt_userns, inode))
|
||||
return -EPERM;
|
||||
|
||||
if (!value) {
|
||||
acl = NULL;
|
||||
} else {
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
|
||||
if (acl) {
|
||||
err = posix_acl_valid(&init_user_ns, acl);
|
||||
if (err)
|
||||
goto release_and_out;
|
||||
}
|
||||
}
|
||||
|
||||
err = ntfs_set_acl(mnt_userns, inode, acl, type);
|
||||
|
||||
release_and_out:
|
||||
posix_acl_release(acl);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* ntfs_init_acl - Initialize the ACLs of a new inode.
|
||||
*
|
||||
|
@ -850,23 +789,6 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,
|
|||
goto out;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NTFS3_FS_POSIX_ACL
|
||||
if ((name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 &&
|
||||
!memcmp(name, XATTR_NAME_POSIX_ACL_ACCESS,
|
||||
sizeof(XATTR_NAME_POSIX_ACL_ACCESS))) ||
|
||||
(name_len == sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1 &&
|
||||
!memcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
|
||||
sizeof(XATTR_NAME_POSIX_ACL_DEFAULT)))) {
|
||||
/* TODO: init_user_ns? */
|
||||
err = ntfs_xattr_get_acl(
|
||||
&init_user_ns, inode,
|
||||
name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1
|
||||
? ACL_TYPE_ACCESS
|
||||
: ACL_TYPE_DEFAULT,
|
||||
buffer, size);
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
/* Deal with NTFS extended attribute. */
|
||||
err = ntfs_get_ea(inode, name, name_len, buffer, size, NULL);
|
||||
|
||||
|
@ -979,22 +901,6 @@ set_new_fa:
|
|||
goto out;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NTFS3_FS_POSIX_ACL
|
||||
if ((name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 &&
|
||||
!memcmp(name, XATTR_NAME_POSIX_ACL_ACCESS,
|
||||
sizeof(XATTR_NAME_POSIX_ACL_ACCESS))) ||
|
||||
(name_len == sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1 &&
|
||||
!memcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
|
||||
sizeof(XATTR_NAME_POSIX_ACL_DEFAULT)))) {
|
||||
err = ntfs_xattr_set_acl(
|
||||
mnt_userns, inode,
|
||||
name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1
|
||||
? ACL_TYPE_ACCESS
|
||||
: ACL_TYPE_DEFAULT,
|
||||
value, size);
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
/* Deal with NTFS extended attribute. */
|
||||
err = ntfs_set_ea(inode, name, name_len, value, size, flags);
|
||||
|
||||
|
@ -1082,7 +988,7 @@ static bool ntfs_xattr_user_list(struct dentry *dentry)
|
|||
}
|
||||
|
||||
// clang-format off
|
||||
static const struct xattr_handler ntfs_xattr_handler = {
|
||||
static const struct xattr_handler ntfs_other_xattr_handler = {
|
||||
.prefix = "",
|
||||
.get = ntfs_getxattr,
|
||||
.set = ntfs_setxattr,
|
||||
|
@ -1090,7 +996,11 @@ static const struct xattr_handler ntfs_xattr_handler = {
|
|||
};
|
||||
|
||||
const struct xattr_handler *ntfs_xattr_handlers[] = {
|
||||
&ntfs_xattr_handler,
|
||||
#ifdef CONFIG_NTFS3_FS_POSIX_ACL
|
||||
&posix_acl_access_xattr_handler,
|
||||
&posix_acl_default_xattr_handler,
|
||||
#endif
|
||||
&ntfs_other_xattr_handler,
|
||||
NULL,
|
||||
};
|
||||
// clang-format on
|
||||
|
|
Loading…
Add table
Reference in a new issue