On Mon, Feb 17, 2020 at 01:59:32PM +0100, Christoph Hellwig wrote: > Add a new helper to handle a single attr multi ioctl operation that > can be shared between the native and compat ioctl implementation. > > There is a slight change in heavior in that we don't break out of the > loop when copying in the attribute name fails. The previous behavior > was rather inconsistent here as it continued for any other kind of > error. Nice cleanup! > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > Reviewed-by: Chandan Rajendra <chandanrlinux@xxxxxxxxx> > --- > fs/xfs/xfs_ioctl.c | 97 +++++++++++++++++++++++--------------------- > fs/xfs/xfs_ioctl.h | 18 ++------ > fs/xfs/xfs_ioctl32.c | 50 +++-------------------- > 3 files changed, 59 insertions(+), 106 deletions(-) > > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c > index bb490a954c0b..cfdd80b4ea2d 100644 > --- a/fs/xfs/xfs_ioctl.c > +++ b/fs/xfs/xfs_ioctl.c > @@ -349,7 +349,7 @@ xfs_attrlist_by_handle( > return error; > } > > -int > +static int > xfs_attrmulti_attr_get( > struct inode *inode, > unsigned char *name, > @@ -381,7 +381,7 @@ xfs_attrmulti_attr_get( > return error; > } > > -int > +static int > xfs_attrmulti_attr_set( > struct inode *inode, > unsigned char *name, > @@ -412,6 +412,51 @@ xfs_attrmulti_attr_set( > return error; > } > > +int > +xfs_ioc_attrmulti_one( > + struct file *parfilp, Weird name for the file pointer. It's just a file pointer in this context, similar to... > + struct inode *inode, ... it just being an inode pointer in this context. > + uint32_t opcode, > + void __user *uname, > + void __user *value, > + uint32_t *len, > + uint32_t flags) > +{ > + unsigned char *name; > + int error; > + > + if ((flags & ATTR_ROOT) && (flags & ATTR_SECURE)) > + return -EINVAL; > + flags &= ~ATTR_KERNEL_FLAGS; Ok, so this is a user ABI visible change - the old code would return to userspace with these flags cleared from ops[i].am_flags. Now that doesn't happen. I don't see this as a problem, but it needs to be documented in the commit message. > + > + name = strndup_user(uname, MAXNAMELEN); > + if (IS_ERR(name)) > + return PTR_ERR(name); > + > + switch (opcode) { > + case ATTR_OP_GET: > + error = xfs_attrmulti_attr_get(inode, name, value, len, flags); > + break; > + case ATTR_OP_REMOVE: > + value = NULL; > + *len = 0; > + /*FALLTHRU*/ All the recent code we've added uses: /* fall through */ for this annotation - it's the most widely used variant in the XFS codebase, so it would be good to be consistent here... Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx