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) {