From: Darren Tucker Date: Thu, 8 May 2025 01:38:24 +0000 (+1000) Subject: Add no-op implmentation of dirfd(). X-Git-Tag: V_10_1_P1~305 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1511f113a27d8aafe080aa6493cb3c0cf2b5abe0;p=thirdparty%2Fopenssh-portable.git Add no-op implmentation of dirfd(). Fixes build on pre-POSIX.1 2008 systems. --- 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