Eric Blake [Fri, 26 Sep 2008 20:47:41 +0000 (14:47 -0600)]
Fix previous patch, and tweak references to $0.
* posix-modules: Call func_gnulib_dir before using $gnulib_dir.
(func_version, func_gnulib_dir): Don't call this program
gnulib-tool.
(func_gnulib_dir, func_tmpdir, func_fatal_error): Avoid shell bugs
with using $0 in function.
* gnulib-tool (func_gnulib_dir, func_tmpdir): Likewise.
(func_fatal_error): Reuse the name the user invoked us with.
Jim Meyering [Tue, 16 Sep 2008 08:05:47 +0000 (10:05 +0200)]
fts: sort dirent entries on inode number before traversing
This avoids a quadratic, seek-related performance penalty when
operating on a directory containing many entries (measurable at 10k;
3.5 hours at 2 million entries with a cold cache) on certain types
of file systems, including ext3 and ext4, but not tmpfs.
* lib/fts.c (DT_MUST_BE, NOT_AN_INODE_NUMBER, D_INO): Define.
(FTS_INODE_SORT_DIR_ENTRIES_THRESHOLD): Define if not defined.
(S_MAGIC_TMPFS, S_MAGIC_NFS): Define.
(fs_handles_readdir_ordered_dirents_efficiently): New function.
(dirent_inode_sort_may_be_useful, fts_compare_ino): Likewise.
(fts_build): Set the stat.st_ino member from D_INO.
If it is likely to be useful, sort dirent entries on inode number.
* m4/fts.m4 (gl_FUNC_FTS_CORE): Check for fstatfs, sys/vfs.h,
and the struct statfs.f_type member.
* modules/fts (Depends-on): Add d-ino.
Paolo Bonzini [Tue, 23 Sep 2008 13:11:23 +0000 (15:11 +0200)]
implement full-blown select(2) for winsock
2008-09-24 Paolo Bonzini <bonzini@gnu.org>
* NEWS: Document increased portability that sys_select now provides.
* lib/sys_select.in.h: Install select wrapper.
* lib/sys_socket.in.h: Use more descriptive name when there is no
select wrapper.
* lib/winsock-select.c: New.
* m4/sys_select_h.m4: Compile lib/winsock-select.c if WinSock is used.
Require gl_HEADER_SYS_SOCKET.
* modules/sys_select: Depend on alloca, add lib/winsock-select.c.
* modules/sys_select-tests: Copy dependencies from modules/poll-tests.
* tests/test-sys_select.c: Add functional tests.
Eric Blake [Wed, 24 Sep 2008 16:55:19 +0000 (10:55 -0600)]
open, fopen: close fd leak in last patch
* lib/open.c (rpl_open): Close fd before returning error.
* lib/fopen.c (rpl_fopen): Close fd before returning error.
* doc/posix-functions/open.texi (open): Document that Irix also
has the bug.
* doc/posix-functions/fopen.texi (fopen): Likewise.
Reported by Paolo Bonzini.
Eric Blake [Tue, 23 Sep 2008 14:56:10 +0000 (08:56 -0600)]
c-stack: avoid compiler optimizations when provoking overflow
* m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Make
recursion harder to optimize, to ensure a stack overflow occurs.
* tests/test-c-stack.c (recurse): Likewise.
Borrowed from libsigsegv.
Eric Blake [Tue, 23 Sep 2008 14:47:26 +0000 (08:47 -0600)]
c-stack: work around Irix sigaltstack bug
* m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Check
whether sigaltstack uses wrong end of stack_t (copied in part from
libsigsegv).
* lib/c-stack.c (c_stack_action) [!HAVE_LIBSIGSEGV]: Work around
Irix bug, without requiring an over-allocation.
* doc/posix-functions/sigaltstack.texi (sigaltstack): Document the
bug.
Eric Blake [Tue, 23 Sep 2008 12:48:07 +0000 (06:48 -0600)]
fopen: document mingw bug on directories
* doc/posix-functions/fopen.texi (fopen): Mention mingw bug for
not allowing a stream visiting a directory, even though reading
from such a stream is not portable.
Paolo Bonzini [Fri, 12 Sep 2008 06:43:03 +0000 (08:43 +0200)]
add sockets wrappers
2008-09-23 Paolo Bonzini <bonzini@gnu.org>
* lib/sys_socket.in.h: Do not implement rpl_setsockopt here,
instead define prototypes for a full set of wrappers. Ensure
that Cygwin does not use the compatibility code, which is only
for MinGW.
* lib/winsock.c: New.
* m4/sys_socket_h.m4: Compile lib/winsock.c if WinSock is being used.
* modules/sys_socket: Add lib/winsock.c.
* modules/poll-tests: Add errno and perror.
* tests/test-poll.c: Use ioctl, not ioctlsocket.
* m4/posix-shell.m4 (gl_POSIX_SHELL): Reject a shell that lets
a umask modification leak out of a subshell. Otherwise, the
opensolaris /bin/sh would be accepted and thus cause unwarranted
failures in the coreutils test suite.