Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d540e43b authored by Brian Foster's avatar Brian Foster Committed by Dave Chinner
Browse files

xfs: initialize default acls for ->tmpfile()



The current tmpfile handler does not initialize default ACLs. Doing so
within xfs_vn_tmpfile() makes it roughly equivalent to xfs_vn_mknod(),
which is already used as a common create handler.

xfs_vn_mknod() does not currently have a mechanism to determine whether
to link the file into the namespace. Therefore, further abstract
xfs_vn_mknod() into a new xfs_generic_create() handler with a tmpfile
parameter. This new handler calls xfs_create_tmpfile() and d_tmpfile()
on the dentry when called via ->tmpfile().

Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent c99d609a
Loading
Loading
Loading
Loading
+29 −26
Original line number Original line Diff line number Diff line
@@ -124,15 +124,15 @@ xfs_cleanup_inode(
	xfs_dentry_to_name(&teardown, dentry, 0);
	xfs_dentry_to_name(&teardown, dentry, 0);


	xfs_remove(XFS_I(dir), &teardown, XFS_I(inode));
	xfs_remove(XFS_I(dir), &teardown, XFS_I(inode));
	iput(inode);
}
}


STATIC int
STATIC int
xfs_vn_mknod(
xfs_generic_create(
	struct inode	*dir,
	struct inode	*dir,
	struct dentry	*dentry,
	struct dentry	*dentry,
	umode_t		mode,
	umode_t		mode,
	dev_t		rdev)
	dev_t		rdev,
	bool		tmpfile)	/* unnamed file */
{
{
	struct inode	*inode;
	struct inode	*inode;
	struct xfs_inode *ip = NULL;
	struct xfs_inode *ip = NULL;
@@ -156,8 +156,12 @@ xfs_vn_mknod(
	if (error)
	if (error)
		return error;
		return error;


	if (!tmpfile) {
		xfs_dentry_to_name(&name, dentry, mode);
		xfs_dentry_to_name(&name, dentry, mode);
		error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip);
		error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip);
	} else {
		error = xfs_create_tmpfile(XFS_I(dir), dentry, mode, &ip);
	}
	if (unlikely(error))
	if (unlikely(error))
		goto out_free_acl;
		goto out_free_acl;


@@ -180,7 +184,11 @@ xfs_vn_mknod(
	}
	}
#endif
#endif


	if (tmpfile)
		d_tmpfile(dentry, inode);
	else
		d_instantiate(dentry, inode);
		d_instantiate(dentry, inode);

 out_free_acl:
 out_free_acl:
	if (default_acl)
	if (default_acl)
		posix_acl_release(default_acl);
		posix_acl_release(default_acl);
@@ -189,10 +197,22 @@ xfs_vn_mknod(
	return -error;
	return -error;


 out_cleanup_inode:
 out_cleanup_inode:
	if (!tmpfile)
		xfs_cleanup_inode(dir, inode, dentry);
		xfs_cleanup_inode(dir, inode, dentry);
	iput(inode);
	goto out_free_acl;
	goto out_free_acl;
}
}


STATIC int
xfs_vn_mknod(
	struct inode	*dir,
	struct dentry	*dentry,
	umode_t		mode,
	dev_t		rdev)
{
	return xfs_generic_create(dir, dentry, mode, rdev, false);
}

STATIC int
STATIC int
xfs_vn_create(
xfs_vn_create(
	struct inode	*dir,
	struct inode	*dir,
@@ -353,6 +373,7 @@ xfs_vn_symlink(


 out_cleanup_inode:
 out_cleanup_inode:
	xfs_cleanup_inode(dir, inode, dentry);
	xfs_cleanup_inode(dir, inode, dentry);
	iput(inode);
 out:
 out:
	return -error;
	return -error;
}
}
@@ -1053,25 +1074,7 @@ xfs_vn_tmpfile(
	struct dentry	*dentry,
	struct dentry	*dentry,
	umode_t		mode)
	umode_t		mode)
{
{
	int			error;
	return xfs_generic_create(dir, dentry, mode, 0, true);
	struct xfs_inode	*ip;
	struct inode		*inode;

	error = xfs_create_tmpfile(XFS_I(dir), dentry, mode, &ip);
	if (unlikely(error))
		return -error;

	inode = VFS_I(ip);

	error = xfs_init_security(inode, dir, &dentry->d_name);
	if (unlikely(error)) {
		iput(inode);
		return -error;
	}

	d_tmpfile(dentry, inode);

	return 0;
}
}


static const struct inode_operations xfs_inode_operations = {
static const struct inode_operations xfs_inode_operations = {