OrionLibC
Barry Importing existing Orion LibC 03048a9 (3 years, 2 months ago)
diff --git a/unistd/getcwd.c b/unistd/getcwd.c
new file mode 100644
index 0000000..0107f2f
--- /dev/null
+++ b/unistd/getcwd.c
@@ -0,0 +1,16 @@
+#include <stddef.h>
+#include <sys/syscall.h>
+#include <errno.h>
+
+/* Get the current working directory's path */
+char *
+getcwd(char *buf, size_t size)
+{
+ int ret;
+ asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_GETCWD),
+ "c" (2), "S" (&buf));
+ if ((char *) ret == buf)
+ return (char *) ret;
+ errno = -ret;
+ return NULL;
+}