fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Eryu Guan <guan@eryu.me>,
	fstests@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Cc: "Darrick J . Wong" <djwong@kernel.org>,
	David Howells <dhowells@redhat.com>,
	Christian Brauner <christian.brauner@ubuntu.com>
Subject: [PATCH v10 3/6] common/rc: add _scratch_{u}mount_idmapped() helpers
Date: Mon, 22 Mar 2021 14:45:19 +0100	[thread overview]
Message-ID: <20210322134522.916512-4-brauner@kernel.org> (raw)
In-Reply-To: <20210322134522.916512-1-brauner@kernel.org>

From: Christian Brauner <christian.brauner@ubuntu.com>

They will be used in follow-up patches for xfs quota tests but might be
useful for other tests in the future.

Cc: Eryu Guan <guan@eryu.me>
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Howells <dhowells@redhat.com>
Cc: fstests@vger.kernel.org
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
 common/rc | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/common/rc b/common/rc
index a8b375a2..351996fc 100644
--- a/common/rc
+++ b/common/rc
@@ -342,6 +342,36 @@ _scratch_mount()
 	_try_scratch_mount $* || _fail "mount failed"
 }
 
+_scratch_mount_idmapped()
+{
+	local type="$1"
+	local id="$2"
+
+	if [ "$type" = "u" ]; then
+		# This means root will be able to create files as uid %id in
+		# the underlying filesystem by going through the idmapped mount.
+		$here/src/idmapped-mounts/mount-idmapped --map-mount u:0:$id:1 \
+							 --map-mount u:$id:0:1 \
+							 --map-mount g:0:0:1 \
+							 "$SCRATCH_MNT" "$SCRATCH_MNT" || _fail "mount-idmapped failed"
+	elif [ "$type" = "g" ]; then
+		# This means root will be able to create files as gid %id in
+		# the underlying filesystem by going through the idmapped mount.
+		$here/src/idmapped-mounts/mount-idmapped --map-mount g:0:$id:1 \
+							 --map-mount g:$id:0:1 \
+							 --map-mount u:0:0:1 \
+							 "$SCRATCH_MNT" "$SCRATCH_MNT" || _fail "mount-idmapped failed"
+	elif [ "$type" = "b" ]; then
+		# This means root will be able to create files as uid and gid
+		# %id in the underlying filesystem by going through the idmapped mount.
+		$here/src/idmapped-mounts/mount-idmapped --map-mount b:0:$id:1 \
+							 --map-mount b:$id:0:1 \
+							 "$SCRATCH_MNT" "$SCRATCH_MNT" || _fail "mount-idmapped failed"
+	else
+		_fail "usage: either \"u\" (uid), \"g\" (gid), or \"b\" (uid and gid) must be specified "
+	fi
+}
+
 _scratch_unmount()
 {
 	case "$FSTYP" in
@@ -357,6 +387,11 @@ _scratch_unmount()
 	esac
 }
 
+_scratch_umount_idmapped()
+{
+	$UMOUNT_PROG $SCRATCH_MNT
+}
+
 _scratch_remount()
 {
     local opts="$1"
-- 
2.27.0


  parent reply	other threads:[~2021-03-22 13:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 13:45 [PATCH v10 0/6] fstests: add idmapped mounts tests Christian Brauner
2021-03-22 13:45 ` [PATCH v10 1/6] generic/631: add test for detached mount propagation Christian Brauner
2021-03-24  7:40   ` Amir Goldstein
2021-03-24  7:50     ` Christian Brauner
2021-03-24  8:04       ` Amir Goldstein
2021-03-24  8:39         ` Christian Brauner
2021-03-24  9:45           ` Amir Goldstein
2021-03-24  9:52             ` Christian Brauner
2021-03-22 13:45 ` Christian Brauner [this message]
2021-03-22 13:45 ` [PATCH v10 4/6] common/quota: move _qsetup() helper to common code Christian Brauner
2021-03-22 13:45 ` [PATCH v10 5/6] xfs/529: quotas and idmapped mounts Christian Brauner
2021-03-22 13:45 ` [PATCH v10 6/6] xfs/530: quotas on " Christian Brauner
2021-03-22 13:50 ` [PATCH v10 0/6] fstests: add idmapped mounts tests Christian Brauner
2021-03-22 14:21   ` Christian Brauner
2021-03-24  8:03     ` Amir Goldstein
2021-03-24  8:41       ` Christian Brauner
2021-03-24 11:24         ` Amir Goldstein
2021-03-24 13:33           ` Amir Goldstein
2021-03-24 13:49             ` Christian Brauner
2021-03-24 13:45           ` Christian Brauner
2021-03-24 14:01             ` Amir Goldstein
2021-03-24 14:03               ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210322134522.916512-4-brauner@kernel.org \
    --to=brauner@kernel.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=dhowells@redhat.com \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=hch@lst.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).