Commit Graph

3957 Commits

Author SHA1 Message Date
Paul Eggert fcf37d8842 Recent changes to save-cwd, openat. 2004-12-03 07:13:31 +00:00
Paul Eggert f125837030 Import from gnulib. 2004-12-03 07:10:19 +00:00
Paul Eggert dddbfd198a Add copyright and authorship notice.
(AT_FDCWD): Use the same value Solaris 9 uses.
2004-12-03 06:44:30 +00:00
Paul Eggert d2117d918c Include "openat.h" before other include files.
Include "exitfail.h".
(openat): Remove #undef; no longer needed now that we include openat.h first.
(rpl_openat): Add comment about mode_t promotion.  Simplify
code a bit by moving initializations around.  Use exit_failure
rather than EXIT_FAILURE.
2004-12-03 06:43:59 +00:00
Paul Eggert f2173447ba save-cwd.c: Include "save-cwd.h" before other include files.
(O_DIRECTORY): Remove; not needed here, since "." must be
a directory.  All uses removed.
(save_cwd): Use __sgi || __sun, not sun || __sun.  __sun is
universal on Suns, and we also need to test for IRIX.
Revamp code to use 'if' rather than '#if'.
Avoid unnecessary comparison of cwd->desc to 0.
2004-12-03 06:25:03 +00:00
Paul Eggert a7c9d8dae8 Assume setlocale, locale.h, and localeconv exist and work. 2004-12-02 06:57:05 +00:00
Paul Eggert 08da1bb439 Assume <locale.h> exists.
(human_readable): Assume localeconv exists.
2004-12-02 06:52:10 +00:00
Paul Eggert 2dea4ec8b0 Assume <locale.h> exists.
Include "strdup.h".
(GLIBC_VERSION): New macro.
(hard_locale): Assume setlocale exists.
Rewrite to avoid #ifdef.
Use strdup rather than malloc + strcpy.
2004-12-02 06:51:46 +00:00
Paul Eggert 02496d03b5 * getcwd.c: Use system getcwd first, if appropriate. 2004-12-01 07:13:35 +00:00
Paul Eggert 3b8fa2ba33 (is_ENAMETOOLONG): New macro.
(__getcwd.c): Don't restore errno; glibc doesn't.
[HAVE_PARTLY_WORKING_GETCWD && !defined AT_FDCWD]: Try system getcwd
first, falling back to our code only if its results look suspicious.
Ensure that the resulting buffer is only as large as necessary.
2004-12-01 07:12:14 +00:00
Paul Eggert 52a0364803 Go back to including <sys/types.h> rather than <stddef.h>; this is
needed on OpenBSD since its <utmp.h> needs time_t without making sure
that time_t is defined.
2004-12-01 07:07:38 +00:00
Paul Eggert 525e6c12c3 Make readutmp more consistent among its client code. 2004-11-30 21:41:31 +00:00
Paul Eggert fa60e4cb6f Don't include <sys/types.h>, <errno.h>,
<sys/param.h>, <time.h>; not needed to establish interface.
Include <stddef.h> instead.
(errno): Remove decl.
(HAVE_STRUCT_XTMP_UT_TYPE): Remove; no longer needed.
(UT_TYPE_EQ, UT_TYPE_NOT_DEFINED, UT_TYPE_BOOT_TIME,
UT_TYPE_USER_PROCESS, IS_USER_PROCESS): New macros.
2004-11-30 21:39:46 +00:00
Paul Eggert 8f7cca3d72 Include readutmp.h first.
Include <errno.h>, since readutmp.h no longer does that.
2004-11-30 21:39:26 +00:00
Jim Meyering 943f676c01 . 2004-11-30 14:48:02 +00:00
Jim Meyering e9725a701a renamed to chdir-long.[ch] 2004-11-30 14:47:47 +00:00
Jim Meyering a4304d4187 *** empty log message *** 2004-11-30 14:47:16 +00:00
Jim Meyering de39e47a40 (libfetish_a_SOURCES): Reflect name changes: chdir.[ch] -> chdir-long.[ch] 2004-11-30 14:47:08 +00:00
Jim Meyering e7acb8d8dd Include chdir-long.h rather than chdir.h.
(restore_cwd): Use chdir_long, not chdir.
2004-11-30 14:46:25 +00:00
Jim Meyering 34a8030d36 *** empty log message *** 2004-11-30 14:46:09 +00:00
Jim Meyering 8f3175736e [!defined PATH_MAX]: Define chdir_long to chdir on systems like the Hurd. 2004-11-30 14:45:28 +00:00
Jim Meyering 86c716db61 Renamed from chdir.h. 2004-11-30 14:35:46 +00:00
Jim Meyering 036728c2e8 Renamed from chdir.c. 2004-11-30 14:35:33 +00:00
Jim Meyering 2a807da972 *** empty log message *** 2004-11-30 14:24:55 +00:00
Jim Meyering d70691fc4b (O_DIRECTORY): Define, if necessary.
(memchrcspn): Tiny wrapper around memchr.
(rpl_chdir): Use memchrcspn rather than strcspn.
2004-11-30 14:24:40 +00:00
Jim Meyering f76c6fa030 *** empty log message *** 2004-11-28 22:43:11 +00:00
Jim Meyering 98be5b6685 (rpl_openat): Also accept optional mode parameter.
Adjust prototype
2004-11-28 22:42:08 +00:00
Jim Meyering 26b53ffffe (rpl_openat): Also accept optional mode parameter. 2004-11-28 22:41:57 +00:00
Jim Meyering fd6af25d9a Don't let error uses in #if-0'd code trigger `make distcheck' failure. 2004-11-28 22:24:38 +00:00
Jim Meyering c272386d5d (main): Appease the gods. 2004-11-28 21:29:16 +00:00
Jim Meyering b69fc7b949 *** empty log message *** 2004-11-28 21:13:59 +00:00
Jim Meyering bb4833e756 *** empty log message *** 2004-11-28 21:03:13 +00:00
Jim Meyering f039b8f8bf Include "chdir.h", so that if save_cwd/getcwd
saves a name longer than PATH_MAX, restore_cwd's chdir can use it.
2004-11-28 21:03:08 +00:00
Jim Meyering a67e741070 . 2004-11-28 20:52:04 +00:00
Jim Meyering 77eb2b6b8a *** empty log message *** 2004-11-28 20:51:57 +00:00
Jim Meyering d91b876d72 (libfetish_a_SOURCES): Add chdir.h and openat.h. 2004-11-28 20:51:46 +00:00
Jim Meyering fa871415f9 *** empty log message *** 2004-11-28 20:51:05 +00:00
Jim Meyering 79e2f2c1f9 *** empty log message *** 2004-11-28 20:50:26 +00:00
Jim Meyering 30df68dfe2 This is a robust version of chdir, in that it can handle directory
names longer than PATH_MAX.
2004-11-28 20:49:14 +00:00
Jim Meyering c373cdcf61 add another FIXME, to make it obvious 2004-11-28 20:49:04 +00:00
Jim Meyering 72287ac271 This is a robust version of chdir, in that it can handle directory
names longer than PATH_MAX.
2004-11-28 20:48:29 +00:00
Paul Eggert 6942c45d50 Regenerate. 2004-11-26 08:11:52 +00:00
Paul Eggert 03a690ddca Fix problems reported by Scott S. Tinsley for HP-UX 11.11 using
HP's ANSI C compiler.
2004-11-26 07:40:56 +00:00
Paul Eggert da741f89bd (MIN) [defined MIN]: Don't define, since it's already defined. 2004-11-26 07:40:41 +00:00
Paul Eggert cc08c826e9 (statvfs) [HAVE_SYS_STATVFS_H]: Remove decl.
Declaring int functions causes warnings on some modern systems and
shouldn't be needed to compile on ancient ones.
2004-11-26 07:40:23 +00:00
Paul Eggert 9c8b155e38 filesystems -> file systems 2004-11-26 07:27:45 +00:00
Paul Eggert a7fab534e4 Recent getcwd fixes. 2004-11-25 20:05:15 +00:00
Paul Eggert 639d4a42b7 David MacKenzie's old code was removed, so give
credit only to Jim Meyering and adjust the copyright dates.
Do not include <limits.h>, <stdio.h>, <sys/types.h>,
<stdlib.h>, <unistd.h>, "pathmax.h".
Instead, include "xgetcwd.h" (first) and "getcwd.h".
(INITIAL_BUFFER_SIZE): Remove.
(xgetcwd): Rely on getcwd, since we now depend on a reliable one.
2004-11-25 19:25:07 +00:00
Paul Eggert 69790900a4 Replace by a copy of glibc/sysdeps/posix/getcwd.c, but
with the following changes.
(__set_errno): Parenthesize properly.
Include <stdbool.h>.
(MIN, MAX, MATCHING_INO): New macros.
(__getcwd): Define with prototype, not K&R form.
Use heuristics to allocate default buffer on stack if possible.
If AT_FDCWD is defined, use openat and fstatat to avoid O(N**2)
behavior, and to avoid the PATH_MAX limit when computing
../../../../...
Use MATCHING_INO to compare inode number to file.
Check for arithmetic overflow in size calculations.
Fix bug in reallocation of dot array that caused getcwd to fail
on directories nested deeper than 75.
Be more careful about saving errno on error.
Do not use realloc; use only free+malloc, as this is a bit
more flexible and avoids a needless copy operation.
Do not inspect st_dev and st_ino for symbolic links; POSIX
doesn't specify the latter.
Check for closedir errors.
Avoid needless casts.
Use "#ifdef weak_alias" around weak_alias, to be like other
glibc code.
The following changes to getcwd.c have effect only when used in
gnulib; they have no effect inside glibc proper.
(#pragma alloca) [defined _AIX && !defined __GNUC__]: Remove,
as alloca isn't used.
(alloca, __alloca): Likewise.
[!_LIBC]: Include "getcwd.h", "mempcpy.h".
Include <stddef.h>, <stdlib.h>, <string.h>, <limits.h>
unconditionally, as gnulib assumes C89 or better.
Do not include <sys/param.h>.
(errno) [!defined __GNU_LIBRARY__ && !defined STDC_HEADERS]: Remove
no-longer-necessary 'extern int errno' decl; gnulib assumes C89 or
better.
(NULL) [!defined NULL]: Remove; we assume C89 or better.
Include <dirent.h> in a way that is compatible with modern Autoconf.
(_D_ALLOC_NAMELEN, _D_EXACT_NAMLEN):
New macros, if not already defined.
Include <unistd.h> if _LIBC, not if __GNU_LIBRARY__.
Use "_LIBC", not "defined _LIBC", for consistency.
(HAVE_MEMPCPY): Remove; no longer needed now that gnulib has
a mempcpy module.
(__lstat, __closedir, __opendir, __readdir) [!_LIBC]: New macros.
(GETCWD_RETURN_TYPE): Remove.  All uses replaced by char *.
2004-11-25 19:23:32 +00:00
Paul Eggert 4396b05c13 (libfetish_a_SOURCES): Add getcwd.h, mempcpy.h. 2004-11-25 19:20:13 +00:00