summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-06 15:59:57 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-06 15:59:57 +0100
commite5e0bffd769ed29c42dc07e70dc40639b6ba51c7 (patch)
tree5d30a03e999a47e00cc86265e3d76dce0c5a9614
parent7c3746592bf2547dbd5de5d07589c7e19ea6fe2a (diff)
downloadserenity-e5e0bffd769ed29c42dc07e70dc40639b6ba51c7.zip
Add getwd().
-rw-r--r--LibC/limits.h3
-rw-r--r--LibC/sys/param.h2
-rw-r--r--LibC/unistd.cpp5
-rw-r--r--LibC/unistd.h2
4 files changed, 11 insertions, 1 deletions
diff --git a/LibC/limits.h b/LibC/limits.h
index e69de29bb2..355cea6330 100644
--- a/LibC/limits.h
+++ b/LibC/limits.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define PATH_MAX 4096
diff --git a/LibC/sys/param.h b/LibC/sys/param.h
index bbc4517380..fa80d611fb 100644
--- a/LibC/sys/param.h
+++ b/LibC/sys/param.h
@@ -1,4 +1,4 @@
#pragma once
#include <endian.h>
-
+#include <limits.h>
diff --git a/LibC/unistd.cpp b/LibC/unistd.cpp
index 5ba180d38d..1a5d8b0e95 100644
--- a/LibC/unistd.cpp
+++ b/LibC/unistd.cpp
@@ -156,6 +156,11 @@ char* getcwd(char* buffer, size_t size)
__RETURN_WITH_ERRNO(rc, buffer, nullptr);
}
+char* getwd(char* buf)
+{
+ return getcwd(buf, PATH_MAX);
+}
+
int sleep(unsigned seconds)
{
return Syscall::invoke(Syscall::SC_sleep, (dword)seconds);
diff --git a/LibC/unistd.h b/LibC/unistd.h
index 69d9e9c31c..d16663140c 100644
--- a/LibC/unistd.h
+++ b/LibC/unistd.h
@@ -2,6 +2,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
+#include <limits.h>
__BEGIN_DECLS
@@ -29,6 +30,7 @@ int close(int fd);
pid_t waitpid(pid_t, int* wstatus, int options);
int chdir(const char* path);
char* getcwd(char* buffer, size_t size);
+char* getwd(char* buffer);
int lstat(const char* path, struct stat* statbuf);
int stat(const char* path, struct stat* statbuf);
int sleep(unsigned seconds);