public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dorjoy Chowdhury <dorjoychy111@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk,
	brauner@kernel.org, jack@suse.cz, jlayton@kernel.org,
	chuck.lever@oracle.com, alex.aring@gmail.com, arnd@arndb.de,
	adilger@dilger.ca, mjguzik@gmail.com, smfrench@gmail.com
Subject: [PATCH v4 2/4] kselftest/openat2: test for OPENAT2_REGULAR flag
Date: Sat,  7 Feb 2026 01:03:37 +0600	[thread overview]
Message-ID: <20260206190536.57289-3-dorjoychy111@gmail.com> (raw)
In-Reply-To: <20260206190536.57289-1-dorjoychy111@gmail.com>

Just a happy path test.

Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
---
 .../testing/selftests/openat2/openat2_test.c  | 46 ++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c
index 0e161ef9e9e4..238de9cff291 100644
--- a/tools/testing/selftests/openat2/openat2_test.c
+++ b/tools/testing/selftests/openat2/openat2_test.c
@@ -320,8 +320,51 @@ void test_openat2_flags(void)
 	}
 }
 
+#ifndef OPENAT2_REGULAR
+#define OPENAT2_REGULAR 040000000
+#endif
+
+#ifndef EFTYPE
+#define EFTYPE 134
+#endif
+
+void test_openat2_regular_flag(void)
+{
+	if (!openat2_supported) {
+		ksft_test_result_skip("Skipping %s as openat2 is not supported\n", __func__);
+		return;
+	}
+
+	struct open_how how = {
+		.flags = OPENAT2_REGULAR | O_RDONLY
+	};
+
+	int fd = sys_openat2(AT_FDCWD, "/dev/null", &how);
+
+	if (fd == -ENOENT) {
+		ksft_test_result_skip("Skipping %s as there is no /dev/null\n", __func__);
+		return;
+	}
+
+	if (fd != -EFTYPE) {
+		ksft_test_result_fail("openat2 should return EFTYPE\n");
+		return;
+	}
+
+	how.flags = OPENAT2_REGULAR | O_DIRECTORY | O_RDONLY;
+
+	fd = sys_openat2(AT_FDCWD, "/dev", &how);
+
+	if (fd < 0) {
+		ksft_test_result_fail("openat2 should open directory with both O_DIRECTORY and OPENAT2_REGULAR\n");
+		return;
+	}
+
+	ksft_test_result_pass("%s succeeded\n", __func__);
+}
+
 #define NUM_TESTS (NUM_OPENAT2_STRUCT_VARIATIONS * NUM_OPENAT2_STRUCT_TESTS + \
-		   NUM_OPENAT2_FLAG_TESTS)
+		   NUM_OPENAT2_FLAG_TESTS + 1)
 
 int main(int argc, char **argv)
 {
@@ -330,6 +373,7 @@ int main(int argc, char **argv)
 
 	test_openat2_struct();
 	test_openat2_flags();
+	test_openat2_regular_flag();
 
 	if (ksft_get_fail_cnt() + ksft_get_error_cnt() > 0)
 		ksft_exit_fail();
-- 
2.53.0


  parent reply	other threads:[~2026-02-06 19:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06 19:03 [PATCH v4 0/4] openat2: new OPENAT2_REGULAR flag support Dorjoy Chowdhury
2026-02-06 19:03 ` [PATCH v4 1/4] " Dorjoy Chowdhury
2026-02-06 19:03 ` Dorjoy Chowdhury [this message]
2026-02-06 19:03 ` [PATCH v4 3/4] sparc/fcntl.h: convert O_* flag macros from hex to octal Dorjoy Chowdhury
2026-02-06 19:03 ` [PATCH v4 4/4] mips/fcntl.h: " Dorjoy Chowdhury
2026-02-11 16:05 ` [PATCH v4 0/4] openat2: new OPENAT2_REGULAR flag support Dorjoy Chowdhury
2026-02-18 15:23   ` Dorjoy Chowdhury
  -- strict thread matches above, loose matches on Subject: below --
2026-02-21 14:45 [PATCH v4 0/4] OPENAT2_REGULAR flag support in openat2 Dorjoy Chowdhury
2026-02-21 14:45 ` [PATCH v4 2/4] kselftest/openat2: test for OPENAT2_REGULAR flag Dorjoy Chowdhury

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=20260206190536.57289-3-dorjoychy111@gmail.com \
    --to=dorjoychy111@gmail.com \
    --cc=adilger@dilger.ca \
    --cc=alex.aring@gmail.com \
    --cc=arnd@arndb.de \
    --cc=brauner@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --cc=smfrench@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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