diff options
author | peter <peter@FreeBSD.org> | 2000-09-05 09:35:36 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2000-09-05 09:35:36 +0000 |
commit | 459dd42211f73b6dd4a7eea0cac74bd3e5841455 (patch) | |
tree | aa910cff5b7ec92130653085fbf11c914dbf131b /lib/libc | |
parent | 64ac0aa678e382d03d7bad1b3c1401222e4bc7e7 (diff) | |
download | FreeBSD-src-459dd42211f73b6dd4a7eea0cac74bd3e5841455.zip FreeBSD-src-459dd42211f73b6dd4a7eea0cac74bd3e5841455.tar.gz |
Remove the SIGSYS handler and wrapper around the __getcwd() syscall.
It was kinda silly since the sigaction() syscall that it used to setup
the handler is more recent than __getcwd(), therefore it was useless
as the wrapper would have died before even getting as far as __getcwd(2).
Reminded by: bde
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/getcwd.c | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c index 9b1ccf3..e2ea820 100644 --- a/lib/libc/gen/getcwd.c +++ b/lib/libc/gen/getcwd.c @@ -47,14 +47,11 @@ static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95"; #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <signal.h> #define ISDOT(dp) \ (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \ (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) -static int have__getcwd = 1; /* 0 = no, 1 = perhaps, 2 = yes */ - char * getcwd(pt, size) char *pt; @@ -94,44 +91,18 @@ getcwd(pt, size) return (NULL); ept = pt + ptsize; } -#if defined(__NETBSD_SYSCALLS) - have__getcwd = 0; -#else - if (have__getcwd) { - struct sigaction sa, osa; - int sigsys_installed = 0; - int ret; - - if (have__getcwd == 1) { /* unsure? */ - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sa.sa_handler = SIG_IGN; - if (sigaction(SIGSYS, &sa, &osa) >= 0) - sigsys_installed = 1; - } - ret = __getcwd(pt, ept - pt); - if (sigsys_installed == 1) { - int oerrno = errno; - sigaction(SIGSYS, &osa, NULL); - errno = oerrno; - } - /* XXX a bogus syscall seems to return EINVAL(!) */ - if (ret < 0 && (errno == ENOSYS || errno == EINVAL)) - have__getcwd = 0; - else if (have__getcwd == 1) - have__getcwd = 2; /* yep, remember we have it */ - if (ret == 0) { - if (*pt != '/') { - bpt = pt; - ept = pt + strlen(pt) - 1; - while (bpt < ept) { - c = *bpt; - *bpt++ = *ept; - *ept-- = c; - } +#if !defined(__NETBSD_SYSCALLS) + if (__getcwd(pt, ept - pt) == 0) { + if (*pt != '/') { + bpt = pt; + ept = pt + strlen(pt) - 1; + while (bpt < ept) { + c = *bpt; + *bpt++ = *ept; + *ept-- = c; } - return (pt); } + return (pt); } #endif bpt = ept - 1; |