Bruno Haible [Sun, 18 Sep 2011 08:34:24 +0000 (10:34 +0200)]
dup2: Support for MSVC.
* lib/dup2.c: Include msvc-inval.h.
(rpl_dup2): Handle invalid parameter notifications during dup2 and
_get_osfhandle calls.
* modules/dup2 (Depends-on): Add msvc-inval.
* doc/posix-functions/dup2.texi: Mention problem on MSVC.
Bruno Haible [Sat, 17 Sep 2011 16:28:17 +0000 (18:28 +0200)]
popen: Support for MSVC.
* lib/stdio.in.h (popen): Declare it if the system lacks this function.
* lib/popen.c (popen): Provide alternate definition for native Windows.
* m4/popen.m4 (gl_FUNC_POPEN): Test if popen exists. Set HAVE_POPEN.
* m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Initialize HAVE_POPEN.
* modules/popen (Depends-on, configure.ac): Update condition.
* modules/stdio (Makefile.am): Substitute HAVE_POPEN.
* doc/posix-functions/popen.texi: Mention that the MSVC problem is
fixed.
Bruno Haible [Sat, 17 Sep 2011 13:09:53 +0000 (15:09 +0200)]
inet_pton: Support for MSVC on Windows Vista or newer.
* lib/arpa_inet.in.h (inet_pton): Also consider REPLACE_INET_PTON.
* lib/inet_pton.c (rpl_inet_pton): Use a simple wrapper if
HAVE_DECL_INET_PTON is defined.
* m4/inet_pton.m4 (gl_FUNC_INET_PTON): Invoke gl_PREREQ_SYS_H_WINSOCK2.
On platforms with <winsock2.h>, test whether inet_pton is declared in
<ws2tcpip.h>. If so, arrange to replace it.
* m4/arpa_inet_h.m4 (gl_ARPA_INET_H_DEFAULTS): Initialize
REPLACE_INET_PTON.
* modules/arpa_inet (Makefile.am): Substitute REPLACE_INET_PTON.
* modules/inet_pton (Files): Add m4/sys_socket_h.m4.
(Depends-on, configure.ac): Update condition.
* doc/posix-functions/inet_pton.texi: Mention the MSVC problem.
Bruno Haible [Sat, 17 Sep 2011 12:56:11 +0000 (14:56 +0200)]
inet_ntop: Support for MSVC on Windows Vista or newer.
* lib/arpa_inet.in.h (inet_ntop): Also consider REPLACE_INET_NTOP.
* lib/inet_ntop.c (rpl_inet_ntop): Use a simple wrapper if
HAVE_DECL_INET_NTOP is defined.
* m4/inet_ntop.m4 (gl_FUNC_INET_NTOP): Invoke gl_PREREQ_SYS_H_WINSOCK2.
On platforms with <winsock2.h>, test whether inet_ntop is declared in
<ws2tcpip.h>. If so, arrange to replace it.
* m4/arpa_inet_h.m4 (gl_ARPA_INET_H_DEFAULTS): Initialize
REPLACE_INET_NTOP.
* modules/arpa_inet (Makefile.am): Substitute REPLACE_INET_NTOP.
* modules/inet_ntop (Files): Add m4/sys_socket_h.m4.
(Depends-on, configure.ac): Update condition.
* doc/posix-functions/inet_ntop.texi: Mention the MSVC problem.
Bruno Haible [Fri, 16 Sep 2011 21:17:49 +0000 (23:17 +0200)]
sys_stat: Support for MSVC.
* lib/sys_stat.in.h (S_IFIFO): Define to _S_IFIFO if that exists.
* tests/test-sys_stat.c: Don't assume that S_IFBLK exists.
* doc/posix-headers/sys_stat.texi: Mention missing S_IFIFO, S_IFBLK on
MSVC.
Eric Blake [Fri, 16 Sep 2011 20:12:01 +0000 (14:12 -0600)]
fdatasync: port to Solaris
Cater to Solaris requiring extra libraries for fdatasync.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Set LIB_FDATASYNC.
* modules/fdatasync (Link): Document it.
* modules/fdatasync-tests (test_fdatasync_LDADD): Link with it.
Eric Blake [Fri, 16 Sep 2011 19:49:16 +0000 (13:49 -0600)]
fdatasync: port to MacOS X 10.7
MacOS X 10.7 added an fdatasync syscall and exports a symbol for it,
but fails to declare it anywhere. Lacking any hard evidence that this
syscall is broken, we will just provide the declaration and use it.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Check for present but not
declared.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Another default.
* modules/unistd (Makefile.am): Substitute it.
* lib/unistd.in.h (fdatasync): Declare on MacOS.
* doc/posix-functions/fdatasync.texi (fdatasync): Document it.
Eric Blake [Fri, 16 Sep 2011 18:12:41 +0000 (12:12 -0600)]
unistd: update refs to newer POSIX
usleep only exists in POSIX 2001, but for the rest of the functions
where we pointed to online POSIX specs, we might as well point to the
latest version of the standard.
* lib/unistd.in.h: Prefer POSIX 2008 over 2001.
Suggested by Bruno Haible.
Eric Blake [Fri, 16 Sep 2011 15:59:23 +0000 (09:59 -0600)]
fdatasync: new module
At least libvirt would like to use the lighter-weight fdatasync
on platforms where it is supported, while still guaranteeing full
sync (via the heavy-weight fsync fallback) on all platforms.
I've got an open question to the Austin Group, since the POSIX 2008
wording is self-contradictory (unlike fsync, fdatasync requires
EBADF on non-writable fds, but still mentions that read() errors
must be propagated). I can see how fsync() would affect atime after
read() while fdatasync() can skip that, explaining why fdatasync()
might have the EBADF requirement, but on the other hand, that prevents
an implementation (like ours) where fdatasync is a straight alias of
fsync. At any rate, glibc allows fdatasync on read-only fds.
* modules/fsync (Description): Document difference to fdatasync.
* modules/fdatasync: New module.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): New file.
* lib/fdatasync.c (fdatasync): Likewise.
* m4/unistd_h.m4 (gl_UNISTD_H, gl_UNISTD_H_DEFAULTS): Set up
defaults.
* modules/unistd (Makefile.am): Set witnesses.
* lib/unistd.in.h (fdatasync): Declare.
* MODULES.html.sh: Document it.
* doc/posix-functions/fdatasync.texi (fdatasync): Likewise.
* modules/fdatasync-tests: New test.
* tests/test-fdatasync.c: Likewise.
Bruno Haible [Wed, 14 Sep 2011 23:00:17 +0000 (01:00 +0200)]
Avoid using #, the m4 comment starter character, near brackets.
* m4/absolute-header.m4 (gl_ABSOLUTE_HEADER_ONE): Use |, not #, as
delimiter character in sed expressions.
* m4/include_next.m4 (gl_NEXT_HEADERS_INTERNAL): Likewise.
Suggested by Eric Blake.
Bruno Haible [Wed, 14 Sep 2011 00:08:36 +0000 (02:08 +0200)]
sys_time: Support for MSVC.
* m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_BODY): Invoke
gl_PREREQ_SYS_H_WINSOCK2. When testing for 'struct timeval', also
include <winsock2.h>.
* lib/sys_time.in.h: On MSVC, include <winsock2.h> and hide its
function declarations that collide with POSIX.
* modules/sys_time (Files): Add m4/sys_socket_h.m4.
(Makefile.am): Substitute HAVE_WINSOCK2_H.
Bruno Haible [Sun, 11 Sep 2011 19:44:32 +0000 (21:44 +0200)]
unistd et al.: Don't assume <unistd.h> exists.
* m4/chdir-long.m4 (gl_FUNC_CHDIR_LONG): Don't include <unistd.h> if it
does not exist.
* m4/environ.m4 (gl_ENVIRON): Don't include <unistd.h> if it does not
exist. But include <stdlib.h>.
* m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): If <unistd.h> does not exist,
include <io.h> and <stdlib.h> instead. Don't test symbolink links if
symlink() does not exist.
* m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): If <unistd.h> does not exist,
include <io.h> instead.
* m4/free.m4 (gl_FUNC_FREE): Assume free(NULL) works on native Windows.
* m4/getcwd.m4 (gl_FUNC_GETCWD_NULL): If <unistd.h> does not exist,
include <direct.h> instead.
* m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Likewise.
* m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): Likewise.
* m4/lseek.m4 (gl_FUNC_LSEEK): If <unistd.h> does not exist, include
<io.h> instead.
* m4/rename.m4 (gl_FUNC_RENAME): Assume rename() manages hard links
correctly if the system does not have hard links.
* m4/rmdir.m4 (gl_FUNC_RMDIR): If <unistd.h> does not exist, include
<direct.h> instead.
* m4/unistd_h.m4 (gl_UNISTD_H): If <unistd.h> does not exist, bypass
it when looking for function declarations.
* m4/unlink.m4 (gl_FUNC_UNLINK): If <unistd.h> does not exist, include
<direct.h> and <io.h> instead.
* doc/posix-headers/unistd.texi: More details about MSVC problem.
Bruno Haible [Sun, 11 Sep 2011 19:15:40 +0000 (21:15 +0200)]
strings: Don't assume <strings.h> exists.
* lib/strings.in.h: Include <strings.h> only if HAVE_STRINGS_H is 1.
* m4/strings_h.m4 (gl_HEADER_STRINGS_H_BODY): Set HAVE_STRINGS_H.
* modules/strings (Makefile.am): Substitute HAVE_STRINGS_H.
* doc/posix-headers/strings.texi: Mention the MSVC problem.
Bruno Haible [Sun, 11 Sep 2011 19:11:58 +0000 (21:11 +0200)]
dirent: Don't assume <dirent.h> exists.
* lib/dirent.in.h: Include <dirent.h> only if HAVE_DIRENT_H is 1.
* m4/dirent_h.m4 (gl_DIRENT_H): Set HAVE_DIRENT_H.
* modules/dirent (Makefile.am): Substitute HAVE_DIRENT_H.
* doc/posix-headers/dirent.texi: Mention the MSVC problem.
Bruno Haible [Sun, 11 Sep 2011 18:47:03 +0000 (20:47 +0200)]
Fix wint_t on MSVC.
* lib/wchar.in.h (wint_t): On MSVC, override it.
* lib/wctype.in.h (wint_t): Likewise.
* m4/stdint.m4 (gl_STDINT_TYPE_PROPERTIES): Override BITSIZEOF_WINT_T on
MSVC.
* doc/posix-headers/wchar.texi: Mention the problem with wint_t on MSVC.
* doc/posix-headers/wctype.texi: Likewise.
Bruno Haible [Sun, 11 Sep 2011 16:14:00 +0000 (18:14 +0200)]
New module 'sys_types'.
* lib/sys_types.in.h: New file.
* m4/sys_types_h.m4: New file.
* modules/sys_types: New file.
* doc/posix-headers/sys_types.texi: Mention the new module and the
size_t problem on MSVC 9.
Bruno Haible [Sun, 11 Sep 2011 09:56:35 +0000 (11:56 +0200)]
acl: Fix compilation on Solaris 10 (older version).
* lib/file-has-acl.c (acl_ace_nontrivial): Use NEW_ACE_EVERYONE instead
of ACE_EVERYONE.
* lib/set-mode-acl.c (qset_acl): Likewise.
Reported by Christian Jullien <eligis@orange.fr>.
Bruno Haible [Sat, 10 Sep 2011 09:35:17 +0000 (11:35 +0200)]
absolute-header, include-next: Add support for MSVC compiler.
* m4/absolute-header.m4 (gl_ABSOLUTE_HEADER_ONE): Require
AC_CANONICAL_HOST. On native Windows, recognize also backslash as
directory separator in #line directives.
* m4/include_next.m4 (gl_NEXT_HEADERS_INTERNAL): On native Windows,
recognize also backslash as directory separator in #line directives.
Bruno Haible [Thu, 8 Sep 2011 09:58:44 +0000 (11:58 +0200)]
Doc about crypt functions.
* doc/posix-functions/crypt.texi: Mention need for _GNU_SOURCE on glibc
systems.
* doc/posix-functions/encrypt.texi: Likewise.
* doc/posix-functions/setkey.texi: Likewise.
Bruno Haible [Wed, 7 Sep 2011 22:03:50 +0000 (00:03 +0200)]
openat: Work around compilation error with OSF/1 5.1 DTK cc.
* lib/fopen.c: Use different syntax for include of <stdio.h>.
* lib/freopen.c: Likewise.
* lib/fstatat.c: Use different syntax for include of <sys/stat.h>.
* lib/lstat.c: Likewise.
* lib/stat.c: Likewise.
* lib/open.c: Use different syntax for include of <fcntl.h>.
* lib/openat.c: Include fcntl.h again, explicitly.
Bruno Haible [Tue, 6 Sep 2011 08:38:52 +0000 (10:38 +0200)]
acl: Fix a test failure on IRIX 6.5 with NFS.
* lib/acl-internal.h (MODE_INSIDE_ACL): Define to 0 on IRIX.
* lib/set-mode-acl.c (qset_acl): Test !HAVE_ACL_TYPE_EXTENDED instead
of MODE_INSIDE_ACL. If !MODE_INSIDE_ACL, do a chmod_or_fchmod always.
* lib/copy-acl.c (qcopy_acl): Likewise.
Paul Eggert [Tue, 6 Sep 2011 00:40:58 +0000 (17:40 -0700)]
openat: port to AIX 7.1 with large files
AIX 7.1 does a "#define openat open64at" if large files are in use,
so we can't simply #undef openat. Use the orig_openat trick (similar
to orig_open in lib/open.c) to work around the problem. Problem
reported by Kevin Brott for GNU tar, in the thread containing
<http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00032.html>.
* lib/openat.c (__need_system_fcntl_h): Define first.
Include <fcntl.h> and <sys/types.h> before undefining.
(orig_openat) [HAVE_OPENAT]: New inline function.
(openat) [HAVE_OPENAT]: Do not undef.
(rpl_openat): Use orig_openat, not openat.
Bruno Haible [Mon, 5 Sep 2011 21:45:11 +0000 (23:45 +0200)]
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
* lib/acl-internal.h (acl_nontrivial): Declare also on newer Solaris
10.
* lib/file-has-acl.c (acl_nontrivial): Define also on newer Solaris 10.
(acl_ace_nontrivial): Likewise. Recognize the trivial ACLs with 6 ACEs.
* lib/copy-acl.c (qcopy_acl): On newer Solaris 10, use acl or facl
instead of acl_get, facl_get, acl_set, facl_set.
Bruno Haible [Mon, 5 Sep 2011 09:25:09 +0000 (11:25 +0200)]
copy-file: Try unit tests on more file systems.
* tests/test-copy-file-1.sh: New file.
* tests/test-copy-file-2.sh: New file.
* modules/copy-file-tests (Files): Add them.
(Makefile.am): Add them to TESTS.
Bruno Haible [Mon, 5 Sep 2011 09:23:55 +0000 (11:23 +0200)]
acl: Try unit tests on more file systems.
* tests/test-file-has-acl-1.sh: New file.
* tests/test-file-has-acl-2.sh: New file.
* tests/test-set-mode-acl-1.sh: New file.
* tests/test-set-mode-acl-2.sh: New file.
* tests/test-copy-acl-1.sh: New file.
* tests/test-copy-acl-2.sh: New file.
* modules/acl-tests (Files): Add them.
(Makefile.am): Add them to TESTS.
Bruno Haible [Sun, 4 Sep 2011 22:44:13 +0000 (00:44 +0200)]
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
* lib/acl-internal.h (ACE_*, NEW_ACE_*): Define also on newer Solaris
10.
(OLD_ALLOW, OLD_DENY): New macros.
(NEW_ACE_ACCESS_ALLOWED_ACE_TYPE): Renamed from
ACE_ACCESS_ALLOWED_ACE_TYPE.
(NEW_ACE_ACCESS_DENIED_ACE_TYPE): Renamed from
ACE_ACCESS_DENIED_ACE_TYPE.
(OLD_ACE_OWNER, OLD_ACE_GROUP, OLD_ACE_OTHER): New macros.
(NEW_ACE_EXECUTE): Fix value.
(NEW_ACE_APPEND_DATA, NEW_ACE_READ_NAMED_ATTRS,
NEW_ACE_WRITE_NAMED_ATTRS, NEW_ACE_DELETE_CHILD,
NEW_ACE_READ_ATTRIBUTES, NEW_ACE_WRITE_ATTRIBUTES, NEW_ACE_DELETE,
NEW_ACE_READ_ACL, NEW_ACE_WRITE_ACL, NEW_ACE_WRITE_OWNER,
NEW_ACE_SYNCHRONIZE): New macros.
* lib/set-mode-acl.c (qset_acl): On newer Solaris 10, use acl or facl
instead of acl_fromtext, acl_set, facl_set.
Fixes a coreutils/tests/cp/perm failure.
Paul Eggert [Sun, 4 Sep 2011 03:17:33 +0000 (20:17 -0700)]
openat: test for fstatat (..., 0) bug
Further testing with tar suggests that fstatat (..., 0)
does not work in general, on AIX 7.1; see
<http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00023.html>.
So, give up entirely on AIX 7.1's fstatat, and fall back on our
replacement fstatat (which is what older AIX releases were using
anyway).
* lib/fstatat.c (fstatat) [HAVE_FSTATAT]: Do not undef. The only
use is now changed to orig_fstatat. This was probably the right
thing to do anyway.
(FSTATAT_AT_FDCWD_0_BROKEN): Remove; no longer used.
(rpl_fstatat) [FSTATAT_ZERO_FLAG_BROKEN]: Remove.
(rpl_fstatat): Simplify, assuming !FSTATAT_ZERO_FLAG_BROKEN.
(AT_FUNC_NAME) [FSTATAT_ZERO_FLAG_BROKEN]: Now rpl_fstatat.
* m4/openat.m4 (gl_FUNC_FSTATAT): Test for the more-general bug
and define FSTATAT_ZERO_FLAG_BROKEN, not FSTATAT_AT_FDCWD_0_BROKEN,
if the bug is found.
Paul Eggert [Sat, 3 Sep 2011 17:03:22 +0000 (10:03 -0700)]
openat: test for fstatat (AT_FDCWD, ..., 0) bug
This tests for another fstatat bug on AIX 7.1:
fstatat (AT_FDCWD, ..., 0) does not work. See
<http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00015.html>.
* lib/fstatat.c (FSTATAT_AT_FDCWD_0_BROKEN)
(LSTAT_FOLLOWS_SLASHED_SYMLINK): Default to 0.
(rpl_fstatat): Adjust so that it works around either (or both)
bugs if present.
* m4/openat.m4 (gl_FUNC_FSTATAT): Test for this fstatat bug.
Bruno Haible [Fri, 2 Sep 2011 12:13:59 +0000 (14:13 +0200)]
tests: init.sh: work also with any non-GNU diff that supports -u
* tests/init.sh: Relax check for diff -u support.
Rather than checking for GNU diff via --version, simply check
for support for -u itself. Useful at least on OpenBSD 4.9,
AIX 7.1, IRIX 6.5 and Solaris 10.
Bruno Haible [Thu, 1 Sep 2011 23:36:31 +0000 (01:36 +0200)]
strtoumax: Avoid link error on OSF/1 with DTK cc.
* m4/strtoumax.m4 (gl_FUNC_STRTOUMAX): Always test whether strtoumax is
defined as a function.
* modules/strtoumax (Depends-on, configure.ac): Test only whether
strtoumax is defined, not whether it is declared.
Bruno Haible [Thu, 1 Sep 2011 23:35:53 +0000 (01:35 +0200)]
strtoimax: Avoid link error on OSF/1 with DTK cc.
* m4/strtoimax.m4 (gl_FUNC_STRTOIMAX): Always test whether strtoimax is
defined as a function.
* modules/strtoimax (Depends-on, configure.ac): Test only whether
strtoimax is defined, not whether it is declared.
Bruno Haible [Thu, 1 Sep 2011 23:33:11 +0000 (01:33 +0200)]
imaxdiv: Avoid link error on OSF/1 with DTK cc.
* m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Also test whether imaxdiv is defined
as a function.
* modules/imaxdiv (configure.ac): Test whether imaxdiv is defined, not
whether it is declared.
Paul Eggert [Thu, 1 Sep 2011 19:53:10 +0000 (12:53 -0700)]
openat: work around AIX 7.1 fstatat issue
This should fix the problem that was not properly fixed
in the previous change, dated 2011-08-30.
* lib/fstatat.c: Include <sys/stat.h> twice, the first with
__need_system_stat_h defined.
(orig_fstatat) [HAVE_FSTATAT]: New function.
(rpl_fstatat): Go back to the old way of doing things,
except call orig_fstatat instead of fstatat.
* m4/openat.m4 (gl_FUNC_FSTATAT): Remove unnecessary check for openat.
Remove unnecessary check whether fstatat fills in st_size etc.