blob: 38fae52ab7db23551c4d00319da3facde21482b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*
* 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>
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;
}
|