The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Dorjoy Chowdhury <dorjoychy111@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	 viro@zeniv.linux.org.uk, jack@suse.cz, jlayton@kernel.org,
	chuck.lever@oracle.com,  alex.aring@gmail.com, arnd@arndb.de,
	adilger@dilger.ca
Subject: Re: [PATCH v3 1/4] open: new O_REGULAR flag support
Date: Thu, 29 Jan 2026 11:49:26 +0100	[thread overview]
Message-ID: <20260129-siebzehn-adler-efe74ff8f1a9@brauner> (raw)
In-Reply-To: <20260127180109.66691-2-dorjoychy111@gmail.com>

On Tue, Jan 27, 2026 at 11:58:17PM +0600, Dorjoy Chowdhury wrote:
> This flag indicates the path should be opened if it's a regular file.
> This is useful to write secure programs that want to avoid being tricked
> into opening device nodes with special semantics while thinking they
> operate on regular files.
> 
> A corresponding error code ENOTREG has been introduced. For example, if
> open is called on path /dev/null with O_REGULAR in the flag param, it
> will return -ENOTREG.
> 
> 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, -ENOTREG 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>
> ---

Yeah, we shouldn't add support for this outside of openat2(). We also
shouldn't call this OEXT_* or O2_*. Let's just follow the pattern where
we prefix the flag space with the name of the system call
OPENAT2_REGULAR.

There's also no real need to make O_DIRECTORY exclusive with
OPENAT2_REGULAR. Callers could legimitately want to open a directory or
regular file but not anything else. If someone wants to operate on a
whole filesystem tree but only wants to interact with regular files and
directories and ignore devices, sockets, fifos etc it's very handy to
just be able to set both in flags.

Frankly, this shouldn't be a flag at all but we already have O_DIRECTORY
in there so no need to move this into a new field.

Add EFTYPE as the errno code. Some of the bsds including macos already
have that.

  parent reply	other threads:[~2026-01-29 10:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 17:58 [PATCH v3 0/4] O_REGULAR flag support for open Dorjoy Chowdhury
2026-01-27 17:58 ` [PATCH v3 1/4] open: new O_REGULAR flag support Dorjoy Chowdhury
2026-01-27 23:23   ` Aleksa Sarai
2026-01-28  7:12     ` Mateusz Guzik
2026-01-28 16:57       ` Dorjoy Chowdhury
2026-01-28 19:26       ` Aleksa Sarai
2026-01-27 23:52   ` Jeff Layton
2026-01-28 15:36     ` Dorjoy Chowdhury
2026-01-28 15:51       ` Jeff Layton
2026-01-28 16:29         ` Dorjoy Chowdhury
2026-01-29 12:33         ` Christian Brauner
2026-01-29 13:12           ` Jeff Layton
2026-01-29 13:42             ` Jeff Layton
2026-02-18 18:26             ` Dorjoy Chowdhury
2026-02-18 19:01               ` Jeff Layton
2026-02-18 19:19                 ` Dorjoy Chowdhury
2026-02-18 19:32                   ` Jeff Layton
2026-02-18 19:44                     ` Dorjoy Chowdhury
2026-01-29 14:01           ` Jeff Layton
2026-01-29 10:49   ` Christian Brauner [this message]
2026-01-29 16:55     ` Dorjoy Chowdhury
2026-01-29 17:03     ` Aleksa Sarai
2026-01-29 17:41       ` Dorjoy Chowdhury
2026-01-27 17:58 ` [PATCH v3 2/4] kselftest/openat2: test for O_REGULAR flag Dorjoy Chowdhury
2026-01-27 17:58 ` [PATCH v3 3/4] sparc/fcntl.h: convert O_* flag macros from hex to octal Dorjoy Chowdhury
2026-01-27 17:58 ` [PATCH v3 4/4] mips/fcntl.h: " 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=20260129-siebzehn-adler-efe74ff8f1a9@brauner \
    --to=brauner@kernel.org \
    --cc=adilger@dilger.ca \
    --cc=alex.aring@gmail.com \
    --cc=arnd@arndb.de \
    --cc=chuck.lever@oracle.com \
    --cc=dorjoychy111@gmail.com \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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