<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/96dc11256d2345edb915b90690e21032c8520a7b">https://github.com/macports/macports-legacy-support/commit/96dc11256d2345edb915b90690e21032c8520a7b</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 96dc11256d2345edb915b90690e21032c8520a7b
</span>Author: Ken Cunningham <kencu@macports.org>
AuthorDate: Tue Nov 20 23:43:03 2018 -0800
<span style='display:block; white-space:pre;color:#404040;'> add atcalls
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> From Jeremy
</span>---
include/MacportsLegacySupport.h | 2 +
include/stdio.h | 3 +-
include/sys/fcntl.h | 15 +-
include/{stdio.h => sys/stat.h} | 27 +--
include/{ => sys}/stdio.h | 22 +--
include/sys/unistd.h | 53 ++++++
src/atcalls.c | 364 ++++++++++++++++++++++++++++++++++++++++
src/memmem.c | 2 +-
8 files changed, 462 insertions(+), 26 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/MacportsLegacySupport.h b/include/MacportsLegacySupport.h
</span><span style='display:block; white-space:pre;color:#808080;'>index c3e4cae..2ba574d 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/MacportsLegacySupport.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/MacportsLegacySupport.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -43,4 +43,6 @@
</span> /* llround */
#define __MP_LEGACY_SUPPORT_LLROUND__ __APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MP_LEGACY_SUPPORT_ATCALLS__ __APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> #endif /* _MACPORTS_LEGACYSUPPORTDEFS_H_ */
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/stdio.h b/include/stdio.h
</span><span style='display:block; white-space:pre;color:#808080;'>index 63428a1..c317914 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/stdio.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/stdio.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,6 +1,7 @@
</span>
/*
* Copyright (c) 2010 Chris Jones <jonesc@macports.org>
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2018 Ken Cunningham <kencu@macports.org>
</span> *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -36,6 +37,6 @@ extern "C" {
</span> #ifdef __cplusplus
}
#endif
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MP_LEGACY_SUPPORT_GETLINE__ */
</span>
#endif /* _MACPORTS_STDIO_H_ */
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/sys/fcntl.h b/include/sys/fcntl.h
</span><span style='display:block; white-space:pre;color:#808080;'>index e1fe151..1081580 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/sys/fcntl.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/sys/fcntl.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,6 +1,7 @@
</span>
/*
* Copyright (c) 2010 Chris Jones <jonesc@macports.org>
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2018 Ken Cunningham <kencu@macports.org>
</span> *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -18,7 +19,7 @@
</span> #ifndef _MACPORTS_SYSFCNTL_H_
#define _MACPORTS_SYSFCNTL_H_
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Include the primary system wchar.h */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Include the primary system fcntl.h */
</span> #include_next <sys/fcntl.h>
/* replace missing O_CLOEXEC definition with 0, which works
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -30,4 +31,16 @@
</span> #define O_CLOEXEC 0
#endif
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* openat */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MP_LEGACY_SUPPORT_ATCALLS__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef __cplusplus
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+extern "C" {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int openat(int dirfd, const char *pathname, int flags, ...);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef __cplusplus
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> #endif /* _MACPORTS_SYSFCNTL_H_ */
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/stdio.h b/include/sys/stat.h
</span>similarity index 63%
copy from include/stdio.h
copy to include/sys/stat.h
<span style='display:block; white-space:pre;color:#808080;'>index 63428a1..80bc425 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/stdio.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/sys/stat.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,6 +1,7 @@
</span>
/*
* Copyright (c) 2010 Chris Jones <jonesc@macports.org>
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2018 Ken Cunningham <kencu@macports.org>
</span> *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -15,27 +16,29 @@
</span> * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#ifndef _MACPORTS_STDIO_H_
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define _MACPORTS_STDIO_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef _MACPORTS_SYSSTAT_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _MACPORTS_SYSSTAT_H_
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Include the primary system time.h */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#include_next <stdio.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Include the primary system stat.h */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include_next <sys/stat.h>
</span>
/* MP support header */
#include "MacportsLegacySupport.h"
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* getline */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#if __MP_LEGACY_SUPPORT_GETLINE__
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* #include <unistd.h> */ /* ssize_t */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-typedef long ssize_t;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MP_LEGACY_SUPPORT_ATCALLS__
</span> #ifdef __cplusplus
extern "C" {
#endif
<span style='display:block; white-space:pre;background:#ffe0e0;'>- extern ssize_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *fp);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- extern ssize_t getline (char **lineptr, size_t *n, FILE *stream);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int mkdirat(int dirfd, const char *pathname, mode_t mode);
</span> #ifdef __cplusplus
}
#endif
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif /* _MACPORTS_STDIO_H_ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* _MACPORTS_SYSSTAT_H_ */
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/stdio.h b/include/sys/stdio.h
</span>similarity index 69%
copy from include/stdio.h
copy to include/sys/stdio.h
<span style='display:block; white-space:pre;color:#808080;'>index 63428a1..0aba54d 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/stdio.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/sys/stdio.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,6 +1,7 @@
</span>
/*
* Copyright (c) 2010 Chris Jones <jonesc@macports.org>
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2018 Ken Cunningham <kencu@macports.org>
</span> *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -15,27 +16,26 @@
</span> * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#ifndef _MACPORTS_STDIO_H_
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define _MACPORTS_STDIO_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef _MACPORTS_SYSSTDIO_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _MACPORTS_SYSSTDIO_H_
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Include the primary system time.h */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#include_next <stdio.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Include the primary system sys/stdio.h */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include_next <sys/stdio.h>
</span>
/* MP support header */
#include "MacportsLegacySupport.h"
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* getline */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#if __MP_LEGACY_SUPPORT_GETLINE__
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* #include <unistd.h> */ /* ssize_t */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* renameat */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MP_LEGACY_SUPPORT_ATCALLS__
</span> typedef long ssize_t;
#ifdef __cplusplus
extern "C" {
#endif
<span style='display:block; white-space:pre;background:#ffe0e0;'>- extern ssize_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *fp);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- extern ssize_t getline (char **lineptr, size_t *n, FILE *stream);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
</span> #ifdef __cplusplus
}
#endif
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif /* _MACPORTS_STDIO_H_ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* _MACPORTS_SYSSTDIO_H_ */
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/sys/unistd.h b/include/sys/unistd.h
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..d0101cb
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/sys/unistd.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,53 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2010 Chris Jones <jonesc@macports.org>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2018 Ken Cunningham <kencu@macports.org>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Permission to use, copy, modify, and distribute this software for any
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * purpose with or without fee is hereby granted, provided that the above
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * copyright notice and this permission notice appear in all copies.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef _MACPORTS_SYSUNISTD_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _MACPORTS_SYSUNISTD_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Include the primary system unistd.h */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include_next <sys/unistd.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* MP support header */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include "MacportsLegacySupport.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MP_LEGACY_SUPPORT_ATCALLS__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+typedef long ssize_t;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef __cplusplus
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+extern "C" {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int getattrlistat(int dirfd, const char *pathname, struct attrlist *a,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ void *buf, size_t size, unsigned long flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern ssize_t readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int faccessat(int dirfd, const char *pathname, int mode, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int symlinkat(const char *oldpath, int newdirfd, const char *newpath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ extern int unlinkat(int dirfd, const char *pathname, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef __cplusplus
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* _MACPORTS_SYSUNISTD_H_ */
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/atcalls.c b/src/atcalls.c
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..33fa99e
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/atcalls.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,364 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * atcalls.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2013-2015 Apple Inc. All rights reserved.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * @APPLE_LICENSE_HEADER_START@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * This file contains Original Code and/or Modifications of Original Code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * as defined in and that are subject to the Apple Public Source License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Version 2.0 (the 'License'). You may not use this file except in
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * compliance with the License. Please obtain a copy of the License at
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * http://www.opensource.apple.com/apsl/ and read it before using this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * file.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * The Original Code and all software distributed under the License are
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Please see the License for the specific language governing rights and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * limitations under the License.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * @APPLE_LICENSE_HEADER_END@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* MP support header */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include "MacportsLegacySupport.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MP_LEGACY_SUPPORT_ATCALLS__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/attr.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/errno.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/fcntl.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/param.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/stat.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/mount.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/ucred.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/shm.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <assert.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <dlfcn.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdarg.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdbool.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdint.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdio.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdlib.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <unistd.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <dirent.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <string.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Descriptor value for the current working directory
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define AT_FDCWD -2
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Flags for the at functions
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define AT_EACCESS 0x0010 /* Use effective ids in access check */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define AT_SYMLINK_NOFOLLOW 0x0020 /* Act on the symlink itself not the target */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define AT_SYMLINK_FOLLOW 0x0040 /* Act on target of symlink */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define AT_REMOVEDIR 0x0080 /* Path refers to directory */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* <sys/unistd.h> */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int getattrlistat(int dirfd, const char *pathname, struct attrlist *a,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ void *buf, size_t size, unsigned long flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ssize_t readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int faccessat(int dirfd, const char *pathname, int mode, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int symlinkat(const char *oldpath, int newdirfd, const char *newpath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int unlinkat(int dirfd, const char *pathname, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* #include <sys/stat.h> */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int mkdirat(int dirfd, const char *pathname, mode_t mode);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* #include <sys/fcntl.h> */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int openat(int dirfd, const char *pathname, int flags, ...);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* #include <sys/stdio.h> */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* this is some apple internal magic */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/syscall.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <fcntl.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef SYS___pthread_chdir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# define SYS___pthread_chdir 348
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef SYS___pthread_fchdir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# define SYS___pthread_fchdir 349
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int __pthread_chdir(const char *path)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return syscall(SYS___pthread_chdir, path);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int __pthread_fchdir(int dirfd)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return syscall(SYS___pthread_fchdir, dirfd);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define PROTECT_ERRNO(what) ({ int __err = (errno); what; errno = __err; })
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define ERR_ON(code, what) if (what) { errno = (code); return -1; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _ATCALL(fd, p, onerr, what) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ({ typeof(what) __result; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int oldCWD = -1; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (fd != AT_FDCWD && p[0] != '/') { \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ oldCWD = open(".", O_RDONLY); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (__pthread_fchdir(-1) < 0 && oldCWD != -1) { \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ close(oldCWD); oldCWD = -1; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (__pthread_fchdir(fd) < 0) { \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PROTECT_ERRNO(__pthread_fchdir(oldCWD)); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (oldCWD != -1) PROTECT_ERRNO(close(oldCWD)); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return onerr; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ __result = (what); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (fd != AT_FDCWD && p[0] != '/') { \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PROTECT_ERRNO(__pthread_fchdir(oldCWD)); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (oldCWD != -1) PROTECT_ERRNO(close(oldCWD)); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ __result; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ })
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define ATCALL(fd, p, what) _ATCALL(fd, p, -1, what)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+// buf is a pointer to a buffer of PATH_MAX or larger size
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+_fullpathat(int dirfd, const char *relative, char *buf)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int cwd = -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (dirfd == AT_FDCWD) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cwd = open(".", O_RDONLY);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (cwd == -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dirfd = cwd;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = fcntl(dirfd, F_GETPATH, buf);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (ret == -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ goto fail;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ strlcat(buf, "/", PATH_MAX);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ strlcat(buf, relative, PATH_MAX);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+fail:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (cwd != -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ close(cwd);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int faccessat(int dirfd, const char *pathname, int mode, int flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ struct attrlist al = {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ .bitmapcount = ATTR_BIT_MAP_COUNT,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ .commonattr = ATTR_CMN_USERACCESS,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ struct {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint32_t length;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint32_t access;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } __attribute__((aligned(4), packed)) ab;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ unsigned long opts = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ERR_ON(EINVAL, flags & ~AT_SYMLINK_NOFOLLOW);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (flags & AT_SYMLINK_NOFOLLOW)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ opts |= FSOPT_NOFOLLOW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (getattrlistat(dirfd, pathname, &al, &ab, sizeof(ab), opts) < 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ERR_ON(EACCES, (ab.access & mode) != (uint32_t)mode);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int fchflagsat(int dirfd, const char *path, int flags, int at_flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ERR_ON(EINVAL, at_flags & ~AT_SYMLINK_NOFOLLOW);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (at_flags & AT_SYMLINK_NOFOLLOW) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, path, lchflags(path, flags));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, path, chflags(path, flags));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ERR_ON(EINVAL, flags & ~AT_SYMLINK_NOFOLLOW);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (flags & AT_SYMLINK_NOFOLLOW) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, lchmod(pathname, mode));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, chmod(pathname, mode));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ERR_ON(EINVAL, flags & ~AT_SYMLINK_NOFOLLOW);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (flags & AT_SYMLINK_NOFOLLOW) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, lchown(pathname, owner, group));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, chown(pathname, owner, group));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ERR_ON(EINVAL, flags & ~AT_SYMLINK_NOFOLLOW);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (flags & AT_SYMLINK_NOFOLLOW) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, lstat(pathname, buf));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, stat(pathname, buf));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int getattrlistat(int dirfd, const char *pathname, struct attrlist *a,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ void *buf, size_t size, unsigned long flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef __LP64__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* This is fricken stupid */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ unsigned int _flags = (unsigned int)flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ assert ((unsigned long)_flags == flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, getattrlist(pathname, a, buf, size, _flags));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, getattrlist(pathname, a, buf, size, flags));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ERR_ON(EINVAL, flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (oldpath[0] == '/') {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(newdirfd, newpath, link(oldpath, newpath));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (newpath[0] == '/' || olddirfd == newdirfd) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(olddirfd, oldpath, link(oldpath, newpath));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // olddirfd != newdirfd and both relative
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char _oldpath[PATH_MAX];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = _fullpathat(olddirfd, oldpath, _oldpath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (ret == -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char _newpath[PATH_MAX];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = _fullpathat(newdirfd, newpath, _newpath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (ret == -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return link(_oldpath, _newpath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int mkdirat(int dirfd, const char *pathname, mode_t mode)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, mkdir(pathname, mode));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int mkfifoat(int dirfd, const char *pathname, mode_t mode)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, mkfifo(pathname, mode));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int mknodat(int dirfd, const char *pathname, mode_t mode, dev_t dev)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, mknod(pathname, mode, dev));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int openat(int dirfd, const char *pathname, int flags, ...)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ mode_t mode = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (flags & O_CREAT) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ va_list ap;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ va_start(ap, flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ mode = (mode_t)va_arg(ap, int);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ va_end(ap);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, open(pathname, flags, mode));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int openat$NOCANCEL(int dirfd, const char *pathname, int flags, ...)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ mode_t mode = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (flags & O_CREAT) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ va_list ap;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ va_start(ap, flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ mode = (mode_t)va_arg(ap, int);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ va_end(ap);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, open(pathname, flags, mode));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ssize_t readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, readlink(pathname, buf, bufsiz));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (oldpath[0] == '/') {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(newdirfd, newpath, rename(oldpath, newpath));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (newpath[0] == '/' || olddirfd == newdirfd) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(olddirfd, oldpath, rename(oldpath, newpath));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // olddirfd != newdirfd and both relative
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char _oldpath[PATH_MAX];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = _fullpathat(olddirfd, oldpath, _oldpath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (ret == -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char _newpath[PATH_MAX];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = _fullpathat(newdirfd, newpath, _newpath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (ret == -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return rename(_oldpath, _newpath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int symlinkat(const char *oldpath, int newdirfd, const char *newpath)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(newdirfd, newpath, symlink(oldpath, newpath));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int unlinkat(int dirfd, const char *pathname, int flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ERR_ON(EINVAL, flags & ~AT_REMOVEDIR);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (flags & AT_REMOVEDIR) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, rmdir(pathname));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ATCALL(dirfd, pathname, unlink(pathname));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ */
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/memmem.c b/src/memmem.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 13bd850..ec61bd1 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/memmem.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/memmem.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -27,7 +27,7 @@
</span> * SUCH DAMAGE.
*/
<span style='display:block; white-space:pre;background:#ffe0e0;'>-// MP support header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* MP support header */
</span> #include "MacportsLegacySupport.h"
#if __MP_LEGACY_SUPPORT_MEMMEM__
</pre><pre style='margin:0'>
</pre>