aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
Diffstat (limited to 'com32')
-rw-r--r--com32/include/sys/dirent.h7
-rw-r--r--com32/include/syslinux/pmapi.h7
-rw-r--r--com32/lib/Makefile2
-rw-r--r--com32/lib/closedir.c30
-rw-r--r--com32/lib/opendir.c41
-rw-r--r--com32/lib/readdir.c27
-rw-r--r--com32/lib/sys/readdir.c30
-rw-r--r--com32/rosh/rosh.c1
8 files changed, 40 insertions, 105 deletions
diff --git a/com32/include/sys/dirent.h b/com32/include/sys/dirent.h
index cc2916e1..a7f26e45 100644
--- a/com32/include/sys/dirent.h
+++ b/com32/include/sys/dirent.h
@@ -19,11 +19,8 @@ struct dirent {
char d_name[NAME_MAX + 1];
};
-struct file;
-
-typedef struct {
- struct file *dd_dir;
-} DIR;
+struct _DIR_;
+typedef struct _DIR_ DIR;
#define DIR_REC_LEN(name) (12 + strlen(name) + 1 + 3) & ~3
diff --git a/com32/include/syslinux/pmapi.h b/com32/include/syslinux/pmapi.h
index d16d3de1..34648e52 100644
--- a/com32/include/syslinux/pmapi.h
+++ b/com32/include/syslinux/pmapi.h
@@ -42,11 +42,18 @@
* Note: add new members to this structure only at the end.
* The position of elements in this structure is an ABI.
*/
+struct _DIR_;
+struct dirent;
+
struct com32_pmapi {
void *(*lmalloc)(size_t);
void (*lfree)(void *);
size_t (*read_file)(uint16_t *, void *, size_t);
+
+ struct _DIR_ *(*opendir)(const char *);
+ struct dirent *(*readdir)(struct _DIR_ *);
+ int (*closedir)(struct _DIR_ *);
};
#endif /* _SYSLINUX_PMAPI_H */
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 8aad4f8d..93643ce2 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -31,7 +31,7 @@ LIBOBJS = \
\
dprintf.o vdprintf.o \
\
- opendir.o readdir.o closedir.o getcwd.o chdir.o fdopendir.o \
+ sys/readdir.o getcwd.o chdir.o fdopendir.o \
\
libgcc/__ashldi3.o libgcc/__udivdi3.o \
libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \
diff --git a/com32/lib/closedir.c b/com32/lib/closedir.c
deleted file mode 100644
index f4de67ae..00000000
--- a/com32/lib/closedir.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * closedir.c
- */
-
-#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <com32.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-int closedir(DIR * dir)
-{
- int rv = -1;
-
- if (dir) {
- com32sys_t regs;
- memset(&regs, 0, sizeof regs);
- regs.eax.w[0] = 0x0022;
- regs.esi.l = (uint32_t)dir;
- __com32.cs_intcall(0x22, &regs, &regs);
- free(dir);
- rv = 0;
- }
-
- return rv;
-}
diff --git a/com32/lib/opendir.c b/com32/lib/opendir.c
deleted file mode 100644
index e3c35ce8..00000000
--- a/com32/lib/opendir.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * opendir.c
- */
-
-#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <com32.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-DIR *opendir(const char *pathname)
-{
- DIR *newdir = NULL;
- com32sys_t regs;
- char *lm_pathname;
-
- lm_pathname = lstrdup(pathname);
- if (!lm_pathname)
- return NULL;
-
- regs.eax.w[0] = 0x0020;
- regs.esi.w[0] = OFFS(lm_pathname);
- regs.es = SEG(lm_pathname);
-
- __com32.cs_intcall(0x22, &regs, &regs);
-
- if (!(regs.eflags.l & EFLAGS_CF)) {
- /* Initialization: malloc() then zero */
- newdir = zalloc(sizeof(DIR));
- newdir->dd_dir = (struct file *)regs.eax.l;
- }
-
- lfree(lm_pathname);
-
- /* We're done */
- return newdir;
-}
diff --git a/com32/lib/readdir.c b/com32/lib/readdir.c
deleted file mode 100644
index d59ad3a2..00000000
--- a/com32/lib/readdir.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * readdir.c
- */
-
-#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <com32.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-struct dirent *readdir(DIR * dir)
-{
- struct dirent *newde;
- com32sys_t regs;
-
- memset(&regs, 0, sizeof(regs));
- regs.eax.w[0] = 0x0021;
- regs.esi.l = (uint32_t)dir;
- __com32.cs_intcall(0x22, &regs, &regs);
- newde = (struct dirent *)(regs.eax.l);
-
- return newde;
-}
diff --git a/com32/lib/sys/readdir.c b/com32/lib/sys/readdir.c
new file mode 100644
index 00000000..d2a8c039
--- /dev/null
+++ b/com32/lib/sys/readdir.c
@@ -0,0 +1,30 @@
+/*
+ * readdir.c
+ */
+
+#include <dirent.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <com32.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+
+#include <syslinux/pmapi.h>
+
+DIR *opendir(const char *pathname)
+{
+ return __com32.cs_pm->opendir(pathname);
+}
+
+struct dirent *readdir(DIR *dir)
+{
+ return __com32.cs_pm->readdir(dir);
+}
+
+int closedir(DIR *dir)
+{
+ return __com32.cs_pm->closedir(dir);
+}
diff --git a/com32/rosh/rosh.c b/com32/rosh/rosh.c
index 13e8ffbd..aa3e4532 100644
--- a/com32/rosh/rosh.c
+++ b/com32/rosh/rosh.c
@@ -451,7 +451,6 @@ void rosh_dir_arg(const char *ifilstr, const char *pwdstr)
// inchar = fgetc(stdin);
// fgets(instr, ROSH_CMD_SZ, stdin);
#endif /* DO_DEBUG */
- free(de);
de = readdir(d);
// if(filepos>15){ de = NULL; printf("Force Break\n");}
}