From 1511f113a27d8aafe080aa6493cb3c0cf2b5abe0 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Thu, 8 May 2025 11:38:24 +1000 Subject: [PATCH] Add no-op implmentation of dirfd(). Fixes build on pre-POSIX.1 2008 systems. --- openbsd-compat/bsd-misc.c | 9 +++++++++ openbsd-compat/bsd-misc.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index b26b4ba46..09bbb6049 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c @@ -158,6 +158,15 @@ utimensat(int fd, const char *path, const struct timespec times[2], } #endif +#ifndef HAVE_DIRFD +int +dirfd(DIR *dir) +{ + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_FCHOWNAT /* * A limited implementation of fchownat() that only implements the diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index edb0fcc8c..4ac73c73e 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h @@ -65,6 +65,12 @@ struct timeval { int utimes(const char *, struct timeval *); #endif /* HAVE_UTIMES */ +#ifndef HAVE_DIRFD +#include +#include +int dirfd(DIR *); +#endif + #ifndef AT_FDCWD # define AT_FDCWD (-2) #endif -- 2.47.3