Jim Meyering [Thu, 2 Oct 2008 08:00:46 +0000 (10:00 +0200)]
fts.c: sync with similar code from coreutils' remove.c
* lib/fts.c (dirent_inode_sort_may_be_useful): Merge from coreutils.
Guard also with "#if defined __linux__", since for now at least,
this code is Linux-kernel-specific.
* lib/fsync.c: New file.
* m4/fsync.m4: New file.
* modules/fsync: New file.
* modules/fsync-tests: New file.
* tests/test-fsync.c: New file.
* modules/unistd: Substitute GNULIB_FSYNC and HAVE_FSYNC.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Define and AC_SUBST
both GNULIB_FSYNC and HAVE_FSYNC.
* lib/unistd.in.h (@GNULIB_FSYNC@): Add a block for fsync.
* MODULES.html.sh (posix_functions): Add fsync.
* doc/posix-functions/fsync.texi: Update.
Jim Meyering [Thu, 2 Oct 2008 06:44:01 +0000 (08:44 +0200)]
fts: bug fixes
* lib/fts.c: Remove unnecessary "defined" in cpp directive.
Include <sys/vfs.h>, not <sys/statfs.h>.
* m4/fts.m4 (gl_FUNC_FTS_CORE): Fix typo s/vfs/vfs.h/.
Include <sys/vfs.h>, not <sys/statfs.h>.
getdate.y: disallow countable dayshifts like "4 yesterday ago"
* lib/getdate.y (relative_time_table) [tDAY_SHIFT]: New type for
exactly specified dayshifts.
(dayshift): New rule.
(rel): Add dayshift.
(relative_time_table) [tomorrow, yesterday, today, now]:
Use tDAY_SHIFT in place of tDAY_UNIT.
* tests/test-getdate.c: Add tests for now-disallowed countable
dayshifts, e.g., "4 yesterday ago".
Paolo Bonzini [Mon, 29 Sep 2008 10:02:35 +0000 (12:02 +0200)]
strengthen self-containedness check for sys/select.h
2008-09-29 Paolo Bonzini <bonzini@gnu.org>
Bruno Haible <bruno@clisp.org>
* lib/sys_select.in.h: Include sys/time.h.
* m4/sys_select.h.m4: Test that struct timeval is fully defined.
* modules/sys_select: Depend on sys_time.
* tests/test-sys_select.c: Test that sys/select.h defines struct
timeval fully.
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.