summaryrefslogtreecommitdiff
path: root/userland/libc/dirent/opendir.c
diff options
context:
space:
mode:
Diffstat (limited to 'userland/libc/dirent/opendir.c')
-rw-r--r--userland/libc/dirent/opendir.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/userland/libc/dirent/opendir.c b/userland/libc/dirent/opendir.c
index 7bfa562..efe8b6d 100644
--- a/userland/libc/dirent/opendir.c
+++ b/userland/libc/dirent/opendir.c
@@ -1,10 +1,24 @@
#include <dirent.h>
+DIR *fdopendir(int fd) {
+ DIR *rc = malloc(sizeof(DIR));
+ if (!rc) {
+ return NULL;
+ }
+ rc->fd = fd;
+ rc->dir_num = 0;
+ return rc;
+}
+
DIR *opendir(const char *dirname) {
int fd = open(dirname, O_RDONLY, 0);
- if (-1 == fd)
+ if (-1 == fd) {
return NULL;
+ }
DIR *rc = malloc(sizeof(DIR));
+ if (!rc) {
+ return NULL;
+ }
rc->fd = fd;
rc->dir_num = 0;
return rc;