Eric Blake [Tue, 6 Oct 2009 21:43:12 +0000 (15:43 -0600)]
mkdir, mkdirat: add tests
This test exposes failures on cygwin 1.5 and in our mkdirat emulation.
* modules/mkdir-tests: New test.
* tests/test-mkdir.h: New file.
* tests/test-mkdir.c: Likewise.
* tests/test-mkdirat.c: Likewise.
* modules/openat-tests (Files): Add new files.
(Makefile.am): Run new test.
Eric Blake [Tue, 6 Oct 2009 12:58:08 +0000 (06:58 -0600)]
fdopendir: fix GNU/Hurd bug
fdopendir(open("file",O_RDONLY)) mistakenly succeeded, with
subsequent readdir() failing with ENOTDIR.
* m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): Check for Hurd bug in
allowing non-directory fds.
* lib/fdopendir.c (rpl_fdopendir): Work around it.
* m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): New witness.
* modules/dirent (Makefile.am): Substitute it.
* lib/dirent.in.h (fdopendir): Declare replacement.
* doc/posix-functions/fdopendir.texi (fdopendir): Document this.
* tests/test-fdopendir.c (main): Test something other than
/dev/null, since on Hurd that behaves like a directory.
Eric Blake [Tue, 6 Oct 2009 20:29:13 +0000 (14:29 -0600)]
getopt-gnu: add another test
Ensure that POSIXLY_CORRECT does not interfere with optional argument
behavior; older BSD implementations botched this.
* tests/test-getopt_long.h (test_getopt_long_posix): New test, to
guarantee behavior relied on by m4.
* tests/test-getopt.c (main): Use it.
* modules/getopt-posix-tests (Depends-on): Add setenv.
See http://lists.gnu.org/archive/html/bug-m4/2006-09/msg00028.html.
Eric Blake [Wed, 7 Oct 2009 02:44:13 +0000 (20:44 -0600)]
getopt: fix compilation on darwin
* lib/getopt.in.h (includes): Leave breadcrumbs during system
include.
* lib/unistd.in.h (getopt): Use them to avoid recursive include.
Reported by Ludovic Courtès.
Eric Blake [Mon, 5 Oct 2009 23:17:34 +0000 (17:17 -0600)]
quotearg: port test to systems with C.UTF-8 locale
* tests/test-quotearg.c (struct result_strings): Add another
member, differentiating between C.ASCII and C.UTF-8 handling.
(compare_strings): Add parameter.
(main): Adjust all callers.
Eric Blake [Fri, 2 Oct 2009 18:05:02 +0000 (12:05 -0600)]
rename, fchdir: don't ignore chdir failure
Although we just checked that chdir(cwd) worked, there is a
race where it could disappear while we are temporarily away.
If that happens, forcefully give up rather than proceeding
in the wrong directory.
* lib/fchdir.c (get_name): Abort on unexpected chdir failure.
* lib/rename.c (rpl_rename) [W32]: Likewise.
(rpl_rename) [RENAME_DEST_EXISTS_BUG]: Avoid one case of losing
an empty destination directory if source cannot be renamed,
although there is still possibility for failure.
* doc/posix-functions/rename.texi (rename): Document the race.
Reported by Jim Meyering.
Eric Blake [Thu, 1 Oct 2009 22:46:08 +0000 (16:46 -0600)]
rename: fix mingw bugs
Copy various workarounds from cygwin 1.5: rename("dir/.","name"),
rename("dir","file"), rename("dir1","dir2"). Amazingly,
even though mingw stat() has no way to identify hard linked
files, and even though rename("hard1","hard2") destroys the
hard link, the lower-level MoveFileEx does the right thing!
Eric Blake [Thu, 1 Oct 2009 17:57:47 +0000 (11:57 -0600)]
rename: fix another cygwin 1.5 bug
Cygwin 1.5 sometimes, but not always, failed on rename("dir1","dir2")
when "dir2" exists. Beef up the m4 tests to more reliably
detect at least one of cygwin's bugs, in spite of not knowing
why the rename only failed sporadically (thankfully, cygwin 1.7
does not have the bug). Meanwhile, although NetBSD needs to
share the hard link workarounds, it does not need the trailing
dot and directory workarounds, so split the m4 test into two
separate feature checks.
* m4/rename.m4 (gl_FUNC_RENAME): Split cygwin bugs into two
checks.
* lib/rename.c (rpl_rename): Don't penalize NetBSD with
unnecessary cygwin workarounds. Also work around bug with moving
full directory onto an empty one.
* modules/rename (Depends-on): Add canonicalize-lgpl, rmdir.
Eric Blake [Sat, 26 Sep 2009 21:18:13 +0000 (15:18 -0600)]
rename-dest-slash: merge into rename module
Tested that NetBSD workaround still passes unit test.
* modules/rename-dest-slash (Status): Mark obsolete.
(Depends-on): Add rename.
(Files): Let rename do it all.
* m4/rename.m4 (gl_FUNC_RENAME): Also test for NetBSD bugs,
subsuming the test from gl_FUNC_RENAME_TRAILING_DEST_SLASH...
* m4/rename-dest-slash.m4: ...so this file can be deleted.
* lib/rename-dest-slash.c (rpl_rename_dest_slash): Delete.
* lib/rename.c (rpl_rename): Update comments.
Eric Blake [Tue, 29 Sep 2009 22:42:59 +0000 (16:42 -0600)]
rename: fix cygwin 1.5.x bugs
On cygwin 1.5.x, rename("dir","file") mistakenly succeeded.
rename("hard1","hard2") mistakenly reduced the hard link count,
such that "hard1" disappears once "hard2" is unlinked.
* m4/rename.m4 (gl_FUNC_RENAME): Detect cygwin bugs.
* lib/rename.c (rpl_rename): Work around them.
* modules/rename (Depends-on): Add same-inode.
Eric Blake [Thu, 1 Oct 2009 03:57:58 +0000 (21:57 -0600)]
rename: fix Solaris 10 bug
rename("file","name/") mistakenly succeeded. But since Solaris 10
already obeys POSIX behavior on rename("link/","name"), we avoid
blindly forcing GNU behavior of rejecting symlinks with trailing slash.
* m4/rename.m4 (gl_FUNC_RENAME): Detect Solaris bug.
* lib/rename.c (rpl_rename): Don't cripple POSIX behavior if this
was the only bug.
Eric Blake [Sat, 26 Sep 2009 23:22:15 +0000 (17:22 -0600)]
rename-tests: new test, exposes several platform bugs
This test passes on GNU/Linux, OpenBSD, and Cygwin 1.7.
Elsewhere, this test fails because of at least these bugs:
Solaris 10, cygwin 1.5.x, and mingw all mistakenly succeed on
rename("file","other/"). Solaris 9 and the gnulib replacement
for SunOS 4.1 mistakenly succeed on rename("file/","other").
Cygwin 1.5.x and mingw mistakenly succeed on rename("dir","d/.").
Cygwin 1.5.x and NetBSD 1.6 (even with the gnulib replacement)
mistakenly reduce the link count on rename("hard1","hard2").
* modules/rename-tests: New file.
* tests/test-rename.h: Likewise.
* tests/test-rename.c: Likewise.
* doc/posix-functions/rename.texi (rename): Improve documentation,
including bugs that will eventually be fixed in gnulib.
Jim Meyering [Fri, 2 Oct 2009 09:03:48 +0000 (11:03 +0200)]
gnu-web-doc-update: New module.
Use this script to automatically update the on-line web documentation
for your GNU project at http://www.gnu.org/software/$pkg/manual/
* modules/gnu-web-doc-update: New file.
* build-aux/gnu-web-doc-update: New script, from coreutils.
* MODULES.html.sh (Support for maintaining and releasing projects):
Add gnu-web-doc-update.
Eric Blake [Tue, 29 Sep 2009 17:40:49 +0000 (11:40 -0600)]
tests: tighten link, rmdir, and remove tests
Catch cygwin bug where rmdir("a/./") failed but rmdir("a/.//")
succeeded. Be kinder if a Solaris root user runs the test.
* tests/test-link.h (includes): No need to use <config.h> here.
Clean up if directory hard link was created, otherwise test for
trailing '.'.
* tests/test-linkat.c (main): Simplify.
* tests/test-remove.c (main): Enhance test for trailing '.'.
* tests/test-rmdir.h (test_rmdir_func): Likewise.
Jim Meyering [Thu, 1 Oct 2009 08:09:30 +0000 (10:09 +0200)]
maint.mk: requiring "make major" was annoying, for a "minor" release.
What is intended is "stable", to contrast with alpha and beta,
so require "make stable", not "make major".
* build-aux/announce-gen (%valid_release_types): s/major/stable/.
(get_tool_versions): Likewise.
* top/maint.mk (ALL_RECURSIVE_TARGETS): s/major/stable/
Eric Blake [Sun, 27 Sep 2009 02:09:38 +0000 (20:09 -0600)]
doc: mention yet more cygwin 1.7 status
* doc/posix-functions/fexecve.texi (fexecve): Now implemented in
cygwin.
* doc/glibc-functions/execvpe.texi (execvpe): New file.
* doc/gnulib.texi (Glibc unistd.h): Mention it.
Jim Meyering [Sun, 27 Sep 2009 06:41:55 +0000 (08:41 +0200)]
test-yesno: work around sparc-dash here-document infelicity
Without this change, the literal \177 byte in a here document
would make dash 0.5.5.1-3 access uninitialized memory.
* tests/test-yesno.sh: Don't put the \177 byte in the here document.
Instead, use a marker, "@", and filter through tr to create the desired
contents. Reported as <http://bugs.debian.org/548493> by Kurt Roeckx.
Eric Blake [Thu, 24 Sep 2009 16:57:14 +0000 (10:57 -0600)]
getopt: fix inclusion guards for cygwin
cygwin <unistd.h> includes <getopt.h>, but gnulib <getopt.h> includes
<unistd.h>, so system declarations were happening after gnulib
replacements, leading to multiply-defined rpl_readlink error on
cygwin 1.5. The solution is to ensure that the system <unistd.h>
is complete prior to any of gnulib's contents, by picking up
system <getopt.h> in preference to a cycle to <unistd.h>.
* modules/getopt-posix (Depends-on): Add include-next.
(Makefile.am): Substitute more items in replacement header.
* m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Also check for native
<getopt.h>.
* lib/getopt.in.h (includes): Use split inclusion guard, and
prefer <getopt.h> over include <unistd.h> when one is present.
(option): Also override name of 'struct option'.
Eric Blake [Wed, 9 Sep 2009 12:24:28 +0000 (06:24 -0600)]
dirname: add library-safe mdir_name
A library-safe dir_name is nice, especially alongside
mfile_name_concat. Someday, we should rearrange the .o
files so that linking in mdir_name does not suck in
xalloc_die, but for now, the only planned client of
mdir_name (at-func2) is already using xalloc_die.
* lib/dirname.h (mdir_name): New prototype.
* lib/dirname.c (dir_name): Move guts...
(mdir_name): ...to new function that avoids xalloc_die.
Eric Blake [Thu, 24 Sep 2009 02:33:40 +0000 (20:33 -0600)]
fchdir: another mingw fix
canonicalize_file_name does not understand drive letters or
backslash. The only reason openat required it was to make
fchdir get the canonical name of a directory. But we can do
the same trick with chdir and getcwd. With this fix,
fchdir(open("..",O_RDONLY)) finally does the right thing on mingw.
* modules/fchdir (Depends-on): Drop canonicalize-lgpl.
* lib/fchdir.c (get_name): New helper method; skips canonicalize
on mingw (where it has not yet been ported), and make it optional
elsewhere.
(_gl_register_fd): Use it.
Eric Blake [Wed, 23 Sep 2009 20:51:29 +0000 (14:51 -0600)]
same-inode: make SAME_INODE tri-state, to port to mingw
Mingw has the annoying habit (already documented in
doc/posix-functions/*stat) that st_ino is always 0.
This means that naive uses of SAME_INODE(a,b) would
succeed, even on distinct files.
Here's an analysis of all gnulib modules that used
the macro before this commit:
chdir-safer is safe - SAME_INODE protected by HAVE_READLINK
cycle-check - mingw has no dir hard links and no symlinks,
so no directory cycles can occur, and we should ignore -1
fts - SAME_INODE protected by FTS_DEBUG
hash-triple - using -1 gives more hash collisions, but
the results are still correct
openat-proc - SAME_INODE protected by stat("/proc/self")
same - no dir cycles, so files are only same with identical name
link-follow.m4 - configure test already correct on mingw
test-canonicalize* - test already passes on mingw
test-[l]stat - test already passes on mingw
* NEWS: Mention this change.
* lib/same-inode.h (same-inode.h): Recognize mingw limitation of
st_ino always being 0.
* lib/cycle-check.h (CYCLE_CHECK_REFLECT_CHDIR_UP): Update caller.
* lib/cycle-check.c (cycle_check): Likewise.
* lib/same.c (same_name): Likewise.
Eric Blake [Wed, 23 Sep 2009 20:13:00 +0000 (14:13 -0600)]
lstat: avoid mingw compilation error
The openat module required lstat, but then repeated the checks
for whether lstat worked. When cross-compiling to mingw, this
led to a wrong answer and tried compiling lstat.c, even though it
was not necessary, with a result of a compiler warning about
undeclared lstat.
* m4/lstat.m4 (gl_FUNC_LSTAT): Avoid duplicate calls to
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, and deal with missing
lstat ourselves.
* lib/lstat.c [!HAVE_LSTAT]: Do nothing if <sys/stat.h> override
was adequate.
* m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Let lstat module handle
the checks for lstat.
(gl_SYS_STAT_H_DEFAULTS): Set default for HAVE_LSTAT.
Eric Blake [Mon, 21 Sep 2009 20:40:20 +0000 (14:40 -0600)]
readlink: document portability issue with symlink length
Per comments in areadlink, ERANGE on a too-small buffer is
expected on some platforms; making the readlink module guarantee
GNU behavior of truncated contents is counter-productive, since
we would be duplicating areadlink to learn a-priori how large to
make the buffer, and since truncated contents are not as useful.
* doc/posix-functions/lstat.texi (lstat): Mention that some file
systems have bogus st_size on symlinks, and mention the
areadlink-with-size module.
* doc/posix-functions/fstatat.texi (fstatat): Likewise.
* doc/posix-functions/readlink.texi (readlink): Mention the
areadlink module, and ERANGE failure.
* doc/posix-functions/readlinkat.texi (readlinkat): Likewise.
* tests/test-readlink.c (main): Relax test for AIX, HP-UX.
Eric Blake [Tue, 22 Sep 2009 12:24:25 +0000 (06:24 -0600)]
link-follow: ensure correct result
* m4/fcntl_h.m4 (gl_FCNTL_H): Clean up temporary file.
* m4/link-follow.m4 (gl_FUNC_LINK_FOLLOWS_SYMLINK): Likewise, and
distinguish between possible failures.
Eric Blake [Wed, 16 Sep 2009 23:13:20 +0000 (17:13 -0600)]
unlink: new module, for Solaris 9 bug
unlink("file/") mistakenly succeeded. This patch favors, but
does not enforce, GNU semantics that unlink("link-to-dir/")
flat-out fails rather than attempting to unlink "dir".
Eric Blake [Thu, 17 Sep 2009 21:55:24 +0000 (15:55 -0600)]
lstat: fix Solaris 9 bug
lstat("file/",buf) mistakenly succeeded.
* lib/lstat.c (lstat): Also check for trailing slash on
non-symlink, non-directories. Use stat module to simplify logic.
* doc/posix-functions/lstat.texi (lstat): Document it.
* modules/lstat-tests (Depends-on): Add errno, same-inode.
(configure.ac): Check for symlink.
* tests/test-lstat.c (main): Add more tests.
Eric Blake [Tue, 15 Sep 2009 23:08:39 +0000 (17:08 -0600)]
stat: fix Solaris 9 bug
stat("file/",buf) mistakenly succeeded.
* m4/stat.m4 (gl_FUNC_STAT): Detect Solaris 9 bug with trailing
slash.
* lib/stat.c (rpl_stat): Work around it.
* doc/posix-functions/stat.texi (stat): Update documentation.