From: Miklos Szeredi <miklos@szeredi.hu>
To: Chen Linxuan <chenlinxuan@uniontech.com>
Cc: Shuah Khan <shuah@kernel.org>,
zhanjun@uniontech.com, niecheng1@uniontech.com,
Shuah Khan <skhan@linuxfoundation.org>,
Amir Goldstein <amir73il@gmail.com>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 RESEND] selftests: filesystems: Add functional test for the abort file in fusectl
Date: Thu, 12 Jun 2025 10:56:26 +0200 [thread overview]
Message-ID: <CAJfpegt8Hk6nt5+iPg-if9iquWqr3eecgDSKYZvJY0OX+y5b9A@mail.gmail.com> (raw)
In-Reply-To: <20250610021007.2800329-2-chenlinxuan@uniontech.com>
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
On Tue, 10 Jun 2025 at 04:10, Chen Linxuan <chenlinxuan@uniontech.com> wrote:
>
> This patch add a simple functional test for the "abort" file
> in fusectlfs (/sys/fs/fuse/connections/ID/about).
>
> A simple fuse daemon is added for testing.
>
> Related discussion can be found in the link below.
>
> Link: https://lore.kernel.org/all/CAOQ4uxjKFXOKQxPpxtS6G_nR0tpw95w0GiO68UcWg_OBhmSY=Q@mail.gmail.com/
> Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
> Acked-by: Shuah Khan <skhan@linuxfoundation.org>
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Thanks.
I suggest setting up a userns environment, see attached patch (also
fixes a EBUSY on umount/rmdir).
Thanks,
Miklos
[-- Attachment #2: fuse-abort-test-userns.patch --]
[-- Type: text/x-patch, Size: 1696 bytes --]
diff --git a/tools/testing/selftests/filesystems/fuse/fusectl_test.c b/tools/testing/selftests/filesystems/fuse/fusectl_test.c
index 7050fbe0970e..8d124d1cacb2 100644
--- a/tools/testing/selftests/filesystems/fuse/fusectl_test.c
+++ b/tools/testing/selftests/filesystems/fuse/fusectl_test.c
@@ -14,6 +14,7 @@
#include <sys/wait.h>
#include <unistd.h>
#include <dirent.h>
+#include <sched.h>
#include <linux/limits.h>
#include "../../kselftest_harness.h"
@@ -23,6 +24,17 @@
#define FUSE_DEVICE "/dev/fuse"
#define FUSECTL_TEST_VALUE "1"
+static void write_file(struct __test_metadata *const _metadata,
+ const char *path, const char *val)
+{
+ int fd = open(path, O_WRONLY);
+ size_t len = strlen(val);
+
+ ASSERT_GE(fd, 0);
+ ASSERT_EQ(write(fd, val, len), len);
+ ASSERT_EQ(close(fd), 0);
+}
+
FIXTURE(fusectl){
char fuse_mountpoint[sizeof(FUSE_MOUNTPOINT)];
int connection;
@@ -33,6 +45,18 @@ FIXTURE_SETUP(fusectl)
const char *fuse_mnt_prog = "./fuse_mnt";
int status, pid;
struct stat statbuf;
+ uid_t uid = getuid();
+ gid_t gid = getgid();
+ char buf[32];
+
+ /* Setup userns */
+ ASSERT_EQ(unshare(CLONE_NEWNS|CLONE_NEWUSER), 0);
+ sprintf(buf, "0 %d 1", uid);
+ write_file(_metadata, "/proc/self/uid_map", buf);
+ write_file(_metadata, "/proc/self/setgroups", "deny");
+ sprintf(buf, "0 %d 1", gid);
+ write_file(_metadata, "/proc/self/gid_map", buf);
+ ASSERT_EQ(mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL), 0);
strcpy(self->fuse_mountpoint, FUSE_MOUNTPOINT);
@@ -73,7 +97,7 @@ FIXTURE_SETUP(fusectl)
FIXTURE_TEARDOWN(fusectl)
{
- umount(self->fuse_mountpoint);
+ umount2(self->fuse_mountpoint, MNT_DETACH);
rmdir(self->fuse_mountpoint);
}
next prev parent reply other threads:[~2025-06-12 8:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 2:10 [PATCH v3 RESEND] selftests: filesystems: Add functional test for the abort file in fusectl Chen Linxuan
2025-06-12 8:56 ` Miklos Szeredi [this message]
2025-06-14 2:29 ` Chen Linxuan
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=CAJfpegt8Hk6nt5+iPg-if9iquWqr3eecgDSKYZvJY0OX+y5b9A@mail.gmail.com \
--to=miklos@szeredi.hu \
--cc=amir73il@gmail.com \
--cc=chenlinxuan@uniontech.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=niecheng1@uniontech.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=zhanjun@uniontech.com \
/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).