aboutsummaryrefslogtreecommitdiffstats
path: root/roms/openbios/fs/ext2/ext2_opendir.c
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/openbios/fs/ext2/ext2_opendir.c
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/openbios/fs/ext2/ext2_opendir.c')
-rw-r--r--roms/openbios/fs/ext2/ext2_opendir.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/roms/openbios/fs/ext2/ext2_opendir.c b/roms/openbios/fs/ext2/ext2_opendir.c
new file mode 100644
index 000000000..3363e0b3a
--- /dev/null
+++ b/roms/openbios/fs/ext2/ext2_opendir.c
@@ -0,0 +1,49 @@
+/*
+ *
+ * (c) 2008-2009 Laurent Vivier <Laurent@lvivier.info>
+ *
+ * This file has been copied from EMILE, http://emile.sf.net
+ *
+ */
+
+#include "libext2.h"
+#include "ext2.h"
+#include "ext2_utils.h"
+
+ext2_DIR* ext2_opendir(ext2_VOLUME *volume, const char *name)
+{
+ ext2_DIR* dir;
+ int ino;
+ struct ext2_inode *inode;
+ int ret;
+
+ ino = ext2_seek_name(volume, name);
+ if (ino == 0)
+ return NULL;
+
+ inode = (struct ext2_inode*)malloc(sizeof(struct ext2_inode));
+ if (inode == NULL)
+ return NULL;
+
+ ret = ext2_get_inode(volume, ino, inode);
+ if (ret == -1) {
+ free(inode);
+ return NULL;
+ }
+
+ if (!S_ISDIR(inode->i_mode)) {
+ free(inode);
+ return NULL;
+ }
+
+ dir = (ext2_DIR*)malloc(sizeof(ext2_DIR));
+ if (dir == NULL) {
+ free(inode);
+ return NULL;
+ }
+ dir->volume = (ext2_VOLUME*)volume;
+ dir->inode = inode;
+ dir->index = 0;
+
+ return dir;
+}