diff options
-rw-r--r-- | core/fs/readdir.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/fs/readdir.c b/core/fs/readdir.c index d20fc33b..d071affd 100644 --- a/core/fs/readdir.c +++ b/core/fs/readdir.c @@ -10,13 +10,20 @@ DIR *opendir(const char *path) { int rv; + struct file *file; rv = searchdir(path); if (rv < 0) return NULL; - /* XXX: check for a directory handle here */ - return (DIR *)handle_to_file(rv); + file = handle_to_file(rv); + + if (file->inode->mode != DT_DIR) { + _close_file(file); + return NULL; + } + + return (DIR *)file; } /* |