Skip to content

Commit 1511f11

Browse files
committed
Add no-op implmentation of dirfd().
Fixes build on pre-POSIX.1 2008 systems.
1 parent 0863697 commit 1511f11

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

openbsd-compat/bsd-misc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ utimensat(int fd, const char *path, const struct timespec times[2],
158158
}
159159
#endif
160160

161+
#ifndef HAVE_DIRFD
162+
int
163+
dirfd(DIR *dir)
164+
{
165+
errno = ENOSYS;
166+
return -1;
167+
}
168+
#endif
169+
161170
#ifndef HAVE_FCHOWNAT
162171
/*
163172
* A limited implementation of fchownat() that only implements the

openbsd-compat/bsd-misc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ struct timeval {
6565
int utimes(const char *, struct timeval *);
6666
#endif /* HAVE_UTIMES */
6767

68+
#ifndef HAVE_DIRFD
69+
#include <sys/types.h>
70+
#include <dirent.h>
71+
int dirfd(DIR *);
72+
#endif
73+
6874
#ifndef AT_FDCWD
6975
# define AT_FDCWD (-2)
7076
#endif

0 commit comments

Comments
 (0)