[syslinux] [PATCH 3/5] COM32: Improve opendir() to deal with no '/' at end of string
Gene Cumm
gene.cumm at gmail.com
Wed Mar 4 16:32:22 PST 2009
From: Gene Cumm <gene.cumm at gmail.com>
COM32: Improve opendir() to deal with no '/' at end of string
Signed-off-by: Gene Cumm <gene.cumm at gmail.com>
---
Originally, this was going to be 3 patches but I ended up doing a little more.
Currently, the COMBOOT call required a '/' to recognize that you're
searching for a directory. This checks and automatically appends a
'/' to the end of the pathname string (by creating another string
temporarily) then making the COMBOOT call.
diff --git a/com32/lib/opendir.c b/com32/lib/opendir.c
index aa2ba5b..7063f8c 100644
--- a/com32/lib/opendir.c
+++ b/com32/lib/opendir.c
@@ -16,10 +17,20 @@ DIR *opendir(const char *pathname)
{
DIR *newdir;
com32sys_t regs;
+ char *tpath;
+ int pathlen;
newdir = NULL;
+ pathlen = strlen(pathname);
+ if (pathname[pathlen-1] != '/') {
+ tpath = calloc(1, pathlen + 2);
+ strcpy(tpath, pathname);
+ strcpy(tpath + pathlen, "/");
+ } else {
+ tpath = pathname;
+ }
- strlcpy(__com32.cs_bounce, pathname, __com32.cs_bounce_size);
+ strlcpy(__com32.cs_bounce, tpath, __com32.cs_bounce_size);
regs.eax.w[0] = 0x0020;
regs.esi.w[0] = OFFS(__com32.cs_bounce);
@@ -34,6 +45,10 @@ DIR *opendir(const char *pathname)
newdir->dd_fd = regs.esi.w[0];
newdir->dd_sect = regs.eax.l;
newdir->dd_stat = 0;
+ errno = 0;
+ } else {
+ /* ENOTDIR is another but a file must exist */
+ errno = ENOENT;
}
/* We're done */
More information about the Syslinux
mailing list