[syslinux] [PATCH 2/3] COM32 API: Correct readdir(), opendir(), closedir() and dirent.h
Gene Cumm
gene.cumm at gmail.com
Sun Mar 1 07:08:59 PST 2009
From: Gene Cumm <gene.cumm at gmail.com>
COM32 API: Correct readdir(), opendir(), closedir() and dirent.h;
Forgot some includes in opendir.c, closedir.c and readdir.c.
readdir() now loads DX into d_mode then the quick translate to d_type.
Signed-off-by: Gene Cumm <gene.cumm at gmail.com>
---
Depends on the patch I just submitted about changing from d_type in DL
to st_mode in DX.
diff --git a/com32/include/dirent.h b/com32/include/dirent.h
index 956b911..5161828 100644
--- a/com32/include/dirent.h
+++ b/com32/include/dirent.h
@@ -14,10 +14,13 @@
#define NAME_MAX 255
#endif
+#define IFTODT(mode) (((mode) & 0170000) >> 12)
+
struct dirent {
long d_ino; /* Inode/File number */
off_t d_size; /* Size of file */
- mode_t d_mode; /* Type of file */
+ mode_t d_mode; /* Mode of file */
+ unsigned char d_type; /* Type of file */
char d_name[NAME_MAX + 1];
};
diff --git a/com32/lib/closedir.c b/com32/lib/closedir.c
index 8a0430e..17445b8 100644
--- a/com32/lib/closedir.c
+++ b/com32/lib/closedir.c
@@ -5,6 +5,7 @@
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
+#include <stdlib.h>
#include <com32.h>
#include <string.h>
diff --git a/com32/lib/opendir.c b/com32/lib/opendir.c
index aa2ba5b..e9d8353 100644
--- a/com32/lib/opendir.c
+++ b/com32/lib/opendir.c
@@ -5,6 +5,7 @@
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
+#include <stdlib.h>
#include <com32.h>
#include <string.h>
diff --git a/com32/lib/readdir.c b/com32/lib/readdir.c
index bfa5252..353b61b 100644
--- a/com32/lib/readdir.c
+++ b/com32/lib/readdir.c
@@ -5,11 +5,13 @@
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
+#include <stdlib.h>
#include <com32.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
+#include <sys/stat.h>
struct dirent *readdir(DIR *dir)
{
@@ -34,7 +36,8 @@ struct dirent *readdir(DIR *dir)
newde = calloc(1, sizeof(newde));
if (newde != NULL) {
strcpy(newde->d_name, __com32.cs_bounce);
- newde->d_mode = regs.edx.b[0];
+ newde->d_mode = regs.edx.w[0];
+ newde->d_type = (newde->d_mode & S_IFMT) >> 12;
newde->d_size = regs.eax.l;
newde->d_ino = regs.ebx.l;
dir->dd_stat = 1;
@@ -44,7 +47,7 @@ struct dirent *readdir(DIR *dir)
}
} else {
dir->dd_stat = -1;
- errno = EIO; /* Is this the right nmber? */
+ errno = EIO; /* Is this the right number? */
}
} else {
errno = EBADF;
More information about the Syslinux
mailing list