* [PATCH 0/2] O_REGULAR flag support for open
@ 2026-01-25 14:14 Dorjoy Chowdhury
2026-01-25 14:14 ` [PATCH 1/2] open: new O_REGULAR flag support Dorjoy Chowdhury
2026-01-25 14:14 ` [PATCH 2/2] kselftest/openat2: test for O_REGULAR flag Dorjoy Chowdhury
0 siblings, 2 replies; 9+ messages in thread
From: Dorjoy Chowdhury @ 2026-01-25 14:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: linux-kernel, viro, brauner, jack, jlayton, chuck.lever,
alex.aring, arnd
Hi,
I came upon this "Ability to only open regular files" uapi feature suggestion
from https://uapi-group.org/kernel-features/#ability-to-only-open-regular-files
and thought it would be something I could do as a first patch and get to
know the kernel code a bit better.
I am not quite sure if the semantics that I baked into the code for this
O_REGULAR flag's behavior when combined with other flags like O_CREAT look
good and if there are other places that need the checks. I can fixup my
patch according to suggestions for improvement. I did some happy path testing
and the O_REGULAR flag seems to work as intended.
Thanks.
Regards,
Dorjoy
Dorjoy Chowdhury (2):
open: new O_REGULAR flag support
kselftest/openat2: test for O_REGULAR flag
fs/fcntl.c | 2 +-
fs/namei.c | 6 +++
fs/open.c | 4 +-
include/linux/fcntl.h | 2 +-
include/uapi/asm-generic/errno-base.h | 1 +
include/uapi/asm-generic/fcntl.h | 4 ++
.../testing/selftests/openat2/openat2_test.c | 37 ++++++++++++++++++-
7 files changed, 52 insertions(+), 4 deletions(-)
--
2.52.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] open: new O_REGULAR flag support
2026-01-25 14:14 [PATCH 0/2] O_REGULAR flag support for open Dorjoy Chowdhury
@ 2026-01-25 14:14 ` Dorjoy Chowdhury
2026-01-25 14:40 ` Arnd Bergmann
2026-01-25 16:22 ` kernel test robot
2026-01-25 14:14 ` [PATCH 2/2] kselftest/openat2: test for O_REGULAR flag Dorjoy Chowdhury
1 sibling, 2 replies; 9+ messages in thread
From: Dorjoy Chowdhury @ 2026-01-25 14:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: linux-kernel, viro, brauner, jack, jlayton, chuck.lever,
alex.aring, arnd
This flag indicates the path should be opened if it's a regular file.
A relevant error code ENOTREGULAR(35) has been introduced. For example,
if open is called on path /dev/null with O_REGULAR in the flag param,
it will return -ENOTREGULAR.
When used in combination with O_CREAT, either the regular file is
created, or if the path already exists, it is opened if it's a regular
file. Otherwise, -ENOTREGULAR is returned.
-EINVAL is returned when O_REGULAR is combined with O_DIRECTORY (not
part of O_TMPFILE) because it doesn't make sense to open a path that
is both a directory and a regular file.
Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
---
fs/fcntl.c | 2 +-
fs/namei.c | 6 ++++++
fs/open.c | 4 +++-
include/linux/fcntl.h | 2 +-
include/uapi/asm-generic/errno-base.h | 1 +
include/uapi/asm-generic/fcntl.h | 4 ++++
6 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/fs/fcntl.c b/fs/fcntl.c
index f93dbca08435..62ab4ad2b6f5 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -1169,7 +1169,7 @@ static int __init fcntl_init(void)
* Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
* is defined as O_NONBLOCK on some platforms and not on others.
*/
- BUILD_BUG_ON(20 - 1 /* for O_RDONLY being 0 */ !=
+ BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ !=
HWEIGHT32(
(VALID_OPEN_FLAGS & ~(O_NONBLOCK | O_NDELAY)) |
__FMODE_EXEC));
diff --git a/fs/namei.c b/fs/namei.c
index cf16b6822dd3..365f3cc77e1c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4617,6 +4617,10 @@ static int do_open(struct nameidata *nd,
if (unlikely(error))
return error;
}
+
+ if ((open_flag & O_REGULAR) && !d_is_reg(nd->path.dentry))
+ return -ENOTREGULAR;
+
if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry))
return -ENOTDIR;
@@ -4766,6 +4770,8 @@ static int do_o_path(struct nameidata *nd, unsigned flags, struct file *file)
struct path path;
int error = path_lookupat(nd, flags, &path);
if (!error) {
+ if ((file->f_flags & O_REGULAR) && !d_is_reg(path.dentry))
+ return -ENOTREGULAR;
audit_inode(nd->name, path.dentry, 0);
error = vfs_open(&path, file);
path_put(&path);
diff --git a/fs/open.c b/fs/open.c
index f328622061c5..670cd6b4967a 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1212,7 +1212,7 @@ struct file *kernel_file_open(const struct path *path, int flags,
EXPORT_SYMBOL_GPL(kernel_file_open);
#define WILL_CREATE(flags) (flags & (O_CREAT | __O_TMPFILE))
-#define O_PATH_FLAGS (O_DIRECTORY | O_NOFOLLOW | O_PATH | O_CLOEXEC)
+#define O_PATH_FLAGS (O_DIRECTORY | O_NOFOLLOW | O_PATH | O_CLOEXEC | O_REGULAR)
inline struct open_how build_open_how(int flags, umode_t mode)
{
@@ -1289,6 +1289,8 @@ inline int build_open_flags(const struct open_how *how, struct open_flags *op)
return -EINVAL;
if (!(acc_mode & MAY_WRITE))
return -EINVAL;
+ } else if ((flags & O_DIRECTORY) && (flags & O_REGULAR)) {
+ return -EINVAL;
}
if (flags & O_PATH) {
/* O_PATH only permits certain other flags to be set. */
diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h
index a332e79b3207..4fd07b0e0a17 100644
--- a/include/linux/fcntl.h
+++ b/include/linux/fcntl.h
@@ -10,7 +10,7 @@
(O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC | \
O_APPEND | O_NDELAY | O_NONBLOCK | __O_SYNC | O_DSYNC | \
FASYNC | O_DIRECT | O_LARGEFILE | O_DIRECTORY | O_NOFOLLOW | \
- O_NOATIME | O_CLOEXEC | O_PATH | __O_TMPFILE)
+ O_NOATIME | O_CLOEXEC | O_PATH | __O_TMPFILE | O_REGULAR)
/* List of all valid flags for the how->resolve argument: */
#define VALID_RESOLVE_FLAGS \
diff --git a/include/uapi/asm-generic/errno-base.h b/include/uapi/asm-generic/errno-base.h
index 9653140bff92..ea9a96d30737 100644
--- a/include/uapi/asm-generic/errno-base.h
+++ b/include/uapi/asm-generic/errno-base.h
@@ -36,5 +36,6 @@
#define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Math argument out of domain of func */
#define ERANGE 34 /* Math result not representable */
+#define ENOTREGULAR 35 /* Not a regular file */
#endif
diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
index 613475285643..11e5eadab868 100644
--- a/include/uapi/asm-generic/fcntl.h
+++ b/include/uapi/asm-generic/fcntl.h
@@ -88,6 +88,10 @@
#define __O_TMPFILE 020000000
#endif
+#ifndef O_REGULAR
+#define O_REGULAR 040000000
+#endif
+
/* a horrid kludge trying to make sure that this will fail on old kernels */
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
--
2.52.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] kselftest/openat2: test for O_REGULAR flag
2026-01-25 14:14 [PATCH 0/2] O_REGULAR flag support for open Dorjoy Chowdhury
2026-01-25 14:14 ` [PATCH 1/2] open: new O_REGULAR flag support Dorjoy Chowdhury
@ 2026-01-25 14:14 ` Dorjoy Chowdhury
1 sibling, 0 replies; 9+ messages in thread
From: Dorjoy Chowdhury @ 2026-01-25 14:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: linux-kernel, viro, brauner, jack, jlayton, chuck.lever,
alex.aring, arnd
Just a happy path test.
Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
---
.../testing/selftests/openat2/openat2_test.c | 37 ++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c
index 0e161ef9e9e4..c2f8771e2dae 100644
--- a/tools/testing/selftests/openat2/openat2_test.c
+++ b/tools/testing/selftests/openat2/openat2_test.c
@@ -320,8 +320,42 @@ void test_openat2_flags(void)
}
}
+#ifndef O_REGULAR
+#define O_REGULAR 040000000
+#endif
+
+#ifndef ENOTREGULAR
+#define ENOTREGULAR 35
+#endif
+
+void test_openat2_o_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 = O_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 != -ENOTREGULAR) {
+ ksft_test_result_fail("openat2 should return ENOTREGULAR\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 +364,7 @@ int main(int argc, char **argv)
test_openat2_struct();
test_openat2_flags();
+ test_openat2_o_regular_flag();
if (ksft_get_fail_cnt() + ksft_get_error_cnt() > 0)
ksft_exit_fail();
--
2.52.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] open: new O_REGULAR flag support
2026-01-25 14:14 ` [PATCH 1/2] open: new O_REGULAR flag support Dorjoy Chowdhury
@ 2026-01-25 14:40 ` Arnd Bergmann
2026-01-25 15:41 ` Dorjoy Chowdhury
2026-01-25 16:22 ` kernel test robot
1 sibling, 1 reply; 9+ messages in thread
From: Arnd Bergmann @ 2026-01-25 14:40 UTC (permalink / raw)
To: Dorjoy Chowdhury, linux-fsdevel
Cc: linux-kernel, Alexander Viro, Christian Brauner, Jan Kara,
Jeff Layton, Chuck Lever, Alexander Aring
On Sun, Jan 25, 2026, at 15:14, Dorjoy Chowdhury wrote:
> diff --git a/include/uapi/asm-generic/errno-base.h
> b/include/uapi/asm-generic/errno-base.h
> index 9653140bff92..ea9a96d30737 100644
> --- a/include/uapi/asm-generic/errno-base.h
> +++ b/include/uapi/asm-generic/errno-base.h
> @@ -36,5 +36,6 @@
> #define EPIPE 32 /* Broken pipe */
> #define EDOM 33 /* Math argument out of domain of func */
> #define ERANGE 34 /* Math result not representable */
> +#define ENOTREGULAR 35 /* Not a regular file */
This clashes with EDEADLK on most architectures, or with
EAGAIN on alpha and ENOMSG on mips/parisc. You probably
need to pick the next free value in uapi/asm-generic/errno.h
and arch/*/include/uapi/asm/errno.h and keep this sorted
after EHWPOISON if you can't find an existing error code.
> diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
> index 613475285643..11e5eadab868 100644
> --- a/include/uapi/asm-generic/fcntl.h
> +++ b/include/uapi/asm-generic/fcntl.h
> @@ -88,6 +88,10 @@
> #define __O_TMPFILE 020000000
> #endif
>
> +#ifndef O_REGULAR
> +#define O_REGULAR 040000000
> +#endif
This in turn clashes with O_PATH on alpha, __O_TMPFILE on
parisc, and __O_SYNC on sparc. We can probably fill the holes
in asm/fcntl.h to define this.
Arnd
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] open: new O_REGULAR flag support
2026-01-25 14:40 ` Arnd Bergmann
@ 2026-01-25 15:41 ` Dorjoy Chowdhury
2026-01-25 16:28 ` Jeff Layton
2026-01-26 8:00 ` Arnd Bergmann
0 siblings, 2 replies; 9+ messages in thread
From: Dorjoy Chowdhury @ 2026-01-25 15:41 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-fsdevel, linux-kernel, Alexander Viro, Christian Brauner,
Jan Kara, Jeff Layton, Chuck Lever, Alexander Aring
On Sun, Jan 25, 2026 at 8:40 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Sun, Jan 25, 2026, at 15:14, Dorjoy Chowdhury wrote:
>
> > diff --git a/include/uapi/asm-generic/errno-base.h
> > b/include/uapi/asm-generic/errno-base.h
> > index 9653140bff92..ea9a96d30737 100644
> > --- a/include/uapi/asm-generic/errno-base.h
> > +++ b/include/uapi/asm-generic/errno-base.h
> > @@ -36,5 +36,6 @@
> > #define EPIPE 32 /* Broken pipe */
> > #define EDOM 33 /* Math argument out of domain of func */
> > #define ERANGE 34 /* Math result not representable */
> > +#define ENOTREGULAR 35 /* Not a regular file */
>
> This clashes with EDEADLK on most architectures, or with
> EAGAIN on alpha and ENOMSG on mips/parisc. You probably
> need to pick the next free value in uapi/asm-generic/errno.h
> and arch/*/include/uapi/asm/errno.h and keep this sorted
> after EHWPOISON if you can't find an existing error code.
>
Thanks for pointing this out. I will fix up in v2 along with other
comments (if any). I looked at the existing error codes in
uapi/asm-generic/errno.h and didn't notice anything that I could
reuse. So if I understand correctly, I will need this new error code
in both uapi/asm-generic/errno.h (not in errno-base.h) and in
arch/*/include/uapi/asm/errno.h (I see some parallel
tools/arch/*/include/uapi/asm/errno.h files too) just after EHWPOISON,
right?
> > diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
> > index 613475285643..11e5eadab868 100644
> > --- a/include/uapi/asm-generic/fcntl.h
> > +++ b/include/uapi/asm-generic/fcntl.h
> > @@ -88,6 +88,10 @@
> > #define __O_TMPFILE 020000000
> > #endif
> >
> > +#ifndef O_REGULAR
> > +#define O_REGULAR 040000000
> > +#endif
>
> This in turn clashes with O_PATH on alpha, __O_TMPFILE on
> parisc, and __O_SYNC on sparc. We can probably fill the holes
> in asm/fcntl.h to define this.
>
And for this, I will need to just define O_REGULAR in alpha, parisc
and sparc too, right?
Good catch on the sparc file, some are octal, some are hexadecimal,
easy to miss. Thanks!
Regards,
Dorjoy
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] open: new O_REGULAR flag support
2026-01-25 14:14 ` [PATCH 1/2] open: new O_REGULAR flag support Dorjoy Chowdhury
2026-01-25 14:40 ` Arnd Bergmann
@ 2026-01-25 16:22 ` kernel test robot
1 sibling, 0 replies; 9+ messages in thread
From: kernel test robot @ 2026-01-25 16:22 UTC (permalink / raw)
To: Dorjoy Chowdhury, linux-fsdevel
Cc: oe-kbuild-all, linux-kernel, viro, brauner, jack, jlayton,
chuck.lever, alex.aring, arnd
Hi Dorjoy,
kernel test robot noticed the following build errors:
[auto build test ERROR on brauner-vfs/vfs.all]
[also build test ERROR on shuah-kselftest/next shuah-kselftest/fixes linus/master arnd-asm-generic/master v6.19-rc6 next-20260123]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dorjoy-Chowdhury/open-new-O_REGULAR-flag-support/20260125-221826
base: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link: https://lore.kernel.org/r/20260125141518.59493-2-dorjoychy111%40gmail.com
patch subject: [PATCH 1/2] open: new O_REGULAR flag support
config: alpha-allnoconfig (https://download.01.org/0day-ci/archive/20260126/202601260042.TRDQjGeu-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260126/202601260042.TRDQjGeu-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601260042.TRDQjGeu-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from <command-line>:
fs/fcntl.c: In function 'fcntl_init':
>> include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_389' declared with attribute error: BUILD_BUG_ON failed: 21 - 1 != HWEIGHT32( (VALID_OPEN_FLAGS & ~(O_NONBLOCK | O_NDELAY)) | __FMODE_EXEC)
631 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^
include/linux/compiler_types.h:612:25: note: in definition of macro '__compiletime_assert'
612 | prefix ## suffix(); \
| ^~~~~~
include/linux/compiler_types.h:631:9: note: in expansion of macro '_compiletime_assert'
631 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
fs/fcntl.c:1172:9: note: in expansion of macro 'BUILD_BUG_ON'
1172 | BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ !=
| ^~~~~~~~~~~~
vim +/__compiletime_assert_389 +631 include/linux/compiler_types.h
eb5c2d4b45e3d2 Will Deacon 2020-07-21 617
eb5c2d4b45e3d2 Will Deacon 2020-07-21 618 #define _compiletime_assert(condition, msg, prefix, suffix) \
eb5c2d4b45e3d2 Will Deacon 2020-07-21 619 __compiletime_assert(condition, msg, prefix, suffix)
eb5c2d4b45e3d2 Will Deacon 2020-07-21 620
eb5c2d4b45e3d2 Will Deacon 2020-07-21 621 /**
eb5c2d4b45e3d2 Will Deacon 2020-07-21 622 * compiletime_assert - break build and emit msg if condition is false
eb5c2d4b45e3d2 Will Deacon 2020-07-21 623 * @condition: a compile-time constant condition to check
eb5c2d4b45e3d2 Will Deacon 2020-07-21 624 * @msg: a message to emit if condition is false
eb5c2d4b45e3d2 Will Deacon 2020-07-21 625 *
eb5c2d4b45e3d2 Will Deacon 2020-07-21 626 * In tradition of POSIX assert, this macro will break the build if the
eb5c2d4b45e3d2 Will Deacon 2020-07-21 627 * supplied condition is *false*, emitting the supplied error message if the
eb5c2d4b45e3d2 Will Deacon 2020-07-21 628 * compiler has support to do so.
eb5c2d4b45e3d2 Will Deacon 2020-07-21 629 */
eb5c2d4b45e3d2 Will Deacon 2020-07-21 630 #define compiletime_assert(condition, msg) \
eb5c2d4b45e3d2 Will Deacon 2020-07-21 @631 _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
eb5c2d4b45e3d2 Will Deacon 2020-07-21 632
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] open: new O_REGULAR flag support
2026-01-25 15:41 ` Dorjoy Chowdhury
@ 2026-01-25 16:28 ` Jeff Layton
2026-01-25 16:59 ` Dorjoy Chowdhury
2026-01-26 8:00 ` Arnd Bergmann
1 sibling, 1 reply; 9+ messages in thread
From: Jeff Layton @ 2026-01-25 16:28 UTC (permalink / raw)
To: Dorjoy Chowdhury, Arnd Bergmann
Cc: linux-fsdevel, linux-kernel, Alexander Viro, Christian Brauner,
Jan Kara, Chuck Lever, Alexander Aring
On Sun, 2026-01-25 at 21:41 +0600, Dorjoy Chowdhury wrote:
> On Sun, Jan 25, 2026 at 8:40 PM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > On Sun, Jan 25, 2026, at 15:14, Dorjoy Chowdhury wrote:
> >
> > > diff --git a/include/uapi/asm-generic/errno-base.h
> > > b/include/uapi/asm-generic/errno-base.h
> > > index 9653140bff92..ea9a96d30737 100644
> > > --- a/include/uapi/asm-generic/errno-base.h
> > > +++ b/include/uapi/asm-generic/errno-base.h
> > > @@ -36,5 +36,6 @@
> > > #define EPIPE 32 /* Broken pipe */
> > > #define EDOM 33 /* Math argument out of domain of func */
> > > #define ERANGE 34 /* Math result not representable */
> > > +#define ENOTREGULAR 35 /* Not a regular file */
> >
> > This clashes with EDEADLK on most architectures, or with
> > EAGAIN on alpha and ENOMSG on mips/parisc. You probably
> > need to pick the next free value in uapi/asm-generic/errno.h
> > and arch/*/include/uapi/asm/errno.h and keep this sorted
> > after EHWPOISON if you can't find an existing error code.
> >
>
> Thanks for pointing this out. I will fix up in v2 along with other
> comments (if any). I looked at the existing error codes in
> uapi/asm-generic/errno.h and didn't notice anything that I could
> reuse. So if I understand correctly, I will need this new error code
> in both uapi/asm-generic/errno.h (not in errno-base.h) and in
> arch/*/include/uapi/asm/errno.h (I see some parallel
> tools/arch/*/include/uapi/asm/errno.h files too) just after EHWPOISON,
> right?
>
nit: Can we call this this ENOTREG instead of ENOTREGULAR? That seems
like it would read better alongside ENOTDIR and I hate extra typing.
> > > diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
> > > index 613475285643..11e5eadab868 100644
> > > --- a/include/uapi/asm-generic/fcntl.h
> > > +++ b/include/uapi/asm-generic/fcntl.h
> > > @@ -88,6 +88,10 @@
> > > #define __O_TMPFILE 020000000
> > > #endif
> > >
> > > +#ifndef O_REGULAR
> > > +#define O_REGULAR 040000000
> > > +#endif
> >
> > This in turn clashes with O_PATH on alpha, __O_TMPFILE on
> > parisc, and __O_SYNC on sparc. We can probably fill the holes
> > in asm/fcntl.h to define this.
> >
>
> And for this, I will need to just define O_REGULAR in alpha, parisc
> and sparc too, right?
> Good catch on the sparc file, some are octal, some are hexadecimal,
> easy to miss. Thanks!
>
>
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] open: new O_REGULAR flag support
2026-01-25 16:28 ` Jeff Layton
@ 2026-01-25 16:59 ` Dorjoy Chowdhury
0 siblings, 0 replies; 9+ messages in thread
From: Dorjoy Chowdhury @ 2026-01-25 16:59 UTC (permalink / raw)
To: Jeff Layton
Cc: Arnd Bergmann, linux-fsdevel, linux-kernel, Alexander Viro,
Christian Brauner, Jan Kara, Chuck Lever, Alexander Aring
On Sun, Jan 25, 2026 at 10:28 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> On Sun, 2026-01-25 at 21:41 +0600, Dorjoy Chowdhury wrote:
> > On Sun, Jan 25, 2026 at 8:40 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > >
> > > On Sun, Jan 25, 2026, at 15:14, Dorjoy Chowdhury wrote:
> > >
> > > > diff --git a/include/uapi/asm-generic/errno-base.h
> > > > b/include/uapi/asm-generic/errno-base.h
> > > > index 9653140bff92..ea9a96d30737 100644
> > > > --- a/include/uapi/asm-generic/errno-base.h
> > > > +++ b/include/uapi/asm-generic/errno-base.h
> > > > @@ -36,5 +36,6 @@
> > > > #define EPIPE 32 /* Broken pipe */
> > > > #define EDOM 33 /* Math argument out of domain of func */
> > > > #define ERANGE 34 /* Math result not representable */
> > > > +#define ENOTREGULAR 35 /* Not a regular file */
> > >
> > > This clashes with EDEADLK on most architectures, or with
> > > EAGAIN on alpha and ENOMSG on mips/parisc. You probably
> > > need to pick the next free value in uapi/asm-generic/errno.h
> > > and arch/*/include/uapi/asm/errno.h and keep this sorted
> > > after EHWPOISON if you can't find an existing error code.
> > >
> >
> > Thanks for pointing this out. I will fix up in v2 along with other
> > comments (if any). I looked at the existing error codes in
> > uapi/asm-generic/errno.h and didn't notice anything that I could
> > reuse. So if I understand correctly, I will need this new error code
> > in both uapi/asm-generic/errno.h (not in errno-base.h) and in
> > arch/*/include/uapi/asm/errno.h (I see some parallel
> > tools/arch/*/include/uapi/asm/errno.h files too) just after EHWPOISON,
> > right?
> >
>
> nit: Can we call this this ENOTREG instead of ENOTREGULAR? That seems
> like it would read better alongside ENOTDIR and I hate extra typing.
>
Good suggestion. I agree. Will fix up in v2. Thanks!
Regards,
Dorjoy
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] open: new O_REGULAR flag support
2026-01-25 15:41 ` Dorjoy Chowdhury
2026-01-25 16:28 ` Jeff Layton
@ 2026-01-26 8:00 ` Arnd Bergmann
1 sibling, 0 replies; 9+ messages in thread
From: Arnd Bergmann @ 2026-01-26 8:00 UTC (permalink / raw)
To: Dorjoy Chowdhury
Cc: linux-fsdevel, linux-kernel, Alexander Viro, Christian Brauner,
Jan Kara, Jeff Layton, Chuck Lever, Alexander Aring
On Sun, Jan 25, 2026, at 16:41, Dorjoy Chowdhury wrote:
>
> Thanks for pointing this out. I will fix up in v2 along with other
> comments (if any). I looked at the existing error codes in
> uapi/asm-generic/errno.h and didn't notice anything that I could
> reuse. So if I understand correctly, I will need this new error code
> in both uapi/asm-generic/errno.h (not in errno-base.h) and in
> arch/*/include/uapi/asm/errno.h (I see some parallel
> tools/arch/*/include/uapi/asm/errno.h files too) just after EHWPOISON,
> right?
Yes, sounds good to me.
>> > diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
>> > index 613475285643..11e5eadab868 100644
>> > --- a/include/uapi/asm-generic/fcntl.h
>> > +++ b/include/uapi/asm-generic/fcntl.h
>> > @@ -88,6 +88,10 @@
>> > #define __O_TMPFILE 020000000
>> > #endif
>> >
>> > +#ifndef O_REGULAR
>> > +#define O_REGULAR 040000000
>> > +#endif
>>
>> This in turn clashes with O_PATH on alpha, __O_TMPFILE on
>> parisc, and __O_SYNC on sparc. We can probably fill the holes
>> in asm/fcntl.h to define this.
>>
>
> And for this, I will need to just define O_REGULAR in alpha, parisc
> and sparc too, right?
Yes, the only question is whether to use the first available
bit, or the one after the previously last one.
> Good catch on the sparc file, some are octal, some are hexadecimal,
> easy to miss. Thanks!
Right, I wonder if there are any downsides to redefining them
all the same way.
Arnd
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-01-26 8:00 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-25 14:14 [PATCH 0/2] O_REGULAR flag support for open Dorjoy Chowdhury
2026-01-25 14:14 ` [PATCH 1/2] open: new O_REGULAR flag support Dorjoy Chowdhury
2026-01-25 14:40 ` Arnd Bergmann
2026-01-25 15:41 ` Dorjoy Chowdhury
2026-01-25 16:28 ` Jeff Layton
2026-01-25 16:59 ` Dorjoy Chowdhury
2026-01-26 8:00 ` Arnd Bergmann
2026-01-25 16:22 ` kernel test robot
2026-01-25 14:14 ` [PATCH 2/2] kselftest/openat2: test for O_REGULAR flag Dorjoy Chowdhury
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome