<pre style='margin:0'>
Christopher Nielsen (mascguy) pushed a commit to branch master
in repository macports-legacy-support.
</pre>
<p><a href="https://github.com/macports/macports-legacy-support/commit/af8a73fc55b153e86d090198e782ca20b7ad2221">https://github.com/macports/macports-legacy-support/commit/af8a73fc55b153e86d090198e782ca20b7ad2221</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit af8a73fc55b153e86d090198e782ca20b7ad2221
</span>Author: raf <raf@raf.org>
AuthorDate: Mon Jul 15 10:02:45 2024 +1000
<span style='display:block; white-space:pre;color:#404040;'> Add fgetattrlist()
</span>---
README.md | 3 +-
include/MacportsLegacySupport.h | 2 +-
include/unistd.h | 2 +
src/fgetattrlist.c | 81 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 86 insertions(+), 2 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/README.md b/README.md
</span><span style='display:block; white-space:pre;color:#808080;'>index bb98225..3be260c 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/README.md
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/README.md
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -199,7 +199,8 @@ Wrapped headers and replaced functions are:
</span> <td rowspan="3"><code>sys/unistd.h</code></td>
<td>Adds <code>getattrlistat</code>, <code>readlinkat</code>, <code>faccessat</code>,
<code>fchownat</code>, <code>linkat</code>, <code>symlinkat</code>,
<span style='display:block; white-space:pre;background:#ffe0e0;'>- and <code>unlinkat</code> functions</td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ <code>unlinkat</code></td>,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ <code>fsetattrlist</code>, and <code>fgetattrlist</code> functions.
</span> <td>OSX10.9</td>
</tr>
<tr>
<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 1e766af..2cbf685 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;'>@@ -222,7 +222,7 @@
</span> /* realpath() on < 10.6 does not support modern NULL buffer usage */
#define __MPLS_LIB_SUPPORT_REALPATH_WRAP__ (__MPLS_TARGET_OSVER < 1060)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* setattrlist */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* fsetattrlistat, fgetattrlistat */
</span> #define __MPLS_SDK_SUPPORT_FSETATTRLIST__ (__MPLS_SDK_MAJOR < 1060)
#define __MPLS_LIB_SUPPORT_FSETATTRLIST__ (__MPLS_TARGET_OSVER < 1060)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/unistd.h b/include/unistd.h
</span><span style='display:block; white-space:pre;color:#808080;'>index 4474ee5..23b4b7e 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/unistd.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/unistd.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -101,8 +101,10 @@
</span>
#ifdef __LP64__
int fsetattrlist(int,void*,void*,size_t,unsigned int);
<span style='display:block; white-space:pre;background:#e0ffe0;'>+int fgetattrlist(int,void*,void*,size_t,unsigned int);
</span> #else /* defined (__LP64__) */
int fsetattrlist(int,void*,void*,size_t,unsigned long);
<span style='display:block; white-space:pre;background:#e0ffe0;'>+int fgetattrlist(int,void*,void*,size_t,unsigned long);
</span> #endif /* defined (__LP64__) */
#endif /* __MPLS_SDK_SUPPORT_FSETATTRLIST__ */
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/fgetattrlist.c b/src/fgetattrlist.c
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..8d9f61b
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/fgetattrlist.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,81 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2024 Mihai Moldovan <ionic@ionic.de>, raf <raf@raf.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;'>+/* 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 __MPLS_LIB_SUPPORT_FSETATTRLIST__
</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/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/errno.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <fcntl.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <string.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <unistd.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;'>+#ifdef __LP64__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int fgetattrlist(int fd, void *a, void *buf, size_t size, unsigned int flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#else /* defined (__LP64__) */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int fgetattrlist(int fd, void *a, void *buf, size_t size, unsigned long flags)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* defined (__LP64__) */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int cont = 1,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char fpath[MAXPATHLEN];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ memset (fpath, 0, MAXPATHLEN);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (-1 == fcntl(fd, F_GETPATH, fpath)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = EBADF;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cont = 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 __MPLS_TARGET_OSVER < 1080
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Older systems don't correctly check if no attributes are to be read, which usually
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * means a buffer size of zero and return an error since they malloc a block of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * memory with size zero, leading to ENOMEM.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Emulate the fix from 10.8 for those.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Note: This check is inherited from fsetattrlist() and might or might
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * not be appropriate here (but it seems reasonable).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ const struct attrlist *al = a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (al->commonattr == 0 &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (al->volattr & ~ATTR_VOL_INFO) == 0 &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ al->dirattr == 0 &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ al->fileattr == 0 &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ al->forkattr == 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cont = 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;'>+ * Explicitly let the potential error from above pass through, since that's what
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * the original function seems to do as well.
</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;'>+ if (cont) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = getattrlist(fpath, a, buf, size, 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;'>+ 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;'>+#endif /* __MPLS_LIB_SUPPORT_FSETATTRLIST__ */
</span></pre><pre style='margin:0'>
</pre>