Eric Blake [Mon, 2 Nov 2009 13:03:20 +0000 (06:03 -0700)]
maint: avoid compiler warnings in m4 macros
* m4/ungetc.m4 (gl_FUNC_UNGETC_WORKS): Avoid unused variable.
* m4/rmdir.m4 (gl_FUNC_RMDIR): Include correct header.
Signed-off-by: Eric Blake <ebb9@byu.net>
Simon Josefsson [Mon, 2 Nov 2009 10:55:14 +0000 (11:55 +0100)]
pmccabe2html: Don't hard code awk path.
Eric Blake [Sat, 31 Oct 2009 13:23:11 +0000 (07:23 -0600)]
fseeko: fix m4 regression
* m4/fseeko.m4 (gl_FUNC_FSEEKO): Use modern macro. Fixes
regression from 2009-10-27.
Reported by Ralf Wildenhues.
Signed-off-by: Eric Blake <ebb9@byu.net>
Jim Meyering [Sat, 31 Oct 2009 08:42:37 +0000 (09:42 +0100)]
inttostr: aesthetics and improved (compile-time) safety
Define inttype_is_signed rather than inttype_is_unsigned,
since the sole use is via "#if inttype_is_signed".
* lib/imaxtostr.c (inttype_is_signed): Define this, rather than
inttype_is_unsigned.
* lib/offtostr.c (inttype_is_signed): Likewise.
* lib/uinttostr.c (inttype_is_signed): Likewise.
* lib/umaxtostr.c (inttype_is_signed): Likewise.
* lib/inttostr.c (inttostr): Use verify to cross-check the
inttype_is_signed value and the signedness of the actual type.
* modules/inttostr (Depends-on): Add verify.
Eric Blake [Fri, 30 Oct 2009 15:47:12 +0000 (09:47 -0600)]
build: avoid compiler warnings
* lib/fchmodat.c (lchmod): Mark unused variables.
* lib/getopt.c (_getopt_initialize): Likewise.
* lib/mktime.c (__mktime_internal): Provide prototype.
* lib/inttostr.c (inttostr): Avoid compiler warning even with
older gcc that do not understand #pragma GCC diagnostic.
* lib/uinttostr.c (inttype_is_unsigned): Define.
* lib/umaxtostr.c (inttype_is_unsigned): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Michael Haubenwallner [Fri, 30 Oct 2009 23:00:03 +0000 (17:00 -0600)]
stat: fix compilation on AIX
AC_SYS_LARGEFILE turns on large-file support, but in that mode, AIX
provides only struct stat64, and not struct stat.
* lib/sys_stat.in.h (stat): Work with fact that large files on AIX
only see struct stat64.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Fri, 30 Oct 2009 12:48:14 +0000 (06:48 -0600)]
exclude: make more robust
* lib/exclude.c (excluded_file_name): Abort on unexpected value,
rather than masking a coding bug.
Suggested by Bruno Haible.
Signed-off-by: Eric Blake <ebb9@byu.net>
Jim Meyering [Fri, 30 Oct 2009 14:02:02 +0000 (15:02 +0100)]
perl scripts: remove #!/usr/bin/perl in favor of more portable...
Rather than putting #!/usr/bin/perl on the first line,
start with a variant of what's recommended by "man perlrun" that
invokes the first "perl" program from your shell's search path.
* build-aux/gitlog-to-changelog: Replace #!... as above.
Add a "Local Variables" perl mode setting.
Prompted by a patch from Ludovic Courtès.
Improved by Eric Blake.
* build-aux/useless-if-before-free: Likewise.
* build-aux/announce-gen: Likewise.
* build-aux/update-copyright: Likewise.
Eric Blake [Thu, 29 Oct 2009 18:09:48 +0000 (12:09 -0600)]
filenamecat-lgpl: adjust clients
at-func2 still needs xalloc_die because of openat-die, but this
change is still good to make.
* modules/linkat (Depends-on): Use filenamecat-lgpl, not
filenamecat.
* modules/renameat (Depends-on): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 29 Oct 2009 18:00:03 +0000 (12:00 -0600)]
filenamecat: split into filenamecat-lgpl
The concept of filenamecat is simple enough to use in an LGPL
manner, even though current clients are GPL for other reasons.
At any rate, it is nice to separate mfile_name_concat into its
own file so that the linker does not fail without xalloc_die.
* modules/filenamecat-lgpl: New module.
* modules/filenamecat (Files): Move library-safe files into
filenamecat-lgpl.
(Depends-on): Add filenamecat-lgpl.
(configure.ac): Declare witness.
* lib/filenamecat.h (file_name_concat): Only declare when using
GPL module.
* lib/filenamecat.c (longest_relative_suffix, mfile_name_concat):
Move...
* lib/filenamecat-lgpl.c: ...into new file.
* m4/filenamecat.m4 (gl_FILE_NAME_CONCAT_LGPL): New macro.
(gl_FILE_NAME_CONCAT): Use it.
* MODULES.html.sh (File system functions): Mention new module.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 29 Oct 2009 19:38:52 +0000 (13:38 -0600)]
argp: avoid memory leak
argp has been leaking memory since commit
79c0a43, in Jul 2006.
* modules/argp (Depends-on): Use dirname-lgpl, not dirname.
* lib/argp-namefrob.h (__argp_base_name): Use last_component, not
base_name, since the latter malloc()s and can call exit().
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 29 Oct 2009 17:44:12 +0000 (11:44 -0600)]
dirname-lgpl: adjust clients that don't need full dirname
Some of these modules still use xalloc_die from other paths, but
mkdir and rename are definitely reduced in complexity.
* modules/backupfile (Depends-on): Use dirname-lgpl, not dirname.
* modules/filenamecat (Depends-on): Likewise.
* modules/linkat (Depends-on): Likewise.
* modules/mkancesdirs (Depends-on): Likewise.
* modules/mkdir (Depends-on): Likewise.
* modules/openat (Depends-on): Likewise.
* modules/savewd (Depends-on): Likewise.
* modules/rename (Depends-on): Likewise.
(License): Relax license.
* modules/mkdir-tests (Depends-on): Drop progname.
(Makefile.am): Delete unneeded LDADD.
* modules/rename-tests (Depends-on, Makefile.am): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 29 Oct 2009 16:43:31 +0000 (10:43 -0600)]
dirname: split into dirname-lgpl
dirname.h is proving quite useful from multiple LGPL modules,
given the number of trailing slash bugs fixed in syscalls;
only the calls to xalloc_die need to remain GPL.
* modules/dirname-lgpl: New module.
* modules/dirname (Files): Move library-safe files into
dirname-lgpl.
(Depends-on): Add dirname-lgpl.
(configure.ac): Declare witness.
* modules/double-slash-root (License): Relax license.
* lib/dirname.h (base_name, dir_name): Only declare when using GPL
module.
* lib/dirname.c (dir_len, mdir_name): Move...
* lib/dirname-lgpl.c: ...into new file.
* lib/basename.c (last_component, base_len): Move...
* lib/basename-lgpl.c: ...into new file.
* m4/dirname.m4 (gl_DIRNAME_LGPL): New macro.
(gl_DIRNAME): Use it.
* MODULES.html.sh (Enhancements for POSIX:2008 functions):
Mention new module.
* modules/dirname-tests (Depends-on): Add progname.
* tests/test-dirname.c (program_name): Delete.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 29 Oct 2009 15:37:42 +0000 (09:37 -0600)]
mkdir: make safe for libraries
xstrdup is too dangerous to use in a syscall replacement.
* modules/mkdir (Depends-on): Drop xalloc.
* lib/mkdir.c (rpl_mkdir): Fail with ENOMEM rather than calling
exit.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 29 Oct 2009 15:15:06 +0000 (09:15 -0600)]
tests: avoid some compiler warnings
Mostly Simon's modules; warnings reported by gcc 4.3.4 on coreutils.
* tests/test-getaddrinfo.c (simple): Mark static, and allow string
literals.
* tests/test-memchr.c (main): Avoid type mismatch.
* tests/test-arpa_inet.c (main): Avoid unused parameters.
* tests/test-base64.c (main): Likewise.
* tests/test-getdelim.c (main): Likewise.
* tests/test-gethostname.c (main): Likewise.
* tests/test-getline.c (main): Likewise.
* tests/test-netinet_in.c (main): Likewise.
* tests/test-select.c (open_server_socket, main): Likewise.
* tests/test-select-stdin.c (main): Likewise.
* tests/test-sockets.c (main): Likewise.
* tests/test-strsignal.c (main): Likewise.
* tests/test-sys_select.c (main): Likewise.
* tests/test-sys_socket.c (main): Likewise.
* tests/test-u64.c (main): Likewise.
* tests/test-xfprintf-posix.c (main): Likewise.
* tests/test-xvasprintf.c (test_xvasprintf, main): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 29 Oct 2009 14:47:22 +0000 (08:47 -0600)]
sockets: avoid compiler warning
* lib/sockets.c (gl_sockets_startup): Mark unused parameter.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 29 Oct 2009 13:29:26 +0000 (07:29 -0600)]
maint: detect usage(1) and other suspicious exits
* top/maint.mk (sc_prohibit_magic_number_exit): New rule.
Signed-off-by: Eric Blake <ebb9@byu.net>
Jim Meyering [Thu, 29 Oct 2009 10:52:34 +0000 (11:52 +0100)]
timespec: long-to-int truncation could make timespec_cmp malfunction
* lib/timespec.h (timespec_cmp): Do not interpret a difference of
a multiple of 2^32 nanoseconds as no difference.
Jim Meyering [Wed, 28 Oct 2009 10:25:29 +0000 (11:25 +0100)]
fprintftime: wrap macro code argument in "do {...} while(0)"
* lib/strftime.c (cpy) [FPRINTFTIME]: The second argument to the
cpy macro must be a statement that can be followed by a semicolon.
Now that the else clause contains a comment and is hence longer
than one line, I require curly braces. That in turn requires
that we wrap this code block in the standard do...while(0).
Jim Meyering [Wed, 28 Oct 2009 10:07:31 +0000 (11:07 +0100)]
fprintftime: remove stray semicolon from previous change
* lib/strftime.c (cpy) [FPRINTFTIME]: Remove trailing semicolon.
Jim Meyering [Wed, 28 Oct 2009 09:24:09 +0000 (10:24 +0100)]
fprintftime: avoid a warning about ignored fwrite return value
* lib/strftime.c [FPRINTFTIME]: Include "ignore-value.h".
(cpy) [FPRINTFTIME]: Ignore fwrite failure, even though technically,
that is unsafe.
* modules/fprintftime (Depends-on): Add ignore-value.
Jim Meyering [Wed, 28 Oct 2009 08:26:04 +0000 (09:26 +0100)]
exclude: avoid an unwarranted warning
* lib/exclude.c (excluded_file_name): Initialize "rc" before switch.
Eric Blake [Tue, 27 Oct 2009 16:42:50 +0000 (10:42 -0600)]
fseek: avoid compilation failure when fflush is replaced
./gnulib-tool --import fseek fwritable failed on Debian, due
to broken fflush() pulling in rpl_fseeko that mistakenly
overwrote fseek() as function-like macro.
* m4/fseek.m4 (gl_REPLACE_FSEEK): New macro.
* m4/fseeko.m4 (gl_REPLACE_FSEEKO): Also replace fseek, if fseek
module is in use.
* lib/stdio.in.h (GNULIB_FSEEKO): Only poison fseek if fseek
module is not in use; since REPLACE_FSEEK worked otherwise.
(GNULIB_FTELLO): Likewise for ftell.
Reported by Ian Beckwith and others.
Signed-off-by: Eric Blake <ebb9@byu.net>
Bruno Haible [Wed, 28 Oct 2009 00:22:40 +0000 (01:22 +0100)]
Avoid a nearly redundant gcc warning.
Bruno Haible [Tue, 27 Oct 2009 23:51:42 +0000 (00:51 +0100)]
Avoid warning despite dropping the return value of fwrite.
Eric Blake [Tue, 27 Oct 2009 03:41:21 +0000 (21:41 -0600)]
areadlinkat: fix fallback path
* lib/at-func.c (AT_FUNC_NAME): Avoid signed comparison between
pointer and zero.
Signed-off-by: Eric Blake <ebb9@byu.net>
Pádraig Brady [Thu, 22 Oct 2009 16:36:28 +0000 (17:36 +0100)]
digests, copy-file: increase the IO buffer size from 4KiB to 32KiB
This results in a significant decrease in syscall overhead
giving a 3% speedup to the digest utilities for example
(when processing large files from cache).
Storage is moved from the stack to the heap as some
threaded environments for example can have small stacks.
* lib/copy-file.c (copy_file_preserving): Use a 32KiB malloced buffer
* modules/copy-file: Depend on xalloc
* lib/md2.c: Likewise
* lib/md4.c: Likewise
* lib/md5.c: Likewise
* lib/sha1.c: Likewise
* lib/sha256.c: Likewise
* lib/sha512.c: Likewise
Eric Blake [Thu, 22 Oct 2009 13:59:46 +0000 (07:59 -0600)]
tests: avoid several compiler warnings
* tests/test-getcwd.c (main): Avoid buffer underflow.
* tests/test-getdate.c (main): String literals are not safe with
putenv, so use setenv. Declare unused argument.
* modules/getdate-tests (Depends-on): Add setenv.
* tests/test-argv-iter.c (main): Declare unused argument. Avoid
problems with string literals in char *.
* tests/test-hash.c (main): Avoid shadowing declaration.
(insert_new): Treat string literals as char const *.
* tests/test-getopt.h (test_getopt): Likewise.
(getopt_loop): Alter types to minimize casting elsewhere.
* tests/test-getopt_long.h (test_getopt_long, getopt_long_loop)
(test_getopt_long_posix): Likewise.
(do_getopt_long): Add wrapper to minimize casting.
* tests/test-atexit.c (clear_temp_file): Use void.
* tests/test-areadlink-with-size.c (main): Declare unused
arguments.
* tests/test-areadlink.c (main): Likewise.
* tests/test-areadlinkat-with-size.c (main): Likewise.
* tests/test-areadlinkat.c (main): Likewise.
* tests/test-canonicalize-lgpl.c (main): Likewise.
* tests/test-canonicalize.c (main): Likewise.
* tests/test-dirent-safer.c (main): Likewise.
* tests/test-dirname.c (main): Likewise.
* tests/test-dup2.c (main): Likewise.
* tests/test-fchdir.c (main): Likewise.
* tests/test-fcntl-h.c (main): Likewise.
* tests/test-fcntl-safer.c (main): Likewise.
* tests/test-fdopendir.c (main): Likewise.
* tests/test-fdutimensat.c (main): Likewise.
* tests/test-fflush.c (main): Likewise.
* tests/test-filenamecat.c (main): Likewise.
* tests/test-filevercmp.c (main): Likewise.
* tests/test-fopen-safer.c (main): Likewise.
* tests/test-fopen.c (main): Likewise.
* tests/test-fpending.c (main): Likewise.
* tests/test-fpurge.c (main): Likewise.
* tests/test-freading.c (main): Likewise.
* tests/test-fstatat.c (main): Likewise.
* tests/test-fsync.c (main): Likewise.
* tests/test-futimens.c (main): Likewise.
* tests/test-getndelim2.c (main): Likewise.
* tests/test-gettimeofday.c (main): Likewise.
* tests/test-getopt.c (main): Likewise.
* tests/test-i-ring.c (main): Likewise.
* tests/test-inttypes.c (main): Likewise.
* tests/test-link.c (main): Likewise.
* tests/test-lstat.c (main): Likewise.
* tests/test-math.c (main): Likewise.
* tests/test-md5.c (main): Likewise.
* tests/test-memchr2.c (main): Likewise.
* tests/test-memrchr.c (main): Likewise.
* tests/test-mkdir.c (main): Likewise.
* tests/test-mkdirat.c (main): Likewise.
* tests/test-mkfifoat.c (main): Likewise.
* tests/test-open.c (main): Likewise.
* tests/test-openat-safer.c (main): Likewise.
* tests/test-openat.c (main): Likewise.
* tests/test-quotearg.c (main): Likewise.
* tests/test-rawmemchr.c (main): Likewise.
* tests/test-readlink.c (main): Likewise.
* tests/test-remove.c (main): Likewise.
* tests/test-rename.c (main): Likewise.
* tests/test-renameat.c (main): Likewise.
* tests/test-rmdir.c (main): Likewise.
* tests/test-sha1.c (main): Likewise.
* tests/test-signal.c (main): Likewise.
* tests/test-sigaction.c (main): Likewise.
* tests/test-stat.c (main): Likewise.
* tests/test-stat-time.c (main): Likewise.
* tests/test-stddef.c (main): Likewise.
* tests/test-stdint.c (main): Likewise.
* tests/test-stdio.c (main): Likewise.
* tests/test-stdlib.c (main): Likewise.
* tests/test-strchrnul.c (main): Likewise.
* tests/test-strerror.c (main): Likewise.
* tests/test-string.c (main): Likewise.
* tests/test-strtod.c (main): Likewise.
* tests/test-strverscmp.c (main): Likewise.
* tests/test-symlink.c (main): Likewise.
* tests/test-symlinkat.c (main): Likewise.
* tests/test-sys_stat.c (main): Likewise.
* tests/test-sys_time.c (main): Likewise.
* tests/test-time.c (main): Likewise.
* tests/test-unistd.c (main): Likewise.
* tests/test-unlink.c (main): Likewise.
* tests/test-unlinkat.c (main): Likewise.
* tests/test-utimens.c (main): Likewise.
* tests/test-utimensat.c (main): Likewise.
* tests/test-version-etc.c (main): Likewise.
* tests/test-wchar.c (main): Likewise.
* tests/test-wctype.c (main): Likewise.
* tests/test-xprintf-posix.c (main): Likewise.
* tests/test-posixtm.c (main): Likewise.
(STREQ): Delete unused macro.
* tests/test-linkat.c (main): Declare unused arguments. Avoid
shadowed variables.
* tests/test-memchr.c (main): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 22 Oct 2009 03:01:41 +0000 (21:01 -0600)]
areadlinkat: avoid failure on older glibc
Acting on /proc/self/-1/name gives ENOTDIR. at-func normally falls
back to fchdir, which discovers the real problem of invalid fd and
changes to EBADF; but for areadlinkat, it mistakenly short-circuited
when FUNC_FAIL was NULL (since 0<=(char*)result is always true).
* lib/at-func.c (AT_FUNC_NAME): Check for explicit FUNC_FAIL,
rather than mis-comparing 0 against FUNC_RESULT of char*.
Signed-off-by: Eric Blake <ebb9@byu.net>
Bruno Haible [Thu, 22 Oct 2009 00:00:21 +0000 (02:00 +0200)]
Relicense stpncpy under LGPLv2+.
Eric Blake [Tue, 20 Oct 2009 22:47:36 +0000 (16:47 -0600)]
utimensat: work around Solaris 9 bug
utimes("file/",times) mistakenly succeeds. This commit doesn't fix
utimes, but does make utimensat be careful before calling utimes.
The test is now enhanced to test trailing slashes and directories.
Meanwhile, cygwin 1.5 stat() on a directory changes atime (it does
a readdir under the hood to populate st_nlink), so only mtime of
a directory is reliable enough for testing. Cygwin 1.7 no longer
has this problem, because it no longer wastes time on st_nlink.
* lib/utimens.c (fdutimens, lutimens): Force a stat if platform
has trailing slash bugs.
* tests/test-lutimens.h (test_lutimens): Enhance test.
* tests/test-utimens.h (test_utimens): Likewise.
* doc/posix-functions/utime.texi (utime): Document the bug.
* doc/posix-functions/utimes.texi (utimes): Likewise.
* doc/posix-functions/utimensat.texi (utimensat): Likewise.
* doc/glibc-functions/futimesat.texi (futimesat): Likewise.
* doc/glibc-functions/lutimes.texi (lutimes): Mention utimens.
* doc/posix-functions/futimens.texi (futimens): Mention
limitation.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Tue, 20 Oct 2009 12:09:29 +0000 (06:09 -0600)]
fdutimensat: new module
Needed for coreutils copy.c to be rewritten to use fts.
* modules/fdutimensat: New file.
* lib/fdutimensat.c (fdutimensat): Likewise.
* lib/utimens.h (fdutimensat, lutimensat): Declare new functions.
* MODULES.html.sh (File system functions): Mention module.
* modules/fdutimensat-tests: New test.
* tests/test-fdutimensat.c: Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 21 Oct 2009 02:27:20 +0000 (20:27 -0600)]
doc: regenerate INSTALL
* doc/INSTALL: Reflect recent autoconf update.
* doc/INSTALL.ISO: Likewise.
* doc/INSTALL.UTF-8: Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Jim Meyering [Tue, 20 Oct 2009 06:04:10 +0000 (08:04 +0200)]
ChangeLog syntax: use TAB, not a sequence of leading spaces
Pádraig Brady [Mon, 19 Oct 2009 09:10:05 +0000 (10:10 +0100)]
acl: warn if ACL support is not detected
* m4/acl.m4 (gl_FUNC_ACL): Output a warning if ACL support is not found.
Karl Berry [Mon, 19 Oct 2009 13:47:23 +0000 (06:47 -0700)]
autoupdate
Giuseppe Scrivano [Mon, 19 Oct 2009 09:43:54 +0000 (11:43 +0200)]
users.txt: add myserver
* users.txt: Add myserver.
Giuseppe Scrivano [Mon, 19 Oct 2009 07:30:13 +0000 (09:30 +0200)]
Add extern "C" block for C++.
Bruno Haible [Sun, 18 Oct 2009 19:49:38 +0000 (21:49 +0200)]
Document the alternative APIs for character classification.
Bruno Haible [Sun, 18 Oct 2009 19:17:38 +0000 (21:17 +0200)]
Tests for module 'isblank'.
Bruno Haible [Sun, 18 Oct 2009 19:16:44 +0000 (21:16 +0200)]
New module 'isblank'.
Bruno Haible [Sun, 18 Oct 2009 19:12:31 +0000 (21:12 +0200)]
New module 'ctype'.
Jim Meyering [Sun, 18 Oct 2009 16:53:35 +0000 (18:53 +0200)]
m4: stylistic-only: hoist AC_SUBST to be adjacent to initialization
Declare a variable like LIB_CLOCK_GETTIME to be AC_SUBSTituted
right after its initialization, rather than farther down.
Keeping these in close proximity makes it easier to ensure
that each such variable is initialized. E.g.,
LIB_CLOCK_GETTIME=
AC_SUBST([LIB_CLOCK_GETTIME])
This change also increments these serial numbers.
* m4/clock_time.m4 (gl_CLOCK_TIME): Hoist AC_SUBST use.
* m4/euidaccess.m4 (gl_PREREQ_EUIDACCESS): Likewise.
* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Likewise.
Bruno Haible [Sun, 18 Oct 2009 16:19:22 +0000 (18:19 +0200)]
Don't let environment variables perturb build.
* m4/gethrxtime.m4 (gl_GETHRXTIME): Initialize LIB_GETHRXTIME here...
(gl_PREREQ_GETHRXTIME): ... not here.
Bruno Haible [Sun, 18 Oct 2009 14:58:39 +0000 (16:58 +0200)]
Avoid symlink attack in localcharset module.
Bruno Haible [Sun, 18 Oct 2009 09:22:22 +0000 (11:22 +0200)]
Implement nproc for mingw.
Bruno Haible [Sun, 18 Oct 2009 08:56:30 +0000 (10:56 +0200)]
Implement nproc for IRIX.
Bruno Haible [Sun, 18 Oct 2009 08:42:19 +0000 (10:42 +0200)]
Implement nproc for HP-UX.
Bruno Haible [Sun, 18 Oct 2009 08:13:58 +0000 (10:13 +0200)]
Implement nproc for NetBSD, OpenBSD.
Bruno Haible [Sun, 18 Oct 2009 08:00:29 +0000 (10:00 +0200)]
Fix recognition of sys/sysctl.h on OpenBSD 4.0.
Eric Blake [Mon, 12 Oct 2009 22:48:57 +0000 (16:48 -0600)]
utimensat: new module
Provide utimensat where it is missing, and rpl_utimensat to work
around ENOSYS and EINVAL bugs in older Linux kernels.
* modules/utimensat: New file.
* lib/utimensat.c (utimensat): Likewise.
* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Likewise.
* lib/utimens.c (utimensat): Avoid recursion into rpl_utimensat,
so we can work around Linux bugs.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Add witnesses.
* modules/sys_stat (Makefile.am): Substitute them.
* lib/sys_stat.in.h (utimensat): Declare it.
* MODULES.html.sh (systems lacking POSIX:2008): Mention module.
* doc/posix-functions/utimensat.texi (utimensat): Likewise.
* modules/utimensat-tests: New test.
* tests/test-utimensat.c: Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 15 Oct 2009 18:04:57 +0000 (12:04 -0600)]
utimens: let lutimens work on non-symlinks
Coreutils new 'touch -h' is easier to write if we guarantee POSIX
semantics of utimensat(fd,"file",NULL,AT_SYMLINK_NOFOLLOW), rather
than blindly failing with ENOSYS even on non-symlinks.
* lib/utimens.c (lutimens): Fall back to utimens rather than
failing with ENOSYS, when file is not a symlink.
(utimens): Reduce redirection.
* tests/test-lutimens.h (test_lutimens): Update test to cover
non-symlinks.
* tests/test-utimens.h (test_utimens): Update test to cover
symlinks.
* tests/test-utimens.c (main): Update caller.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Mon, 12 Oct 2009 20:56:22 +0000 (14:56 -0600)]
utimens: cache whether utimensat syscall works
No need to repeatedly try utimensat on older Linux kernel.
* lib/utimens.c (utimensat_works_really): New cache variable.
(fdutimens, lutimens): Use it to avoid failing syscall.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Mon, 12 Oct 2009 16:42:35 +0000 (10:42 -0600)]
test-stat-time, test-utimens: improve portability
ext4 on an alpha system has a quantization of about 10 ms but
a resolution of 1ns; utimecmp does not know about quantization,
so tests were failing when comparing timestamps that fall
within the same quantization window. Add strategic usleeps
throughout to minimize this issue, whether or not we later
improve utimecmp to account for quantization.
Windows (and hence cygwin) is documented as having a default
clock quantization of 15.25 milliseconds (although it can be
reduced to 1 millisecond); file timestamps are quantized to this
boundary even though more accurate timing can be obtained.
However, this means that 15 milliseconds is too short for any
test that wants to guarantee crossing a file timestamp boundary.
Cygwin, however, still has bugs where clock_gettime can lag
behind file timestamps, which is not fixed by this patch.
Solaris 9 with NFS exposed the same problem for futimes that was
previously fixed for utimes on Solaris 8, where futimens(f,NULL)
uses a different time source than futimes(,{,UTIME_NOW}).
* tests/test-stat-time.c (nap): Lengthen delay to 20ms, for
ext4 on alpha, and for cygwin.
* tests/test-utimens-common.h: New file.
(nap): Factor delays into single function.
* tests/test-lutimens.h (test_lutimens): Use new header.
* tests/test-futimens.h (test_futimens): Likewise.
* tests/test-utimens.h (test_utimens): Likewise. Also, force NFS
timestamps to occur from same machine, as was done previously for
test_utimens.
* modules/utimens-tests (Files): Ship new file.
* modules/futimens-tests (Files): Likewise.
Reported in part by Jim Meyering.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Mon, 12 Oct 2009 21:33:30 +0000 (15:33 -0600)]
sys_stat: sort replacement declarations
* lib/sys_stat.in.h: Sort declarations.
* lib/futimens.c (futimens): Fix typo.
Signed-off-by: Eric Blake <ebb9@byu.net>
Jim Meyering [Thu, 15 Oct 2009 19:04:51 +0000 (21:04 +0200)]
don't let environment settings perturb build
Setting the envvars, LIB_CLOCK_GETTIME, LIB_EACCESS or LIB_NANOSLEEP
could cause a configure-time and/or build-time malfunction.
Typically, a configure-time function-in-library test is performed
via code like this:
LIB_VAR=
AC_SUBST([LIB_VAR])
prefix_saved_LIBS=$LIBS
AC_SEARCH_LIBS([FUNC], [LIB_NAME],
[test "$ac_cv_search_FUNC" = "none required" ||
LIB_VAR=$ac_cv_search_FUNC])
LIBS=$prefix_saved_LIBS
However, in each of the files affected by this change, the LIB_VAR=
initialization was omitted. Thus, when set in the environment, its
value would propagate into generated Makefiles when FUNC is not found
in LIB_NAME.
* m4/clock_time.m4 (gl_CLOCK_TIME): Initialize AC_SUBST'd var.
* m4/euidaccess.m4 (gl_PREREQ_EUIDACCESS): Likewise.
* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Likewise.
Eric Blake [Tue, 13 Oct 2009 15:25:30 +0000 (09:25 -0600)]
fchdir: avoid infinite recursion in mingw
rpl_fstat, needed only on mingw when using fchdir, should not call itself.
* lib/fchdir.c (rpl_fstat): Call system fstat, rather than
recursing.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Tue, 13 Oct 2009 15:16:16 +0000 (09:16 -0600)]
test-stat-time: port to mingw
Newer mingw has usleep, but it rejects arguments over
1000000
without sleeping. And since stat has no visibility into
sub-second resolutions, it meant all the timestamps ended up
identical. Fixed by restoring the 8 seconds of sleep, as
well as working around the documented unlink issue.
* tests/test-stat-time.c (force_unlink): Return a value.
(test_ctime) [W32]: Fix compilation error.
(nap): Don't call usleep with too large an argument. Use
force_unlink.
* doc/pastposix-functions/usleep.texi (usleep): Document the
portability issue.
Signed-off-by: Eric Blake <ebb9@byu.net>
Jim Meyering [Tue, 13 Oct 2009 07:15:52 +0000 (09:15 +0200)]
use AC_CHECK_FUNCS_ONCE, not AC_CHECK_FUNCS in modules/*
* modules/pipe-filter-gi: Use AC_CHECK_FUNCS_ONCE, not AC_CHECK_FUNCS.
* modules/pipe-filter-ii: Likewise.
* modules/sys_socket-tests: Likewise.
* modules/tsearch-tests: Likewise.
* Makefile (sc_prefer_ac_check_funcs_once): New rule.
(check): Depend on it.
Eric Blake [Mon, 12 Oct 2009 16:42:35 +0000 (10:42 -0600)]
utimens-tests: port to NFS file systems
Testing on Solaris 8 with NFS: creat() and utimens(,NULL) seem to
set timestamps according to the current time on the server, while
utimens(,{,UTIME_NOW}) sets timestamps according to the current
time on the client. If two machines are not perfectly
synchronized in time, then this makes time appear to move
backwards. Avoid spurious test failures caused by a mtime
comparison across machines, by instead doing 2 mtime comparisons,
each known to be from timestamps tied to a single machine.
* tests/test-utimens.h (test_utimens): Add a utimens call prior to
grabbing stat buffer.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Mon, 12 Oct 2009 16:37:48 +0000 (10:37 -0600)]
stat-time-tests: minor cleanups
* modules/stat-time-tests (configure.ac): Use AC_CHECK_FUNCS_ONCE.
* tests/test-stat-time.c (nap): Separate assignment from call.
Suggested by Paolo Bonzini and Bruno Haible.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Mon, 12 Oct 2009 16:36:33 +0000 (10:36 -0600)]
sys_stat: guarantee struct timespec
* lib/sys_stat.in.h (includes): Always include <time.h>
* modules/sys_stat (Depends-on): Add time.
* tests/test-sys_stat.c: Guarantee struct timespec, as well as
mode_t permission values.
* doc/posix-headers/sys_stat.texi (sys/stat.h): Document how to
get at subsecond timestamps.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Fri, 9 Oct 2009 22:05:19 +0000 (16:05 -0600)]
futimens: new module
Provides futimens where it is missing, and rpl_futimens to work
around bugs in older Linux kernels.
* modules/futimens: New file.
* lib/futimens.c (futimens): Likewise.
* m4/futimens.m4 (gl_FUNC_FUTIMENS): Likewise.
* lib/utimens.c (futimens): Avoid recursion into rpl_futimens, so
we can work around Linux bugs.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Add witnesses.
* modules/sys_stat (Makefile.am): Substitute them.
* lib/sys_stat.in.h (futimens): Declare it.
* MODULES.html.sh (systems lacking POSIX:2008): Mention module.
* doc/posix-functions/futimens.texi (futimens): Likewise.
* modules/futimens-tests: New test.
* tests/test-futimens.c: Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 8 Oct 2009 12:40:08 +0000 (06:40 -0600)]
utimens: introduce fdutimens
at-func.c wants the file name argument first. This also paves the
way to add fdutimensat(dfd,name,fd,times,flag).
* lib/utimens.h (fdutimens): New prototype.
* lib/utimens.c (gl_futimens): Move guts...
(fdutimens): ...to new interface.
* tests/test-utimens.c (do_fdutimens): Use it.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 22:05:34 +0000 (16:05 -0600)]
utimens: add UTIME_NOW and UTIME_OMIT support
These flags make it possible to implement futimens and utimensat;
they also make touch(1) more efficient, by avoiding stat or
gettime if native utimensat works.
* lib/utimens.c (validate_timespec, update_timespec): New helper
functions.
(gl_futimens, lutimens): Use them.
* modules/utimens (Depends-on): Add gettime, lstat, stat-time,
stdbool, sys_stat.
(Link): Mention resulting library dependency.
* modules/utimecmp (Link): Likewise.
* modules/utimens-tests (Depends-on): Drop stat-time, stdbool.
(Makefile.am): Pick up library dependency.
* lib/sys_stat.in.h (UTIME_NOW, UTIME_OMIT): Guarantee a
definition.
* tests/test-sys_stat.c: Test the definitions.
* doc/posix-headers/sys_stat.texi (sys/stat.h): Document this.
* NEWS: Document library dependency.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Thu, 8 Oct 2009 04:06:49 +0000 (22:06 -0600)]
utimecmp: support symlink timestamps
Update this module to reflect POSIX 2008:
With pathconf, we can avoid calling utimens.
With utimensat, the system resolution can be 1.
With lutimens, we can determine resolution on symlinks.
* lib/utimecmp.c (utimecmp): Use new interface. Skip effort of
hashing when possible. Use pathconf when available.
(SYSCALL_RESOLUTION): Recognize tighter resolution.
* modules/utimecmp (Depends-on): Add lstat.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 19:36:45 +0000 (13:36 -0600)]
utimens: add lutimens interface
Wraps utimensat(,AT_SYMLINK_NOFOLLOW) or lutimes, when supported;
otherwise fail with ENOSYS. Allows coreutils' copy.c to preserve
symlink timestamps on more systems. Note that cygwin's lstat
changes atime of symlinks, but mtime can reliably be set.
* lib/utimens.c (lutimens): New function.
* m4/utimens.m4 (gl_UTIMENS): Check for lutimes.
* lib/utimens.h (lutimens): Declare new interface.
* tests/test-utimens.c (main): Enhance test.
* tests/test-lutimens.h (test_lutimens): New file.
* modules/utimens-tests (Files): Distribute it.
(Depends-on): Add symlink.
(configure.ac): Check for usleep.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Tue, 6 Oct 2009 18:23:32 +0000 (12:23 -0600)]
utimens: validate futimens usage
Using gl_futimens(fd,NULL,times) as an implementation for futimens
won't work unless we reliably detect EBADF for out-of-range fd.
Also catches a Linux bug with futimens(AT_FDCWD,NULL) changing ".".
mingw <utime.h> has a bug where utime's second argument is not const.
* lib/utimens.c (gl_futimens): Require valid fd up front, using
fewer syscalls on failure later on. Avoid compiler warning on
mingw.
* modules/utimens (Depends-on): Add dup2.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 23:08:17 +0000 (17:08 -0600)]
utimens: add test
Exposes holes in our API, and several platform bugs.
* modules/utimens-tests: New test.
* tests/test-utimens.h: New file.
* tests/test-futimens.h: Likewise.
* tests/test-utimens.c: Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 17:58:54 +0000 (11:58 -0600)]
doc: mention timestamp portability issues
* doc/glibc-functions/lutimes.texi (lutimes): Refer to utimensat
instead.
* doc/posix-functions/utime.texi (utime): Likewise.
* doc/posix-functions/utimes.texi (utimes): Likewise.
* doc/glibc-functions/futimes.texi (futimes): Refer to futimens
instead.
* doc/posix-functions/futimens.texi (futimens): Mention utimens
module.
* doc/posix-functions/utimensat.texi (utimensat): Likewise.
Mention weakness with symlink timestamps.
* doc/glibc-functions/futimesat.texi (futimesat): New file; refer
to utimensat/futimens instead.
* doc/gnulib.texi (Glibc sys/time.h): Include new file.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Sat, 10 Oct 2009 13:06:22 +0000 (07:06 -0600)]
test-dup2: enhance test
AT_FDCWD is only supposed to be special in *at functions.
* tests/test-dup2.c (main): Also check AT_FDCWD.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Sat, 10 Oct 2009 14:04:41 +0000 (08:04 -0600)]
test-stat-time: avoid more spurious failures
On xfs, although timestamps can have a full nanosecond resolution,
successive file actions appear to be quantized to approximately
10 millisecond windows. Running with just 1 ms delays could
cause two actions to fall in the same window, leading to sporadic
failures on a fast enough machine. Slow down to prevent this.
On ext2, timestamps only have 1 second resolution, but if the
first timestamp was made at 1.95 and the second at 2.10, then
the two files appear 1 second apart, and the shorter delay was
used, causing spurious failures. Require that the observable
difference lie within the same second, using a second try if
necessary, to prevent this.
* tests/test-stat-time.c (nap): Wait for 15ms rather than 2ms, for
xfs; and avoid race if the two timestamps cross quantization edge.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Sat, 10 Oct 2009 01:17:38 +0000 (19:17 -0600)]
relocatable: prefer 'file system' over 'filesystem'
* m4/relocatable-lib.m4 (gl_RELOCATABLE_NOP): Use AS_HELP_STRING.
(gl_RELOCATABLE_LIBRARY_BODY): Fix spelling.
* doc/relocatable-maint.texi (Supporting Relocation): Likewise.
* doc/relocatable.texi (Enabling Relocatability): Likewise.
* lib/relocatable.c (compute_curr_prefix): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Jim Meyering [Sat, 10 Oct 2009 09:05:22 +0000 (11:05 +0200)]
stat-time-tests: check for the usleep function
* modules/stat-time-tests (configure.ac): Now that we test HAVE_USLEEP.
Bruno Haible [Sat, 10 Oct 2009 08:45:10 +0000 (10:45 +0200)]
Typo in ChangeLog entry.
Bruno Haible [Sat, 10 Oct 2009 08:43:21 +0000 (10:43 +0200)]
Put the Link section after the Include section.
Eric Blake [Sat, 10 Oct 2009 03:28:40 +0000 (21:28 -0600)]
dup2: work around FreeBSD 6.1 bug
dup2(1,
1000000) needs to fail with EBADF (per POSIX), not
EMFILE, based on our usage of it in other modules.
* m4/dup2.m4 (gl_FUNC_DUP2): Detect bug.
* doc/posix-functions/dup2.texi (dup2): Document it.
Reported by Nelson H. F. Beebe and Jim Meyering.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Sat, 10 Oct 2009 03:09:38 +0000 (21:09 -0600)]
test-stat-time: port to buggy NFS clients
On darwin, the NFS client reports mtime with st_sec==INT_MAX and
st_nsec monotonically increasing per transaction until the next
sync(); but sync() is expensive, so it is easier to just skip
this part of the test if mtime is nowhere near ctime.
* tests/test-stat-time.c (main) [W32]: Reduce ifdefs.
(test_ctime): Also skip test if mtime and ctime are skewed.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Sat, 10 Oct 2009 01:17:17 +0000 (19:17 -0600)]
maint: prefer 'file system' over 'filesystem'
* doc/posix-functions/fstatat.texi (fstatat): Likewise.
* doc/posix-functions/lstat.texi (lstat): Likewise.
* lib/file-has-acl.c (file_has_acl): Likewise.
* lib/fwriteerror.c [TEST]: Likewise.
* tests/test-areadlink.h (test_areadlink): Likewise.
* tests/test-areadlinkat-with-size.c (main): Likewise.
* tests/test-areadlinkat.c (main): Likewise.
* tests/test-canonicalize-lgpl.c (main): Likewise.
* tests/test-canonicalize.c (main): Likewise.
* tests/test-fstatat.c (main): Likewise.
* tests/test-linkat.c (main): Likewise.
* tests/test-lstat.h (test_lstat_func): Likewise.
* tests/test-mkdir.h (test_mkdir): Likewise.
* tests/test-readlink.h (test_readlink): Likewise.
* tests/test-remove.c (main): Likewise.
* tests/test-rename.h (test_rename): Likewise.
* tests/test-renameat.c (main): Likewise.
* tests/test-rmdir.h (test_rmdir_func): Likewise.
* tests/test-symlink.h (test_symlink): Likewise.
* tests/test-symlinkat.c (main): Likewise.
* tests/test-unlink.h (test_unlink_func): Likewise.
* tests/test-unlinkat.c (main): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Fri, 9 Oct 2009 14:36:22 +0000 (08:36 -0600)]
maint: make realtime library usage explicit
Adding a Link section makes it easier to notice when it a module
may require edits to a user's Makefile.am.
* modules/gethrxtime (Link): Mention LIB_GETHRXTIME.
* modules/gettime (Link): Mention LIB_CLOCK_GETTIME.
* modules/settime (Link): Likewise.
* modules/xnanosleep (Link): Mention LIB_NANOSLEEP.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Fri, 9 Oct 2009 17:55:46 +0000 (11:55 -0600)]
test-stat-time: speed up execution
Eight seconds was painfully long.
* tests/test-stat-time.c (test_ctime) [!W32]: Avoid compiler
warning on mingw.
(nap): New helper function.
(prepare_test): Use it to reduce sleep time.
(test_mtime, test_ctime, test_birthtime): Allow for subsecond
execution.
* modules/stat-time-tests (configure.ac): Check for usleep.
Signed-off-by: Eric Blake <ebb9@byu.net>
Jim Meyering [Wed, 7 Oct 2009 17:00:42 +0000 (19:00 +0200)]
selinux-h: always use getfilecon wrappers
* lib/getfilecon.c: New file.
* lib/se-selinux.in.h: Use a better inclusion guard symbol name.
[HAVE_SELINUX_SELINUX_H]: Include-next <selinux/selinux.h>.
[!HAVE_SELINUX_SELINUX_H]: Use better parameter names.
(fgetfilecon): Provide a stub.
* m4/selinux-selinux-h.m4 (gl_HEADERS_SELINUX_SELINUX_H): Don't
AC_SUBST SELINUX_SELINUX_H, since now we're generating that
file unconditionally.
When <selinux/selinux.h> is found, arrange to use wrappers.
* modules/selinux-h (Files): Add getfilecon.c.
(Makefile.am): Substitute include-next-related bits
into the now-always-generated selinux/selinux.h file.
* doc/glibc-functions/getfilecon.texi: New file.
* doc/glibc-functions/lgetfilecon.texi: New file.
* doc/glibc-functions/fgetfilecon.texi: New file.
* doc/glibc-functions/getfilecon-desc.texi: New file.
* doc/gnulib.texi (Glibc selinux/selinux.h): New section, by
which to pull in the new files.
* MODULES.html.sh (Misc): Add selinux-h.
Jim Meyering [Thu, 8 Oct 2009 16:25:39 +0000 (18:25 +0200)]
unistd: fix comment typo
* lib/unistd.in.h (euidaccess): Fix a comment typo.
Eric Blake [Thu, 8 Oct 2009 16:09:05 +0000 (10:09 -0600)]
areadlink: use SIZE_MAX consistently
* modules/areadlink (Depends-on): Add stdint.
* modules/areadlink-with-size (Depends-on): Likewise.
* lib/areadlink-with-size.c (includes): Drop stdio, since stdlib
gives NULL; drop sys/types, since unistd gives size_t; and add
stdint for SIZE_MAX.
(SIZE_MAX): Rely on headers.
* lib/areadlinkat-with-size.c (includes): Drop stdio, sys/types,
and add stdint.
* lib/areadlink.c (includes): Drop sys/types, and add stdint.
(SIZE_MAX): Likewise.
(INITIAL_BUF_SIZE): Turn into enum.
* lib/areadlinkat.c (INITIAL_BUF_SIZE): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Karl Berry [Thu, 8 Oct 2009 15:01:40 +0000 (08:01 -0700)]
autoupdate
Jim Meyering [Thu, 8 Oct 2009 14:40:49 +0000 (16:40 +0200)]
areadlinkat: avoid compilation failure
* lib/areadlinkat.c: Include <stdint.h> for use of SIZE_MAX.
Fix typo in comment.
Eric Blake [Wed, 7 Oct 2009 16:52:15 +0000 (10:52 -0600)]
areadlinkat-with-size: new module
* modules/areadlinkat-with-size: New module.
* lib/areadlinkat-with-size.c (areadlinkat_with_size): New file.
* lib/areadlink.h (areadlinkat): Declare it.
* MODULES.html.sh (File system functions): Mention it.
* modules/areadlinkat-with-size-tests: New test.
* tests/test-areadlinkat-with-size.c: New file.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 16:39:29 +0000 (10:39 -0600)]
xreadlinkat: new module
* modules/xreadlinkat: New module.
* lib/xreadlinkat.c (xreadlinkat): New file.
* lib/xreadlink.h (xreadlinkat): Declare it.
* MODULES.html.sh (File system functions): Mention it.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 16:15:33 +0000 (10:15 -0600)]
areadlinkat: new module
* lib/at-func.c (FUNC_FAIL): New define.
(AT_FUNC_NAME, VALIDATE_FLAG): Use it rather than raw -1.
* modules/areadlinkat: New module.
* lib/linkat.c (areadlinkat): Move...
* lib/areadlinkat.c (areadlinkat): ...to new file.
* lib/areadlink.h (areadlinkat): Declare it.
* modules/linkat (Depends-on): Add areadlinkat.
* MODULES.html.sh (File system functions): Mention it.
* modules/areadlinkat-tests: New test.
* tests/test-areadlinkat.c: New file.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 15:40:32 +0000 (09:40 -0600)]
areadlink, areadlink-with-size: add tests
* modules/areadlink-tests: New test.
* modules/areadlink-with-size-tests: Likewise.
* tests/test-areadlink.h: New file.
* tests/test-areadlink.c: Likewise.
* tests/test-areadlink-with-size.c: Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 20:49:38 +0000 (14:49 -0600)]
maint: minor cleanups
* lib/fts.c (ATTRIBUTE_UNUSED): Delete; use gnulib-guaranteed
_ATTRIBUTE_UNUSED instead.
* lib/getdate.y (ATTRIBUTE_UNUSED): Likewise.
* lib/utimens.c (ATTRIBUTE_UNUSED): Likewise.
* modules/linkat-tests (Files): Distribute test-link.h.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 14:17:36 +0000 (08:17 -0600)]
openat, utimens: whitespace cleanup
* lib/openat.c: Prefer space throughout, rather than mix of 8
spaces vs. tabs.
* lib/at-func.c: Likewise.
* lib/utimens.c: Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Wed, 7 Oct 2009 12:56:52 +0000 (06:56 -0600)]
openat: avoid using wrong fd
Detected by a Solaris failure on:
int fd = dup (0);
close (fd);
mkdirat (fd, "dir", 0700);
which created "./dir" instead of failing with EBADF.
* lib/openat.c (openat_permissive): Reject user's fd if saving the
working directory chooses same fd.
* lib/at-func.c (AT_FUNC_NAME): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Tue, 6 Oct 2009 22:08:46 +0000 (16:08 -0600)]
mkdir, mkdirat: fix cygwin 1.5.x bug
mkdir("dir/./",mode) mistakenly succeeded.
* lib/mkdir.c (rpl_mkdir) [FUNC_MKDIR_DOT_BUG]: Work around bug.
* m4/mkdir-slash.m4 (gl_FUNC_MKDIR_TRAILING_SLASH): Move...
* m4/mkdir.m4 (gl_FUNC_MKDIR): ...here, and add check for cygwin
bug.
(gl_PREREQ_MKDIR): Delete unused macro.
* modules/mkdir (Files): Track file rename.
(configure.ac): Update macro name.
* modules/openat (Depends-on): Add mkdir.
* doc/posix-functions/mkdir.texi (mkdir): Document the bug.
Signed-off-by: Eric Blake <ebb9@byu.net>
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.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Tue, 6 Oct 2009 19:57:50 +0000 (13:57 -0600)]
doc: tweak *at function documentation
* doc/posix-functions/faccessat.texi (faccessat): Mention
known issue with replacement.
* doc/posix-functions/fchdir.texi (fchdir): Likewise.
* doc/posix-functions/linkat.texi (linkat): Likewise.
* doc/posix-functions/mkfifoat.texi (mkfifoat): Likewise.
* doc/posix-functions/mknodat.texi (mknodat): Likewise.
* doc/posix-functions/readlinkat.texi (readlinkat): Likewise.
* doc/posix-functions/renameat.texi (renameat): Likewise.
* doc/posix-functions/symlinkat.texi (symlinkat): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Tue, 6 Oct 2009 18:03:58 +0000 (12:03 -0600)]
openat: fix GNU/Hurd bug in unlinkat
unlinkat(fd,"file/",0) mistakenly succeeded.
* m4/openat.m4 (gl_FUNC_OPENAT): Replace unlinkat if unlink is
broken.
* doc/posix-functions/unlink.texi (unlink): Document this.
* doc/posix-functions/unlinkat.texi (unlinkat): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
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.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Tue, 6 Oct 2009 13:09:13 +0000 (07:09 -0600)]
test-symlink: port to GNU/Hurd
* tests/test-symlink.h (test_symlink): Relax expected errno.
Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake [Tue, 6 Oct 2009 19:58:06 +0000 (13:58 -0600)]
doc: tweak more cygwin information
* doc/glibc-headers/getopt.texi (getopt.h): Cygwin 1.7 getopt is
now compatible with glibc.
* doc/posix-functions/getopt.texi (getopt): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>