summaryrefslogtreecommitdiff
path: root/LibC/dirent.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-05 19:01:22 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-05 19:01:59 +0100
commit9f2b9c82bf0424bb8d0bbc832a0fa6366c3def9a (patch)
tree953c9032c530310a9e230801e6d8f0aa46aa9bcd /LibC/dirent.cpp
parent82f84bab114e8fb1651041ed1ccff4c30d267f19 (diff)
downloadserenity-9f2b9c82bf0424bb8d0bbc832a0fa6366c3def9a.zip
More work towards getting bash to build.
Implemented some syscalls: dup(), dup2(), getdtablesize(). FileHandle is now a retainable, since that's needed for dup()'ed fd's. I didn't really test any of this beyond a basic smoke check.
Diffstat (limited to 'LibC/dirent.cpp')
-rw-r--r--LibC/dirent.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/LibC/dirent.cpp b/LibC/dirent.cpp
index 07d50d01d4..0914e856f3 100644
--- a/LibC/dirent.cpp
+++ b/LibC/dirent.cpp
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include <Kernel/Syscall.h>
extern "C" {
@@ -20,6 +21,16 @@ DIR* opendir(const char* name)
return dirp;
}
+int closedir(DIR* dirp)
+{
+ if (!dirp || dirp->fd == -1)
+ return -EBADF;
+ int rc = close(dirp->fd);
+ if (rc == 0)
+ dirp->fd = -1;
+ return rc;
+}
+
struct sys_dirent {
ino_t ino;
byte file_type;