summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getcwd.c
Commit message (Collapse)AuthorAgeFilesLines
* Avoid a memory leak by using reallocf() instead of realloc().tjr2003-01-101-1/+1
|
* Prototype __getcwd() to avoid a warning.tjr2003-01-101-0/+2
|
* s/trailing NULL/trailing NUL/jmallett2002-08-191-1/+1
|
* * Remove 'register'. (some functions had 7+ register functions...)obrien2002-02-011-8/+8
| | | | * Fix SCM ID's.
* Remove _THREAD_SAFE and make libc thread-safe by default bydeischen2001-01-241-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch
* Remove the SIGSYS handler and wrapper around the __getcwd() syscall.peter2000-09-051-39/+10
| | | | | | | | 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
* Explicitly use sigemptyset to clear a sigset_t. Explicitmarcel1999-09-281-1/+4
| | | | | | initialization of sa_flags allows us to lose the bzero. $FreeBSD$ tag added.
* Replace memory leaking instances of realloc with non-leaking reallocf.imp1998-09-161-1/+1
| | | | | | | | | | | In some cases replace if (a == null) a = malloc(x); else a = realloc(a, x); with simple reallocf(a, x). Per ANSI-C, this is guaranteed to be the same thing. I've been running these on my system here w/o ill effects for some time. However, the CTM-express is at part 6 of 34 for the CAM changes, so I've not been able to do a build world with the CAM in the tree with these changes. Shouldn't impact anything, but...
* NetBSD doesn't have a __getcwd syscall, so set have__getcwd to `no'jb1998-05-151-0/+4
| | | | when building libc with NetBSD syscalls.
* Return the correct errno from getcwd() even if free() or closedir()mckay1998-01-151-0/+4
| | | | | | overwrites it. This actually showed up when running under an old kernel when free() called the madvise() stub which set errno, causing getcwd() to return EOPNOTSUPP instead of ERANGE.
* Put a system call not present checking wrapper around the call topeter1997-09-161-9/+35
| | | | | __getcwd(). I've got this libc code running on one of my machines at the moment without the __getcwd() syscall being present.
* Fix yet a minor stylistic nit from Bruce (Doesn't he have morephk1997-09-151-7/+9
| | | | | | important things to do ?? :-) Prepare for the likely case of a change in kernel algorithm.
* Fix a buglet and a couple of stylistic nits from Bruce.phk1997-09-151-3/+2
|
* Add __getcwd() syscall, and have getcwd() take a shot at it.phk1997-09-141-0/+11
| | | | | If your kernel doesn't support __getcwd() or if __getcwd() cannot deliver because of cache expiry, it does the canonical thing.
* Fixed file descriptor leak that occurs after certain types of failures.dg1997-08-151-2/+5
| | | | | PR: 3516 Submitted by: Matthew Flatt <mflatt@cs.rice.edu>
* Back out a dubious Lite2 change to "optimise" getcwd() to look at $PWDpeter1997-03-131-153/+0
| | | | | | | | because it's potentially dangerous (think: symlink races). Move realpath() back to it's original location, and remove getcwd_physical() by renaming it back to getcwd() and zapping the original getcwd wrapper. Noticed by: bde
* merge from Lite2 - realpath() now shares a lot of code with getcwd()peter1997-03-111-4/+158
| | | | and is now in the same file.
* Corrently null-terminate the path being passed to the opendir() calls,peter1996-10-171-0/+1
| | | | | | | malloc() does is not defined to return a zeroed buffer leading to "strange" problems. Submitted by: Karl Denninger <karl@mcs.com>, PR#1826
* General -Wall warning cleanup, part I.jkh1996-07-121-1/+1
| | | | Submitted-By: Kent Vander Velden <graphix@iastate.edu>
* Don't cast void functions to void.hsu1995-06-201-2/+2
| | | | Obtained from: NetBSD commit by jtc on June 16, 1995.
* Backed out Keith Bostic's getcwd/$PWD hack. It is causing things to breakdg1995-02-071-24/+5
| | | | all over the place.
* A cute hack to speed up things by Keith: if getenv("PWD") is the samephk1995-02-041-5/+24
| | | | | | | | inode as ".", then just return that. I added a check so it must start with a '/'. Reviewed by: phk Submitted by: bostic@cs.berkeley.edu (Keith Bostic)
* Obtained from: 1.1.5bde1994-12-121-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getcwd() has two off-by-one bugs in FreeBSD-2.0: 1. getcwd(buf, size) fails when the size is just large enough. 2. getcwd(buf + 1, 1) incorrectly succeeds when the current directory is "/". buf[0] and buf[2] are clobbered. (I modified Bruce's original patch to return the proper error code [ERANGE] in the case of #2, but otherwise... -DG) This program demonstrates the bug: --- #include <stdlib.h> #include <string.h> #include <stdio.h> #include <unistd.h> int main(void) { char buf[5]; int errors; errors = 0; if (chdir("/tmp") != 0) { perror("chdir"); abort(); } if (getcwd(buf, 5) == NULL) { perror("oops, getcwd failed for buffer size = size required"); ++errors; } if (chdir("/") != 0) { perror("chdir"); abort(); } buf[0] = 0; buf[2] = 1; if (getcwd(buf + 1, 1) != NULL) { fprintf(stderr, "oops, getcwd succeeded for buffer size = one too small\n"); ++errors; } if (buf[0] != 0) { fprintf(stderr, "oops, getcwd scribbled on memory before start of buffer\n"); ++errors; } if (buf[2] != 1) { fprintf(stderr, "oops, getcwd scribbled on memory after end of buffer\n"); ++errors; } exit(errors == 0 ? 0 : 1); }
* BSD 4.4 Lite Lib Sourcesrgrimes1994-05-271-0/+230
OpenPOWER on IntegriCloud