diff mbox series

[pseudo,2/3] ports/linux/openat2: Add dummy wrapper

Message ID 20260113231729.2698563-2-richard.purdie@linuxfoundation.org
State New
Headers show
Series [pseudo,1/3] test-syscall: Add a syscall test | expand

Commit Message

Richard Purdie Jan. 13, 2026, 11:17 p.m. UTC
From: "mark.hatle" <mark.hatle@kernel.crashing.org>

For now fail politely, most callers have fallback behavior.

Signed-off-by: mark.hatle <mark.hatle@kernel.crashing.org>
---
 makewrappers                       |  1 +
 ports/linux/openat2/guts/openat2.c | 23 +++++++++++++++++++++++
 ports/linux/openat2/portdefs.h     | 13 +++++++++++++
 ports/linux/openat2/wrapfuncs.in   |  1 +
 ports/linux/subports               |  2 ++
 5 files changed, 40 insertions(+)
 create mode 100644 ports/linux/openat2/guts/openat2.c
 create mode 100644 ports/linux/openat2/portdefs.h
 create mode 100644 ports/linux/openat2/wrapfuncs.in
diff mbox series

Patch

diff --git a/makewrappers b/makewrappers
index 67c73e2..0d73cc1 100755
--- a/makewrappers
+++ b/makewrappers
@@ -209,6 +209,7 @@  typedata = {
   'ssize_t': { 'format': '%ld', 'value': '(long) rc' },
   'struct group *': { 'format': '%p', 'value': '(void *) rc' },
   'struct passwd *': { 'format': '%p', 'value': '(void *) rc' },
+  'struct open_how *': { 'format': '%p', 'value': '(void *) rc' },
   'uid_t': { 'format': '%ld', 'value': ' (long) rc' },
   'void *': { 'format': '%p', 'value': 'rc' },
   'void': { 'format': 'void%s', 'value': '""' },
diff --git a/ports/linux/openat2/guts/openat2.c b/ports/linux/openat2/guts/openat2.c
new file mode 100644
index 0000000..da01b31
--- /dev/null
+++ b/ports/linux/openat2/guts/openat2.c
@@ -0,0 +1,23 @@ 
+/*
+ * Copyright (c) 2026 Mark Hatle <mark.hatle@amd.com>; see
+ * guts/COPYRIGHT for information.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * int openat2(int dirfd, const char *path, struct open_how *how, size_t size)
+ *	int rc = -1;
+ */
+
+	(void) dirfd;
+	(void) path;
+	(void) how;
+	(void) size;
+	/* for now, let's try just failing out hard, and hope things retry with a
+	 * different syscall.
+	 */
+	errno = ENOSYS;
+	rc = -1;
+
+/*	return rc;
+ * }
+ */
diff --git a/ports/linux/openat2/portdefs.h b/ports/linux/openat2/portdefs.h
new file mode 100644
index 0000000..8e4e33e
--- /dev/null
+++ b/ports/linux/openat2/portdefs.h
@@ -0,0 +1,13 @@ 
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+#if __has_include (<linux/openat2.h>)
+# include <linux/openat2.h>
+#else
+  struct open_how {
+        __u64 flags;
+        __u64 mode;
+        __u64 resolve;
+  };
+#endif
diff --git a/ports/linux/openat2/wrapfuncs.in b/ports/linux/openat2/wrapfuncs.in
new file mode 100644
index 0000000..96ae8a7
--- /dev/null
+++ b/ports/linux/openat2/wrapfuncs.in
@@ -0,0 +1 @@ 
+int openat2(int dirfd, const char *path, struct open_how *how, size_t size);
diff --git a/ports/linux/subports b/ports/linux/subports
index 099ea59..b202c27 100755
--- a/ports/linux/subports
+++ b/ports/linux/subports
@@ -70,3 +70,5 @@  else
 fi
 rm -f dummy.c dummy.o
 
+# For openat2, similar to statx, we need to be able to build on systems without that support.
+echo "linux/openat2"