aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/getcwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/lib/getcwd.c')
-rw-r--r--com32/lib/getcwd.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/com32/lib/getcwd.c b/com32/lib/getcwd.c
new file mode 100644
index 00000000..95008bb2
--- /dev/null
+++ b/com32/lib/getcwd.c
@@ -0,0 +1,29 @@
+/*
+ * getcwd.c
+ */
+
+#include <syslinux/config.h>
+#include <klibc/compiler.h>
+#include <com32.h>
+
+#include <dirent.h>
+#include <stdio.h>
+#include <errno.h>
+
+char *getcwd(char *buf, size_t size)
+{
+ static com32sys_t reg;
+ char *pwdstr, *ret;
+
+ reg.eax.w[0] = 0x001f;
+ __intcall(0x22, &reg, &reg);
+ 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;
+}