summaryrefslogtreecommitdiff
path: root/src/unistd/getcwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/unistd/getcwd.c')
-rw-r--r--src/unistd/getcwd.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/unistd/getcwd.c b/src/unistd/getcwd.c
new file mode 100644
index 00000000..e8e46a60
--- /dev/null
+++ b/src/unistd/getcwd.c
@@ -0,0 +1,21 @@
+#include "stddef.h"
+#include "sys/types.h"
+#include <unistd.h>
+#include "errno.h"
+#include "nonstd/assert.h"
+#include "nonstd/syscall.h"
+
+char * getcwd(char *buf, size_t size)
+{
+ ASSERT_NONNULL(buf);
+ SCNO(scno, "getcwd", NULL);
+ int r = __libc.syscall(scno, buf, size);
+ if (r < 0) {
+ errno = -r;
+ return NULL;
+ }
+ return buf;
+}
+/*
+POSIX(1)
+*/