diff options
author | phk <phk@FreeBSD.org> | 1997-09-14 16:57:27 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1997-09-14 16:57:27 +0000 |
commit | bb6f420228a605137ef8cdfee0a709b394004873 (patch) | |
tree | ec74fbb8fdc96d74ae3b8aaadada11901746686d /lib/libc/gen/getcwd.c | |
parent | b079abc11c97decabfeb4683ebd3561674cdf55d (diff) | |
download | FreeBSD-src-bb6f420228a605137ef8cdfee0a709b394004873.zip FreeBSD-src-bb6f420228a605137ef8cdfee0a709b394004873.tar.gz |
Add __getcwd() syscall, and have getcwd() take a shot at it.
If your kernel doesn't support __getcwd() or if __getcwd() cannot
deliver because of cache expiry, it does the canonical thing.
Diffstat (limited to 'lib/libc/gen/getcwd.c')
-rw-r--r-- | lib/libc/gen/getcwd.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c index 1593311..eb48b5a 100644 --- a/lib/libc/gen/getcwd.c +++ b/lib/libc/gen/getcwd.c @@ -89,6 +89,17 @@ getcwd(pt, size) return (NULL); ept = pt + ptsize; } + if (!__getcwd(pt,ptsize)) { + char c; + bpt = pt; + ept = pt + strlen(pt) - 1; + while (bpt < ept) { + c = *bpt; + *bpt++ = *ept; + *ept-- = c; + } + return (pt); + } bpt = ept - 1; *bpt = '\0'; |