From f650d54c6a3620d3b1c264a944023beea15fe394 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 20 Jan 2020 18:21:09 +0200 Subject: [PATCH] Unbreak the MS-Windows build * src/w32.c (openat): New function. * src/w32.h (openat): Add prototype. --- src/w32.c | 21 +++++++++++++++++++++ src/w32.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/w32.c b/src/w32.c index 62c53fd7711..a3b9a5683ad 100644 --- a/src/w32.c +++ b/src/w32.c @@ -4591,6 +4591,27 @@ sys_open (const char * path, int oflag, int mode) return res; } +int +openat (int fd, const char * path, int oflag, int mode) +{ + /* Rely on a hack: an open directory is modeled as file descriptor 0, + as in fstatat. FIXME: Add proper support for openat. */ + char fullname[MAX_UTF8_PATH]; + + if (fd != AT_FDCWD) + { + if (_snprintf (fullname, sizeof fullname, "%s/%s", dir_pathname, path) + < 0) + { + errno = ENAMETOOLONG; + return -1; + } + path = fullname; + } + + return sys_open (path, oflag, mode); +} + int fchmod (int fd, mode_t mode) { diff --git a/src/w32.h b/src/w32.h index b8655ec788c..f301b3836ca 100644 --- a/src/w32.h +++ b/src/w32.h @@ -221,6 +221,7 @@ extern void register_child (pid_t, int); extern void sys_sleep (int); extern int sys_link (const char *, const char *); +extern int openat (int, const char *, int, int); /* Return total and free memory info. */ extern int w32_memory_info (unsigned long long *, unsigned long long *, -- 2.39.2