<pre style='margin:0'>
Ken (kencu) pushed a commit to branch master
in repository macports-legacy-support.
</pre>
<p><a href="https://github.com/macports/macports-legacy-support/commit/2a91a02433010a471baff5f4b1cfdb52890de561">https://github.com/macports/macports-legacy-support/commit/2a91a02433010a471baff5f4b1cfdb52890de561</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 2a91a02433010a471baff5f4b1cfdb52890de561
</span>Author: Mihai Moldovan <ionic@ionic.de>
AuthorDate: Tue Oct 8 22:57:26 2019 +0200
<span style='display:block; white-space:pre;color:#404040;'> src/fdopendir.c: split out best_fchdir() into own compilation unit.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> We only need this symbol around once, so don't create multiple
</span><span style='display:block; white-space:pre;color:#404040;'> duplicated versions of it using the "static" keyword.
</span>---
src/{fdopendir.c => best_fchdir.c} | 47 +-------------------------------------
src/fdopendir.c | 16 +------------
2 files changed, 2 insertions(+), 61 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/fdopendir.c b/src/best_fchdir.c
</span>similarity index 62%
copy from src/fdopendir.c
copy to src/best_fchdir.c
<span style='display:block; white-space:pre;color:#808080;'>index bea3ef5..5327221 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/fdopendir.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/best_fchdir.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,4 +1,3 @@
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> /*-
* Copyright (c) 2019 Ken Cunningham kencu@macports.org
*
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -20,18 +19,14 @@
</span> #include "MacportsLegacySupport.h"
#if __MP_LEGACY_SUPPORT_FDOPENDIR__
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <dirent.h>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <sys/errno.h>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <sys/stat.h>
</span> #include <unistd.h>
#include <sys/syscall.h>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <fcntl.h>
</span>
#ifndef SYS___pthread_fchdir
# define SYS___pthread_fchdir 349
#endif
<span style='display:block; white-space:pre;background:#ffe0e0;'>-static int best_fchdir(int dirfd)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int best_fchdir(int dirfd)
</span> {
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
return syscall(SYS___pthread_fchdir, dirfd);
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -42,44 +37,4 @@ static int best_fchdir(int dirfd)
</span> #endif
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#define PROTECT_ERRNO(what) ({ int __err = (errno); what; errno = __err; })
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-DIR *fdopendir(int dirfd) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- DIR *dir;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- struct stat st;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- int oldCWD = -1;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (fstat(dirfd, &st) < 0)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!S_ISDIR(st.st_mode)) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- errno = ENOTDIR;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (dirfd == AT_FDCWD)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return opendir (".");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- oldCWD = open(".", O_RDONLY);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (oldCWD == -1)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if(best_fchdir(dirfd) < 0) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (oldCWD != -1) PROTECT_ERRNO(close(oldCWD));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- dir = opendir (".");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (best_fchdir(oldCWD) < 0) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (oldCWD != -1) PROTECT_ERRNO(close(oldCWD));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (oldCWD != -1)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- PROTECT_ERRNO(close(oldCWD));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return dir;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> #endif /* __MP_LEGACY_SUPPORT_FDOPENDIR__ */
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/fdopendir.c b/src/fdopendir.c
</span><span style='display:block; white-space:pre;color:#808080;'>index bea3ef5..ebabae0 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/fdopendir.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/fdopendir.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -24,23 +24,9 @@
</span> #include <sys/errno.h>
#include <sys/stat.h>
#include <unistd.h>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <sys/syscall.h>
</span> #include <fcntl.h>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#ifndef SYS___pthread_fchdir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# define SYS___pthread_fchdir 349
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-static int best_fchdir(int dirfd)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-{
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return syscall(SYS___pthread_fchdir, dirfd);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#else
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Tiger does not have kernel support for __pthread_fchdir, so we have to fall back to fchdir */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* unless we can come up with a per-thread compatible implementation that works on Tiger */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return syscall(SYS_fchdir, dirfd);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int best_fchdir(int dirfd);
</span>
#define PROTECT_ERRNO(what) ({ int __err = (errno); what; errno = __err; })
</pre><pre style='margin:0'>
</pre>