summaryrefslogtreecommitdiffstats
path: root/contrib/syslinux-4.02/core/fs/readdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/syslinux-4.02/core/fs/readdir.c')
-rw-r--r--contrib/syslinux-4.02/core/fs/readdir.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/core/fs/readdir.c b/contrib/syslinux-4.02/core/fs/readdir.c
new file mode 100644
index 0000000..d071aff
--- /dev/null
+++ b/contrib/syslinux-4.02/core/fs/readdir.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+#include <sys/dirent.h>
+#include "fs.h"
+#include "core.h"
+
+/*
+ * Open a directory
+ */
+DIR *opendir(const char *path)
+{
+ int rv;
+ struct file *file;
+
+ rv = searchdir(path);
+ if (rv < 0)
+ return NULL;
+
+ file = handle_to_file(rv);
+
+ if (file->inode->mode != DT_DIR) {
+ _close_file(file);
+ return NULL;
+ }
+
+ return (DIR *)file;
+}
+
+/*
+ * Read one directory entry at one time.
+ */
+struct dirent *readdir(DIR *dir)
+{
+ static struct dirent buf;
+ struct file *dd_dir = (struct file *)dir;
+ int rv = -1;
+
+ if (dd_dir) {
+ if (dd_dir->fs->fs_ops->readdir) {
+ rv = dd_dir->fs->fs_ops->readdir(dd_dir, &buf);
+ }
+ }
+
+ return rv < 0 ? NULL : &buf;
+}
+
+/*
+ * Close a directory
+ */
+int closedir(DIR *dir)
+{
+ struct file *dd_dir = (struct file *)dir;
+ _close_file(dd_dir);
+ return 0;
+}
+
+