diff options
author | Christoph Hellwig <hch@lst.de> | 2020-02-27 02:30:42 +0100 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2020-03-03 05:55:55 +0100 |
commit | d5f0f49a9bdd4206e941282dfd323c436331659b (patch) | |
tree | 8fbd423d8b336a8c2bdc417a6d67b496432a5ff9 /fs/xfs/xfs_ioctl.c | |
parent | xfs: clean up the ATTR_REPLACE checks (diff) | |
download | linux-d5f0f49a9bdd4206e941282dfd323c436331659b.tar.xz linux-d5f0f49a9bdd4206e941282dfd323c436331659b.zip |
xfs: clean up the attr flag confusion
The ATTR_* flags have a long IRIX history, where they a userspace
interface, the on-disk format and an internal interface. We've split
out the on-disk interface to the XFS_ATTR_* values, but despite (or
because?) of that the flag have still been a mess. Switch the
internal interface to pass the on-disk XFS_ATTR_* flags for the
namespace and the Linux XATTR_* flags for the actual flags instead.
The ATTR_* values that are actually used are move to xfs_fs.h with a
new XFS_IOC_* prefix to not conflict with the userspace version that
has the same name and must have the same value.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_ioctl.c')
-rw-r--r-- | fs/xfs/xfs_ioctl.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index a3cd178ff0ad..9ddaa3cf9bf4 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -320,11 +320,7 @@ xfs_ioc_attr_put_listent( /* * Only list entries in the right namespace. */ - if (((context->flags & ATTR_SECURE) == 0) != - ((flags & XFS_ATTR_SECURE) == 0)) - return; - if (((context->flags & ATTR_ROOT) == 0) != - ((flags & XFS_ATTR_ROOT) == 0)) + if (context->attr_filter != (flags & XFS_ATTR_NSP_ONDISK_MASK)) return; arraytop = sizeof(*alist) + @@ -349,6 +345,28 @@ xfs_ioc_attr_put_listent( trace_xfs_attr_list_add(context); } +static unsigned int +xfs_attr_filter( + u32 ioc_flags) +{ + if (ioc_flags & XFS_IOC_ATTR_ROOT) + return XFS_ATTR_ROOT; + if (ioc_flags & XFS_IOC_ATTR_SECURE) + return XFS_ATTR_SECURE; + return 0; +} + +static unsigned int +xfs_attr_flags( + u32 ioc_flags) +{ + if (ioc_flags & XFS_IOC_ATTR_CREATE) + return XATTR_CREATE; + if (ioc_flags & XFS_IOC_ATTR_REPLACE) + return XATTR_REPLACE; + return 0; +} + int xfs_ioc_attr_list( struct xfs_inode *dp, @@ -370,9 +388,9 @@ xfs_ioc_attr_list( /* * Reject flags, only allow namespaces. */ - if (flags & ~(ATTR_ROOT | ATTR_SECURE)) + if (flags & ~(XFS_IOC_ATTR_ROOT | XFS_IOC_ATTR_SECURE)) return -EINVAL; - if (flags == (ATTR_ROOT | ATTR_SECURE)) + if (flags == (XFS_IOC_ATTR_ROOT | XFS_IOC_ATTR_SECURE)) return -EINVAL; /* @@ -397,7 +415,7 @@ xfs_ioc_attr_list( context.dp = dp; context.cursor = &cursor; context.resynch = 1; - context.flags = flags; + context.attr_filter = xfs_attr_filter(flags); context.buffer = buffer; context.bufsize = (bufsize & ~(sizeof(int)-1)); /* align */ context.firstu = context.bufsize; @@ -454,7 +472,8 @@ xfs_attrmulti_attr_get( { struct xfs_da_args args = { .dp = XFS_I(inode), - .flags = flags, + .attr_filter = xfs_attr_filter(flags), + .attr_flags = xfs_attr_flags(flags), .name = name, .namelen = strlen(name), .valuelen = *len, @@ -491,7 +510,8 @@ xfs_attrmulti_attr_set( { struct xfs_da_args args = { .dp = XFS_I(inode), - .flags = flags, + .attr_filter = xfs_attr_filter(flags), + .attr_flags = xfs_attr_flags(flags), .name = name, .namelen = strlen(name), }; @@ -510,7 +530,7 @@ xfs_attrmulti_attr_set( } error = xfs_attr_set(&args); - if (!error && (flags & ATTR_ROOT)) + if (!error && (flags & XFS_IOC_ATTR_ROOT)) xfs_forget_acl(inode, name); kfree(args.value); return error; @@ -529,7 +549,7 @@ xfs_ioc_attrmulti_one( unsigned char *name; int error; - if ((flags & ATTR_ROOT) && (flags & ATTR_SECURE)) + if ((flags & XFS_IOC_ATTR_ROOT) && (flags & XFS_IOC_ATTR_SECURE)) return -EINVAL; name = strndup_user(uname, MAXNAMELEN); |