From nobody Mon Jan 26 22:46:14 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF296244694 for ; Mon, 26 Jan 2026 15:42:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769442137; cv=none; b=EmrJasSfpP1q8Qv53J8k9l30aHL3Bd2Dyr8pNYzcoOimw7v2wgrncGk8C0je19HMcfGudrWZqUfXnDo0EDUcDbALX0lHCQd+scwEftWGBzreHNGv+n9SVlMLDzSsJRKauGrav3E6J/WBCyha4kjk+tg5e9tX9YOfrFuLP/VO7Yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769442137; c=relaxed/simple; bh=zJ9Vt9tPerdPPt4mnUd175UEfBBVgrlSnaR5oX/vaqA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U+kyRLErOad9k19jFHBiciMFUkd/AfoATh30S7d68CwSaFHZ4keKvgxVew4KineGL9G4xePMIWnKshFnlzzJmAurr4lrZ85qEcaXmhU4Aqa89ZJyZTVqVCyfixxy3CS17rlTD7RR/T3eIsWXFY5rQMobHN2ohcpxDygfzko4iww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=d4lDfXBs; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d4lDfXBs" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-353576abcfeso1788418a91.0 for ; Mon, 26 Jan 2026 07:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769442135; x=1770046935; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZWa3a+DKzR2Fpyep8VZA+b+oY1lgONUe6UlM5lxiQJI=; b=d4lDfXBs+43Ht2/JO4rsyt+/6Xno0QewFEXDaExzrj7HIICKU/VW3zqXK2gIrWTNHN 9MjqNHlKklL4jk0CA+nHSRURoWZ0xiv9Cb60ss/AYb6A3V8hX08tOiDPkW5xvShTZBkP YYCwmUaaIZ9j0nzYEn/JXUtm/6lqNNxQF8Y5F5nrMxBJ5+VPKUbncKat4dXAZYLeobfa nwjBZYHzpRfFRLRNUaugK0oX0Pq4o/Ug2E7tv5s9Voy9Dnk0PnI/maQ0b5QXXE7XgZZA IzPrTKWpLnC0bv0Vzk037s34nPMM45CqptOHnzzjFIJwXuzgIU6AdxAkst38fv3veyNA eeGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769442135; x=1770046935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZWa3a+DKzR2Fpyep8VZA+b+oY1lgONUe6UlM5lxiQJI=; b=rO/EPmqrFnWfcoWTKlAMIIM8bm6K8xKStEcz3nkyaIGX4TiMn4I1vUR9VQlQYxYJGH a0BwffaP5pIWj1UPDWcR3mjuNTdOPG0/7xprpI9PjEPXWpyr/NA1zJknRUFqi94hoigd 0sSJ7vkmvfd1KWsCMl+MWzCPBCEBk2fgO81ivHl20LPQo0VqeZ1f6yoAu+py/bJ1FHaG DJOfiAC5rCjr2dkxygHw1l6nEaKIw0EDFbjj5ZmuMLafehDvTmNoCPQ5DW9VhLfq3++/ FbrU0/AczUEcAOJ2JBnRVFxDZnDTz5pVGttdxL8kBlnXXjqBu/1G/bE6yY9a6MuhurB4 bcEQ== X-Gm-Message-State: AOJu0YxcRuJsqFW3ylHCqfwr4syylI6kMx2fmgBM4Te6dWxDtw5JM6XS maZA0VjRiSs4r6zowgBG3EeITN8a6WKool+sNLpmHuVv0sChHqRyEXjy X-Gm-Gg: AZuq6aL+PcIcGLCd0mC0rlXBBqZpcgLYMcEkrgjk6fTlQG9Eea1sZnzMHK+vdFzJ/F0 BhXFYV2B/PFUMcGfu5epmBVmHhrgixrUD8/akDH9LcG/6VQ8q6G7qWiru5vYEWXSnB40rr6AVy5 H4RxtrlYIhTT8ZSAZSZik/ICRqO9DcrtzJ+O0kEnmd10cpznzNG1cPWJUi6xbi6MZhp7kHQlZt4 PMNstiUxFcHleFfod9D6l9I8SGEjTlnFsR76185GFbKberygHYaRY0FlWr2e2kV0FUdjSB6jqAW t17G14l/sK29/t6NrR4uNqi9LDmy+ledhF77d9yZuQOUfmffszpZnxat5uxoxmVs07p0qmHJWW+ BQfx8JsemAvAT9R6YGvz6JrtNsGo4SK1acKYakIWtQOl+lLU4jNUx/AaLWiGKxnfIlzg4jGrB9P IQXSd+gBCIlNZOkPX+eXaL0RLk4v1NBGhslqC5itpHxQigOP8OjOekmA== X-Received: by 2002:a17:90b:3a87:b0:343:eb40:8dca with SMTP id 98e67ed59e1d1-353c416b994mr4659325a91.19.1769442134809; Mon, 26 Jan 2026 07:42:14 -0800 (PST) Received: from toolbx ([103.230.182.3]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3536d88b098sm8649100a91.3.2026.01.26.07.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 07:42:14 -0800 (PST) From: Dorjoy Chowdhury 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 Subject: [PATCH v2 1/2] open: new O_REGULAR flag support Date: Mon, 26 Jan 2026 21:39:21 +0600 Message-ID: <20260126154156.55723-2-dorjoychy111@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260126154156.55723-1-dorjoychy111@gmail.com> References: <20260126154156.55723-1-dorjoychy111@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- arch/alpha/include/uapi/asm/errno.h | 2 ++ arch/alpha/include/uapi/asm/fcntl.h | 1 + arch/mips/include/uapi/asm/errno.h | 2 ++ arch/parisc/include/uapi/asm/errno.h | 2 ++ arch/parisc/include/uapi/asm/fcntl.h | 1 + arch/sparc/include/uapi/asm/errno.h | 2 ++ arch/sparc/include/uapi/asm/fcntl.h | 1 + fs/fcntl.c | 2 +- fs/namei.c | 6 ++++++ fs/open.c | 4 +++- include/linux/fcntl.h | 2 +- include/uapi/asm-generic/errno.h | 2 ++ include/uapi/asm-generic/fcntl.h | 4 ++++ tools/arch/alpha/include/uapi/asm/errno.h | 2 ++ tools/arch/mips/include/uapi/asm/errno.h | 2 ++ tools/arch/parisc/include/uapi/asm/errno.h | 2 ++ tools/arch/sparc/include/uapi/asm/errno.h | 2 ++ tools/include/uapi/asm-generic/errno.h | 2 ++ 18 files changed, 38 insertions(+), 3 deletions(-) diff --git a/arch/alpha/include/uapi/asm/errno.h b/arch/alpha/include/uapi/= asm/errno.h index 6791f6508632..8bbcaa9024f9 100644 --- a/arch/alpha/include/uapi/asm/errno.h +++ b/arch/alpha/include/uapi/asm/errno.h @@ -127,4 +127,6 @@ =20 #define EHWPOISON 139 /* Memory page has hardware error */ =20 +#define ENOTREG 140 /* Not a regular file */ + #endif diff --git a/arch/alpha/include/uapi/asm/fcntl.h b/arch/alpha/include/uapi/= asm/fcntl.h index 50bdc8e8a271..4da5a64c23bd 100644 --- a/arch/alpha/include/uapi/asm/fcntl.h +++ b/arch/alpha/include/uapi/asm/fcntl.h @@ -34,6 +34,7 @@ =20 #define O_PATH 040000000 #define __O_TMPFILE 0100000000 +#define O_REGULAR 0200000000 =20 #define F_GETLK 7 #define F_SETLK 8 diff --git a/arch/mips/include/uapi/asm/errno.h b/arch/mips/include/uapi/as= m/errno.h index c01ed91b1ef4..293c78777254 100644 --- a/arch/mips/include/uapi/asm/errno.h +++ b/arch/mips/include/uapi/asm/errno.h @@ -126,6 +126,8 @@ =20 #define EHWPOISON 168 /* Memory page has hardware error */ =20 +#define ENOTREG 169 /* Not a regular file */ + #define EDQUOT 1133 /* Quota exceeded */ =20 =20 diff --git a/arch/parisc/include/uapi/asm/errno.h b/arch/parisc/include/uap= i/asm/errno.h index 8cbc07c1903e..442917484f99 100644 --- a/arch/parisc/include/uapi/asm/errno.h +++ b/arch/parisc/include/uapi/asm/errno.h @@ -124,4 +124,6 @@ =20 #define EHWPOISON 257 /* Memory page has hardware error */ =20 +#define ENOTREG 258 /* Not a regular file */ + #endif diff --git a/arch/parisc/include/uapi/asm/fcntl.h b/arch/parisc/include/uap= i/asm/fcntl.h index 03dee816cb13..efd763335ff7 100644 --- a/arch/parisc/include/uapi/asm/fcntl.h +++ b/arch/parisc/include/uapi/asm/fcntl.h @@ -19,6 +19,7 @@ =20 #define O_PATH 020000000 #define __O_TMPFILE 040000000 +#define O_REGULAR 060000000 =20 #define F_GETLK64 8 #define F_SETLK64 9 diff --git a/arch/sparc/include/uapi/asm/errno.h b/arch/sparc/include/uapi/= asm/errno.h index 4a41e7835fd5..8dce0bfeab74 100644 --- a/arch/sparc/include/uapi/asm/errno.h +++ b/arch/sparc/include/uapi/asm/errno.h @@ -117,4 +117,6 @@ =20 #define EHWPOISON 135 /* Memory page has hardware error */ =20 +#define ENOTREG 136 /* Not a regular file */ + #endif diff --git a/arch/sparc/include/uapi/asm/fcntl.h b/arch/sparc/include/uapi/= asm/fcntl.h index 67dae75e5274..a93d18d2c23e 100644 --- a/arch/sparc/include/uapi/asm/fcntl.h +++ b/arch/sparc/include/uapi/asm/fcntl.h @@ -37,6 +37,7 @@ =20 #define O_PATH 0x1000000 #define __O_TMPFILE 0x2000000 +#define O_REGULAR 0x4000000 =20 #define F_GETOWN 5 /* for sockets. */ #define F_SETOWN 6 /* for sockets. */ 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 */ !=3D + BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ !=3D HWEIGHT32( (VALID_OPEN_FLAGS & ~(O_NONBLOCK | O_NDELAY)) | __FMODE_EXEC)); diff --git a/fs/namei.c b/fs/namei.c index b28ecb699f32..f5504ae4b03c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4616,6 +4616,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 -ENOTREG; + if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry)) return -ENOTDIR; =20 @@ -4765,6 +4769,8 @@ static int do_o_path(struct nameidata *nd, unsigned f= lags, struct file *file) struct path path; int error =3D path_lookupat(nd, flags, &path); if (!error) { + if ((file->f_flags & O_REGULAR) && !d_is_reg(path.dentry)) + return -ENOTREG; audit_inode(nd->name, path.dentry, 0); error =3D vfs_open(&path, file); path_put(&path); diff --git a/fs/open.c b/fs/open.c index 74c4c1462b3e..82153e21907e 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1173,7 +1173,7 @@ struct file *kernel_file_open(const struct path *path= , int flags, EXPORT_SYMBOL_GPL(kernel_file_open); =20 #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_R= EGULAR) =20 inline struct open_how build_open_how(int flags, umode_t mode) { @@ -1250,6 +1250,8 @@ inline int build_open_flags(const struct open_how *ho= w, 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) =20 /* List of all valid flags for the how->resolve argument: */ #define VALID_RESOLVE_FLAGS \ diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/er= rno.h index 92e7ae493ee3..2216ab9aa32e 100644 --- a/include/uapi/asm-generic/errno.h +++ b/include/uapi/asm-generic/errno.h @@ -122,4 +122,6 @@ =20 #define EHWPOISON 133 /* Memory page has hardware error */ =20 +#define ENOTREG 134 /* Not a regular file */ + #endif diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fc= ntl.h index 613475285643..3468b352a575 100644 --- a/include/uapi/asm-generic/fcntl.h +++ b/include/uapi/asm-generic/fcntl.h @@ -88,6 +88,10 @@ #define __O_TMPFILE 020000000 #endif =20 +#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) =20 diff --git a/tools/arch/alpha/include/uapi/asm/errno.h b/tools/arch/alpha/i= nclude/uapi/asm/errno.h index 6791f6508632..8bbcaa9024f9 100644 --- a/tools/arch/alpha/include/uapi/asm/errno.h +++ b/tools/arch/alpha/include/uapi/asm/errno.h @@ -127,4 +127,6 @@ =20 #define EHWPOISON 139 /* Memory page has hardware error */ =20 +#define ENOTREG 140 /* Not a regular file */ + #endif diff --git a/tools/arch/mips/include/uapi/asm/errno.h b/tools/arch/mips/inc= lude/uapi/asm/errno.h index c01ed91b1ef4..293c78777254 100644 --- a/tools/arch/mips/include/uapi/asm/errno.h +++ b/tools/arch/mips/include/uapi/asm/errno.h @@ -126,6 +126,8 @@ =20 #define EHWPOISON 168 /* Memory page has hardware error */ =20 +#define ENOTREG 169 /* Not a regular file */ + #define EDQUOT 1133 /* Quota exceeded */ =20 =20 diff --git a/tools/arch/parisc/include/uapi/asm/errno.h b/tools/arch/parisc= /include/uapi/asm/errno.h index 8cbc07c1903e..442917484f99 100644 --- a/tools/arch/parisc/include/uapi/asm/errno.h +++ b/tools/arch/parisc/include/uapi/asm/errno.h @@ -124,4 +124,6 @@ =20 #define EHWPOISON 257 /* Memory page has hardware error */ =20 +#define ENOTREG 258 /* Not a regular file */ + #endif diff --git a/tools/arch/sparc/include/uapi/asm/errno.h b/tools/arch/sparc/i= nclude/uapi/asm/errno.h index 4a41e7835fd5..8dce0bfeab74 100644 --- a/tools/arch/sparc/include/uapi/asm/errno.h +++ b/tools/arch/sparc/include/uapi/asm/errno.h @@ -117,4 +117,6 @@ =20 #define EHWPOISON 135 /* Memory page has hardware error */ =20 +#define ENOTREG 136 /* Not a regular file */ + #endif diff --git a/tools/include/uapi/asm-generic/errno.h b/tools/include/uapi/as= m-generic/errno.h index 92e7ae493ee3..2216ab9aa32e 100644 --- a/tools/include/uapi/asm-generic/errno.h +++ b/tools/include/uapi/asm-generic/errno.h @@ -122,4 +122,6 @@ =20 #define EHWPOISON 133 /* Memory page has hardware error */ =20 +#define ENOTREG 134 /* Not a regular file */ + #endif --=20 2.52.0 From nobody Mon Jan 26 22:46:14 2026 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1546933F364 for ; Mon, 26 Jan 2026 15:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769442141; cv=none; b=pmZovcH6HFrJCSCxeUGwXTwWri7C3SfIC29opC3h/nbJag4KLptzs9DhAIPqBZ8SBBER1BSsQOBO0PPih1i1MHisVBQGKr55y960t5ku2W5ql/jtkjln0+TB0tDN4iR3/CrxSQefbyvuVOY5EjgBQDA1rJt7VjQLQxQsi7PMyDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769442141; c=relaxed/simple; bh=tqewIhbRqq1adswiVbpduoDW8JX3z3VKvL2i1Kqr57I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ED5xnk2DcKMpfXWI+Kfa/WwBbfwZZ45O84QRrW9zTnbU1wRtr/FqgcDjLioEtl6b7PFBz/UOQ05wJcXSzX5Fez4G0Xkglt9WL+sw3U7iF+MVC4+6SR4+WXh5Dh/YrYINBkctCD125HnHMv2vu+XyJ3SYB/paZ2mPsq40XHS3Ggw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bePWme8q; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bePWme8q" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-bd1ce1b35e7so3011057a12.0 for ; Mon, 26 Jan 2026 07:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769442139; x=1770046939; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EFHTE7+4vut1ZBbXi2BaQWFLCQQCwb8j1cvQskcZkjo=; b=bePWme8qPU39g65mrF5KWvwERR0PvniLQwnyJWyokZP3mWNwFl32zxMcwVwZKlrBUu Ft1QUwKr2Jk1goOBfpENojDRUjlvKaMq2YBPZEdvK2ztrytV8l/XLlxI9Yca/dr/o7XV 2bt1f9xijzV/HJvBp3AuivgNJd1AA3s2t7XY9KqpWaEwWfvMwYmTEtgD9/v7YuKAUNDT u1GarTfANyacMt1rLF2GO3wWYFdtgwbhqCKfzo1g0AOrilxhnuLP/aNr8NUWGOOzrRwJ +hwJeB0P2OmtAmvBsUUKq7zd6HrlVt1zwONAWf0RADCAZHD8kDGwRYITTrGBc2Ivd2yv 3xZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769442139; x=1770046939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=EFHTE7+4vut1ZBbXi2BaQWFLCQQCwb8j1cvQskcZkjo=; b=u03TV+mqxA9wVR3MiB/q+VkPI8OTulg7kmw99CZPPaFcKycsbrAINye0J5w4fp/d45 ID6H7FPpMMkBTwP1KhLuf3ntOUQst03Vx03G4EwumCmd/c7ephPjHob3HyZBw9Lsfn/O NVp8HovTZzVUcyXeRWRUbO6cHO51teYkAeA9WF1u5xUBb1qq8u+h4pxbXsKI55XBWwJD 1V1juuVO2wMct5YFtPPv25wWNh7e/fRF74ki+U+6moElTwrE4I6x+hG5JjbSTcT+cJtV CAUdbUPQatSsx9l5T0ZvIG41fWg4ii+btIJzxRwubWPaScF+HCcgnva5U5/8DaDSvCRb YeSw== X-Gm-Message-State: AOJu0Yxmk8VqINQdebyAtGjHGIEy+rnBVujFsjt0kdNAq0HeJN/QRJCG Z1lNevAfbiOhF32UyQV3OU8UtoItTt5yZj1grhPuv+qAnbxe/3JkrQfk X-Gm-Gg: AZuq6aI68HJIRcXQvH8A+EkulxkKRHhvZC/qskNrj7YAA/dju5Cga+hwTWA1PcBb358 Njs8TN3TPZeOR0fjqgSaFJ8TqS0ll2rJx3IYMF9PSyqpEM1t6Vvd+ffq1TFyVEo2Pqv7Dp2rOo1 gROmEpuS75m++frkv4u4+4ACdlxQL3EtzHxpfPicmQGhp+5tSg/elzPpfKjc5Ob9+5LL26j0ALx IkJN9FyUO5vC6nGMt5y/8+VkIgCEpR87MJwoONGRtdfaRekj/PUfL6utrYdsLIObIGRp7cd3i83 DAKAzxA7w4cDuI4Ea5CZwH5Jq+OzuNKX27aDrK9nZrH1F1MacbNwagbRsZFTRorZYFr95CGzn// h9llLz+Vab0BI8oZHOvBWr2RxkXdVIoeqsORrteNl6ED7yA72HrIQmdrnXz1jfD/rOvKjinm8kN jPT7YaoXq13o5nu5OxG+a20MY6MGcxCGS3agKn/Lnekay45QnGQ9gC/Q== X-Received: by 2002:a17:90b:3a4d:b0:32e:38b0:15f4 with SMTP id 98e67ed59e1d1-353c40b88f3mr4065706a91.7.1769442139114; Mon, 26 Jan 2026 07:42:19 -0800 (PST) Received: from toolbx ([103.230.182.3]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3536d88b098sm8649100a91.3.2026.01.26.07.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 07:42:18 -0800 (PST) From: Dorjoy Chowdhury 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 Subject: [PATCH v2 2/2] kselftest/openat2: test for O_REGULAR flag Date: Mon, 26 Jan 2026 21:39:22 +0600 Message-ID: <20260126154156.55723-3-dorjoychy111@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260126154156.55723-1-dorjoychy111@gmail.com> References: <20260126154156.55723-1-dorjoychy111@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Just a happy path test. Signed-off-by: Dorjoy Chowdhury --- .../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..011ebc9af4e5 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) } } =20 +#ifndef O_REGULAR +#define O_REGULAR 040000000 +#endif + +#ifndef ENOTREG +#define ENOTREG 134 +#endif + +void test_openat2_o_regular_flag(void) +{ + if (!openat2_supported) { + ksft_test_result_skip("Skipping %s as openat2 is not supported\n", __fun= c__); + return; + } + + struct open_how how =3D { + .flags =3D O_REGULAR | O_RDONLY + }; + + int fd =3D sys_openat2(AT_FDCWD, "/dev/null", &how); + + if (fd =3D=3D ENOENT) { + ksft_test_result_skip("Skipping %s as there is no /dev/null\n", __func__= ); + return; + } + + if (fd !=3D -ENOTREG) { + ksft_test_result_fail("openat2 should return ENOTREG\n"); + return; + } + + ksft_test_result_pass("%s succeeded\n", __func__); +} + #define NUM_TESTS (NUM_OPENAT2_STRUCT_VARIATIONS * NUM_OPENAT2_STRUCT_TEST= S + \ - NUM_OPENAT2_FLAG_TESTS) + NUM_OPENAT2_FLAG_TESTS + 1) =20 int main(int argc, char **argv) { @@ -330,6 +364,7 @@ int main(int argc, char **argv) =20 test_openat2_struct(); test_openat2_flags(); + test_openat2_o_regular_flag(); =20 if (ksft_get_fail_cnt() + ksft_get_error_cnt() > 0) ksft_exit_fail(); --=20 2.52.0