[PATCH 1/2] tools/nolibc: add pipe() support

From: Yuan Tan
Date: Tue Jul 25 2023 - 14:01:39 EST


pipe is crucial for shell.

Signed-off-by: Yuan Tan <tanyuan@xxxxxxxxxxx>
---
tools/include/nolibc/sys.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 8bfe7db20b80..09841fc266fe 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -752,6 +752,23 @@ int open(const char *path, int flags, ...)
}


+/*
+ * int pipe(int pipefd[2]);
+ */
+
+static __attribute__((unused))
+int sys_pipe(int pipefd[2])
+{
+ return my_syscall1(__NR_pipe, pipefd);
+}
+
+static __attribute__((unused))
+int pipe(int pipefd[2])
+{
+ return __sysret(sys_pipe(pipefd));
+}
+
+
/*
* int prctl(int option, unsigned long arg2, unsigned long arg3,
* unsigned long arg4, unsigned long arg5);
--
2.39.2