Re: [PATCH v23 04/22] vfs: Make the inode passed to inode_change_ok non-const

From: Jeff Layton
Date: Tue Jul 05 2016 - 07:12:23 EST


On Thu, 2016-06-30 at 15:46 +0200, Andreas Gruenbacher wrote:
> We will need to call iop->permission and iop->get_acl from
> inode_change_ok() for additional permission checks, and both take a
> non-const inode.
>
> Signed-off-by: Andreas Gruenbacher <agruenba@xxxxxxxxxx>
> Reviewed-by: J. Bruce Fields <bfields@xxxxxxxxxx>
> Reviewed-by: Andreas Dilger <adilger@xxxxxxxxx>
> Reviewed-by: Steve French <steve.french@xxxxxxxxxxxxxxx>
> ---
> Âfs/attr.cÂÂÂÂÂÂÂÂÂÂ| 2 +-
> Âinclude/linux/fs.h | 2 +-
> Â2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/attr.c b/fs/attr.c
> index 25b24d0..7ca7fa0 100644
> --- a/fs/attr.c
> +++ b/fs/attr.c
> @@ -28,7 +28,7 @@
> Â * Should be called as the first thing in ->setattr implementations,
> Â * possibly after taking additional locks.
> Â */
> -int inode_change_ok(const struct inode *inode, struct iattr *attr)
> +int inode_change_ok(struct inode *inode, struct iattr *attr)
> Â{
> Â unsigned int ia_valid = attr->ia_valid;
> Â
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 86bfa10..208f73b 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2993,7 +2993,7 @@ extern int buffer_migrate_page(struct address_space *,
> Â#define buffer_migrate_page NULL
> Â#endif
> Â
> -extern int inode_change_ok(const struct inode *, struct iattr *);
> +extern int inode_change_ok(struct inode *, struct iattr *);
> Âextern int inode_newsize_ok(const struct inode *, loff_t offset);
> Âextern void setattr_copy(struct inode *inode, const struct iattr *attr);
> Â

Yuck. Bummer to lose the "const" there, but it doesn't look like it's
possible to make those ops take a const arg.

Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>