[PATCH v5 0/2] vfs: add O_EMPTYPATH to openat(2)/openat2(2)

From: Jori Koolstra

Date: Fri Apr 24 2026 - 07:47:58 EST


Hi Christian,

I've rebased this on vfs-7.2.misc as Aleksa suggested. Also moved the
O_EMPTYPATH bit to 1<<26 to avoid conflict with non asm-generic O_*
flags.

---

To get an operable version of an O_PATH file descriptor, it is possible
to use openat(fd, ".", O_DIRECTORY) for directories, but other files
currently require going through open("/proc/<pid>/fd/<nr>"), which
depends on a functioning procfs.

This patch adds the O_EMPTYPATH flag to openat(2)/openat2(2). If passed,
LOOKUP_EMPTY is set at path resolution time.

Jori Koolstra (2):
vfs: add O_EMPTYPATH to openat(2)/openat2(2)
selftest: add tests for O_EMPTYPATH

fs/fcntl.c | 2 +-
fs/open.c | 6 +-
include/linux/fcntl.h | 2 +-
include/uapi/asm-generic/fcntl.h | 4 ++
tools/include/uapi/linux/openat2.h | 43 +++++++++++++++
.../selftests/filesystems/openat2/Makefile | 4 +-
.../filesystems/openat2/emptypath_test.c | 55 +++++++++++++++++++
.../selftests/filesystems/openat2/helpers.h | 35 +-----------
8 files changed, 111 insertions(+), 40 deletions(-)
create mode 100644 tools/include/uapi/linux/openat2.h
create mode 100644 tools/testing/selftests/filesystems/openat2/emptypath_test.c

--
2.54.0