[syslinux:master] PM getcwd(); Fix COM32 getcwd
syslinux-bot for Gene Cumm
gene.cumm at gmail.com
Sat Jun 26 20:54:04 PDT 2010
Commit-ID: 03791432c7207da9eb6c898bf15f003ab92ff10e
Gitweb: http://syslinux.zytor.com/commit/03791432c7207da9eb6c898bf15f003ab92ff10e
Author: Gene Cumm <gene.cumm at gmail.com>
AuthorDate: Sat, 26 Jun 2010 22:51:39 -0400
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Sat, 26 Jun 2010 20:52:58 -0700
PM getcwd(); Fix COM32 getcwd
Implement getcwd() in the core; Fix COM32 getcwd() to use the new function.
This resolves the previous comment about COM32 getcwd() not working by
not using INT 22h AX=001Fh.
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
com32/include/syslinux/pmapi.h | 1 +
com32/lib/getcwd.c | 23 ++---------------------
core/fs/getcwd.c | 13 +++++++++++++
core/include/fs.h | 3 +++
core/pmapi.c | 1 +
5 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/com32/include/syslinux/pmapi.h b/com32/include/syslinux/pmapi.h
index f1036df..c325b62 100644
--- a/com32/include/syslinux/pmapi.h
+++ b/com32/include/syslinux/pmapi.h
@@ -69,6 +69,7 @@ struct com32_pmapi {
void (*reset_idle)(void);
int (*chdir)(const char *);
+ char *(*getcwd)(char *, size_t);
};
#endif /* _SYSLINUX_PMAPI_H */
diff --git a/com32/lib/getcwd.c b/com32/lib/getcwd.c
index 38fae52..5ce62ec 100644
--- a/com32/lib/getcwd.c
+++ b/com32/lib/getcwd.c
@@ -2,29 +2,10 @@
* getcwd.c
*/
-#include <syslinux/config.h>
-#include <klibc/compiler.h>
#include <com32.h>
-
-#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
+#include <syslinux/pmapi.h>
char *getcwd(char *buf, size_t size)
{
- static com32sys_t reg;
- char *pwdstr, *ret;
-
- reg.eax.w[0] = 0x001f;
- __intcall(0x22, ®, ®);
- pwdstr = MK_PTR(reg.es, reg.ebx.w[0]);
- if ((strlen(pwdstr) < size) && (buf != NULL)) {
- strcpy(buf, pwdstr);
- ret = buf;
- } else {
- ret = NULL;
- errno = ERANGE;
- }
- return ret;
+ return __com32.cs_pm->getcwd(buf, size);
}
diff --git a/core/fs/getcwd.c b/core/fs/getcwd.c
new file mode 100644
index 0000000..a7b6c7a
--- /dev/null
+++ b/core/fs/getcwd.c
@@ -0,0 +1,13 @@
+#include <string.h>
+#include "fs.h"
+
+char *getcwd(char *buf, size_t size)
+{
+ char *ret = NULL;
+
+ if((buf != NULL) && (strlen(this_fs->cwd_name) < size)) {
+ strcpy(buf, this_fs->cwd_name);
+ ret = buf;
+ }
+ return ret;
+}
diff --git a/core/include/fs.h b/core/include/fs.h
index bb629c9..a01f998 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -202,6 +202,9 @@ DIR *opendir(const char *pathname);
struct dirent *readdir(DIR *dir);
int closedir(DIR *dir);
+/* getcwd.c */
+char *getcwd(char *buf, size_t size);
+
/*
* Generic functions that filesystem drivers may choose to use
*/
diff --git a/core/pmapi.c b/core/pmapi.c
index 18693d9..ff65533 100644
--- a/core/pmapi.c
+++ b/core/pmapi.c
@@ -36,4 +36,5 @@ const struct com32_pmapi pm_api_vector =
.reset_idle = reset_idle,
.chdir = chdir,
+ .getcwd = getcwd,
};
More information about the Syslinux-commits
mailing list