Adding upstream version 4.00~pre53+dfsg.
[syslinux-debian/hramrach.git] / core / fs / readdir.c
blobd20fc33baba365ebdfe7a9a16273549d149683fc
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/dirent.h>
4 #include "fs.h"
5 #include "core.h"
7 /*
8 * Open a directory
9 */
10 DIR *opendir(const char *path)
12 int rv;
14 rv = searchdir(path);
15 if (rv < 0)
16 return NULL;
18 /* XXX: check for a directory handle here */
19 return (DIR *)handle_to_file(rv);
23 * Read one directory entry at one time.
25 struct dirent *readdir(DIR *dir)
27 static struct dirent buf;
28 struct file *dd_dir = (struct file *)dir;
29 int rv = -1;
31 if (dd_dir) {
32 if (dd_dir->fs->fs_ops->readdir) {
33 rv = dd_dir->fs->fs_ops->readdir(dd_dir, &buf);
37 return rv < 0 ? NULL : &buf;
41 * Close a directory
43 int closedir(DIR *dir)
45 struct file *dd_dir = (struct file *)dir;
46 _close_file(dd_dir);
47 return 0;