From c0c13d73233c740b7d278c71b161da7b16217564 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Fri, 16 Jan 2026 22:48:25 +0000 Subject: [PATCH] libutil: fix `linux` build on fresh `glibc` and `gcc` Without the change the build fails for me as: ../unix/file-descriptor.cc:404:70: error: 'RESOLVE_BENEATH' was not declared in this scope 404 | dirFd, path.rel_c_str(), flags, static_cast(mode), RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS); | ^~~~~~~~~~~~~~~ This happens for 2 reasons: 1. `__NR_openat2` constant was not pulled in from the according headers and as a result `` was not included. 2. `define HAVE_OPENAT2 0` build is broken: refers to missing `RESOLVE_BENEATH` normally pulled in from `` This changes fixes both. (cherry picked from commit 3256aba6a2c9cc970bffd54fd13bc6a19367ffbf) --- src/libutil/unix/file-descriptor.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libutil/unix/file-descriptor.cc b/src/libutil/unix/file-descriptor.cc index d90342ff0ec..501f07aec65 100644 --- a/src/libutil/unix/file-descriptor.cc +++ b/src/libutil/unix/file-descriptor.cc @@ -8,9 +8,12 @@ #include #include +#if defined(__linux__) +# include /* pull __NR_* definitions */ +#endif + #if defined(__linux__) && defined(__NR_openat2) # define HAVE_OPENAT2 1 -# include # include #else # define HAVE_OPENAT2 0 @@ -323,7 +326,7 @@ Descriptor unix::openFileEnsureBeneathNoSymlinks(Descriptor dirFd, const CanonPa { assert(!path.rel().starts_with('/')); /* Just in case the invariant is somehow broken. */ assert(!path.isRoot()); -#ifdef __linux__ +#if HAVE_OPENAT2 auto maybeFd = linux::openat2( dirFd, path.rel_c_str(), flags, static_cast(mode), RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS); if (maybeFd) {