Re: [PATCH 1/2] idmapped-mounts: add fs_allow_idmap() helper

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Sun, Jan 16, 2022 at 12:51:32PM +0800, Eryu Guan wrote:
> On Thu, Jan 13, 2022 at 02:24:20PM +0100, Christian Brauner wrote:
> > Move the check whether the underlying filesystem supports idmapped
> > mounts into a separate helper. We will use it in the following patch to
> > make it possible to always run all tests that don't require idmapped
> > mounts.
> > 
> > Cc: Seth Forshee <sforshee@xxxxxxxxxxxxxxxx>
> > Cc: Eryu Guan <guaneryu@xxxxxxxxx>
> > Cc: Christoph Hellwig <hch@xxxxxx>
> > Cc: fstests@xxxxxxxxxxxxxxx
> > Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
> > ---
> >  src/idmapped-mounts/idmapped-mounts.c | 57 ++++++++++++++-------------
> >  1 file changed, 30 insertions(+), 27 deletions(-)
> > 
> > diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c
> > index da690779..a78a901f 100644
> > --- a/src/idmapped-mounts/idmapped-mounts.c
> > +++ b/src/idmapped-mounts/idmapped-mounts.c
> > @@ -13907,6 +13907,35 @@ static bool run_test(struct t_idmapped_mounts suite[], size_t suite_size)
> >  	return true;
> >  }
> >  
> > +static bool fs_allow_idmap(void)
> > +{
> > +	int ret;
> > +	int open_tree_fd = -EBADF;
> > +	struct mount_attr attr = {
> > +		.attr_set	= MOUNT_ATTR_IDMAP,
> > +		.userns_fd	= -EBADF,
> > +	};
> > +
> > +	/* Changing mount properties on a detached mount. */
> > +	attr.userns_fd = get_userns_fd(0, 1000, 1);
> > +	if (attr.userns_fd < 0)
> > +		exit(EXIT_FAILURE);
> 
> IMHO, it'd be better to return false here and let caller decide if we
> should exit or not.

Agreed.



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux