Bruno Haible [Sun, 8 Mar 2020 21:54:02 +0000 (22:54 +0100)]
*printf-posix: Document why it's overridden on some glibc systems.
Reported by Adrian Bunk <bunk@stusta.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00011.html>.
* doc/posix-functions/*printf.texi: Document the problem with the %n
directive on some glibc systems.
* m4/printf.m4 (gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N): Adjust
the cross-compilation guesses accordingly.
Paul Eggert [Sat, 7 Mar 2020 19:02:05 +0000 (11:02 -0800)]
open, openat: port to (O_RDWR | O_RDONLY) != 0
Potential portability problem reported by Dan Gohman in:
https://lists.gnu.org/r/bug-gnulib/2020-03/msg00000.html
* lib/open.c (open):
* lib/openat.c (rpl_openat):
Don’t assume O_RDONLY is disjoint from O_RDWR.
Bruno Haible [Sat, 7 Mar 2020 18:56:33 +0000 (19:56 +0100)]
findprog, relocatable-prog: Ignore directories during PATH search.
Reported by Frederick Eaton via Dmitry Goncharov in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00003.html>.
* lib/findprog.c (find_in_path): When the file found in a PATH element
is a directory, continue searching.
* lib/progreloc.c (maybe_executable): Likewise.
Paul Eggert [Sun, 23 Feb 2020 06:47:06 +0000 (22:47 -0800)]
fchmodat, lchmod: simplify
It appears that we may have overengineered lchmod and fchmodat,
in that the code was prepared for some hypothetical platforms but
was so complicated that it was hard to understand. I attempted to
improve the situation by simplifying the code when this
simplification should not hurt on real platforms; we can re-add
complexity later to port to platforms I didn’t know about.
* lib/fchmodat.c (fchmodat):
* lib/lchmod.c (lchmod):
Put the ‘defined __linux__ || defined __ANDROID__’ #ifdef only
around the /proc code that needs it.
* lib/fchmodat.c (fchmodat): Coalese calls to orig_fchmodat.
* lib/lchmod.c (__need_system_sys_stat_h): Omit; no longer needed.
Do not include <config.h> twice.
(orig_lchmod) [HAVE_LCHMOD]: Remove, since we need not wrap
lchmod on any known hosts.
(lchmod): Do not defer to fchmodat, so that the lchmod module
need not depend on the fchmodat module (which is a circular
dependency). Do not use openat, since ‘open’ suffices.
Coalesce calls to lchmod/chmod.
* lib/lchmod.c, lib/sys_stat.in.h (lchmod):
* m4/sys_stat_h.m4 (REPLACE_FSTAT):
* modules/lchmod (Depends-on, configure.ac):
* modules/sys_stat (Depends-on):
Do not worry about replacing lchmod, since that shouldn’t happen.
* m4/lchmod.m4 (gl_FUNC_LCHMOD): Do not check for fchmodat.
Do not worry about whether lchmod works on non-symlinks,
since every known lchmod works on non-symlinks.
* modules/lchmod (Depends-on):
Remove circular dependency on fchmodat.
Paul Eggert [Sat, 22 Feb 2020 20:09:11 +0000 (12:09 -0800)]
chmodat, chownat: new modules
These are split from fchmodat, fchownat. GNU Emacs needs the
POSIX-specified fchmodat, but not the gnulib-specified chmodat and
lchmodat. Split the latter two into a new module chmodat.
Similarly for fchownat. This the same basic idea for why statat
was split from fstatat on 2013-01-23.
* lib/chmodat.c, lib/openat.h (CHMODAT_INLINE):
Rename from FCHMODAT_INLINE. All uses changed.
* lib/chownat.c, lib/openat.h (CHOWNAT_INLINE):
Rename from FCHOWNAT_INLINE. All uses changed.
* lib/openat.h:
(chownat, lchownat): Define if GNULIB_CHOWNAT, not GNULIB_FCHOWNAT.
(chmodat, lchmodat): Define if GNULIB_CHMODAT, not GNULIB_FCHMODAT.
* modules/chmodat, modules/chownat, tests/test-chownat.c: New files.
* modules/fchmodat (Files:): Remove lib/fchmodat.c.
(configure.ac): Remove fchmodat module indicator.
(Makefile.am): Omit chmodat.c.
(Maintainer): Add self.
* modules/fchownat: Similarly, but for chown.
* tests/test-fchownat.c (BASE): Don't define if already defined.
(do_chown, do_lchown) [!TEST_CHOWNAT]: Test fchownat instead.
Bruno Haible [Sat, 22 Feb 2020 14:15:01 +0000 (15:15 +0100)]
gnulib-tool: Ensure copied files are writable.
Reported by Benno Fünfstück <benno.fuenfstueck@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-02/msg00101.html>.
* gnulib-tool (func_ensure_writable): New function.
(func_ln_s, func_hardlink, func_lookup_file, func_import,
func_create_testdir, copy-file): Invoke it after copying a file.
Bruno Haible [Sat, 22 Feb 2020 13:53:02 +0000 (14:53 +0100)]
users.txt: Update.
* users.txt: Update URLs to projects that have moved or switched to git.
Use canonical host names. Prefer gitweb over cgit. Prefer the tree view
over the summary view. Add gawk.
Paul Eggert [Sat, 22 Feb 2020 01:27:02 +0000 (17:27 -0800)]
largefile: remove _DARWIN_USE_64_BIT_INODE
It’s not needed in currently-supported macOS versions, and was
problematic anyway in MacOS X 10.5 which was the only version that
could use it. Problem reported by Peter Eisentraut in:
https://lists.gnu.org/r/bug-autoconf/2020-02/msg00004.html
* m4/largefile.m4 (AC_SYS_LARGEFILE):
Don’t define _DARWIN_USE_64_BIT_INODE.
This syncs with Autoconf master.
Paul Eggert [Fri, 21 Feb 2020 20:41:33 +0000 (12:41 -0800)]
Add ‘extern "C"’ to count-one-bits.h etc.
This ports these .h files to C++.
Problem reported by Simon Marchi in:
https://lists.gnu.org/r/bug-gnulib/2020-02/msg00110.html
* lib/count-leading-zeros.h, lib/count-one-bits.h:
* lib/count-trailing-zeros.h: Add ‘extern "C"’.
Bruno Haible [Sun, 16 Feb 2020 22:01:08 +0000 (23:01 +0100)]
fchmodat: Make more future-proof.
* m4/fchmodat.m4 (gl_FUNC_FCHMODAT): Define
NEED_FCHMODAT_NONSYMLINK_FIX.
(gl_PREREQ_FCHMODAT): New macro.
* lib/fchmodat.c (fchmodat): Test NEED_FCHMODAT_NONSYMLINK_FIX. Access
/proc only on Linux. Return EOPNOTSUPP only on Linux and on platforms
without lchmod function.
* modules/fchmodat (configure.ac): Invoke gl_PREREQ_FCHMODAT.
Bruno Haible [Sun, 16 Feb 2020 21:37:28 +0000 (22:37 +0100)]
lchmod: Make more future-proof.
* m4/lchmod.m4 (gl_FUNC_LCHMOD): Define NEED_LCHMOD_NONSYMLINK_FIX.
(gl_PREREQ_LCHMOD): New macro.
* lib/lchmod.c (orig_lchmod): New function.
(lchmod): Test NEED_LCHMOD_NONSYMLINK_FIX. Access /proc only on Linux.
Return EOPNOTSUPP only on Linux and on platforms without lchmod
function.
* modules/lchmod (configure.ac): Invoke gl_PREREQ_LCHMOD.
Paul Eggert [Sun, 16 Feb 2020 20:47:52 +0000 (12:47 -0800)]
xnanosleep: prefer pause, and get remaining time
Problem reported by Vladimir Panteleev in:
https://lists.gnu.org/r/bug-gnulib/2020-02/msg00052.html
* lib/xnanosleep.c: Include intprops.h, unistd.h.
(xnanosleep) [HAVE_PAUSE]: Prefer pause when sleeping infinitely.
(xnanosleep): Obtain remaining time when nanosleep is interrupted.
* m4/xnanosleep.m4 (gl_XNANOSLEEP): Check for 'pause'.
* modules/xnanosleep (Depends-on): Add intprops, unistd.
Bruno Haible [Fri, 14 Feb 2020 18:44:08 +0000 (19:44 +0100)]
wctype-h: Fix compilation errors in C++ (regression from 2020-01-25).
Reported by Christian Biesinger in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-02/msg00064.html>.
* lib/wctype.in.h (iswdigit, iswxdigit): Don't declare if the
corresponding module is not enabled.
* tests/test-wctype-h-c++.cc (iswdigit, iswxdigit): Don't check the
prototype if the corresponding module is not enabled.
Paul Eggert [Thu, 13 Feb 2020 18:41:10 +0000 (10:41 -0800)]
fchmodat, lchmod: port to buggy Linux filesystems
Problem reported by Florian Weimer in:
https://www.sourceware.org/ml/libc-alpha/2020-02/msg00534.html
* lib/fchmodat.c (fchmodat):
* lib/lchmod.c (lchmod):
Don’t assume that chmod on the O_PATH-opened fd will do
the right thing on a symbolic link.
* lib/fchmodat.c (fchmodat):
Don’t attempt to special-case
any flag value other than AT_SYMLINK_NOFOLLOW.
Bruno Haible [Tue, 11 Feb 2020 02:58:39 +0000 (03:58 +0100)]
pthread-mutex-tests, pthread-rwlock-tests: Fix link errors on HP-UX.
* modules/pthread-mutex-tests (Makefile.am): Link test-pthread-mutex
with $(LIB_SEMAPHORE).
* modules/pthread-rwlock-tests (Makefile.am): Link test-pthread-rwlock
with $(LIB_SEMAPHORE).
Bruno Haible [Sat, 8 Feb 2020 19:47:58 +0000 (20:47 +0100)]
fchmodat: Strengthen tests.
* tests/test-fchmodat.c (BASE): New macro.
(main): Use it, to avoid conflicts with other unit tests. Verify that
fchmodat changed the file permission bits.
Bruno Haible [Sat, 8 Feb 2020 19:38:01 +0000 (20:38 +0100)]
fchmodat: Improve cross-compilation guesses.
* m4/fchmodat.m4 (gl_FUNC_FCHMODAT): Require AC_CANONICAL_HOST. When
cross-compiling, guess depending on the platform.
* doc/posix-functions/fchmodat.texi: Clarify.
Bruno Haible [Sat, 8 Feb 2020 14:54:25 +0000 (15:54 +0100)]
doc: Update for glibc 2.31.
* doc/glibc-functions/pthread_clockjoin_np.texi: New file.
* doc/gnulib.texi: Include it.
* doc/pastposix-functions/h_errno.texi: Update.
* doc/posix-functions/*.texi: Likewise.
Paul Eggert [Sat, 8 Feb 2020 00:34:12 +0000 (16:34 -0800)]
fchmodat: AT_SYMLINK_NOFOLLOW fix for non-symlinks
Fix lchmod, and fchmodat with AT_SYMLINK_NOFOLLOW, so that
they act like chmod on non-symlinks.
* NEWS:
* doc/glibc-functions/lchmod.texi (lchmod):
* doc/posix-functions/fchmodat.texi (fchmodat):
Mention this.
* lib/fchmodat.c: Define __need_system_sys_stat_h before including
config.h, and undef it after including sys/stat.h the first time.
Include fcntl.h, stdio.h, unistd.h, intprops.h, and include
sys/stat.h a second time after defining orig_fchmodat.
(orig_fchmodat) [HAVE_FCHMODAT]: New function.
(fchmodat) [HAVE_FCHMODAT]: Work around the AT_SYMLINK_NOFOLLOW bug.
* lib/lchmod.c: New file.
* lib/sys_stat.in.h (fchmodat, lchmod):
Support replacing these functions.
* m4/fchmodat.m4 (gl_FUNC_FCHMODAT): If fchmodat exists,
test that AT_SYMLINK_NOFOLLOW works on non-symlinks.
* m4/lchmod.m4 (gl_FUNC_LCHMOD): Check for lstat.
Test that lchmod works on non-symlinks.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS):
Default REPLACE_FCHMODAT and REPLACE_LCHMOD to 0.
* modules/fchmodat (Depends-on): Add fstatat, intprops, lchmod, unistd.
(Depends-on, configure.ac): Check REPLACE_FCHMODAT too.
* modules/lchmod (Files): Add lib/lchmod.c.
(Depends-on): Add errno, fcntl-h, fchmodat, intprops, lstat, unistd.
(configure.ac): Compile lchmod.c if needed.
(lib_SOURCES): Add lchmod.c.
* modules/sys_stat (sys/stat.h): Substitute REPLACE_FCHMODAT
and REPLACE_LCHMOD.
* tests/test-fchmodat.c: Include fcntl.h, sys/stat.h.
(main): Test fchmodat with AT_SYMLINK_NOFOLLOW on non-symlinks.
Marc Dionne [Wed, 5 Feb 2020 21:35:12 +0000 (13:35 -0800)]
mountlist: Consider AFS filesystems as remote
df --local relies on the ME_REMOTE macro to determine if a given
mount entry should be considered "local". There is special logic
for nfs and smb/cifs mounts, but /afs as mounted by OpenAFS, the
kernel's kafs module or AuriStorFS is treated as a local mount.
* lib/mountlist.c (ME_REMOTE): Treat mounts of type 'afs'
(OpenAFS, kernel kafs) and 'auristorfs' (AuriStorFS) as remote.
Paul Eggert [Mon, 3 Feb 2020 21:20:09 +0000 (13:20 -0800)]
Port _Noreturn to older Clang
Problem reported by Jeffery Walton in:
https://lists.gnu.org/r/bug-gnulib/2020-02/msg00013.html
* lib/_Noreturn.h (_Noreturn):
* m4/gnulib-common.m4 (gl_COMMON_BODY):
Assume _Noreturn works in Clang 3.5 and later.
It is documented to work in Clang 3.5:
http://releases.llvm.org/3.5.0/tools/clang/docs/AttributeReference.html
and is not documented in Clang 3.4:
https://releases.llvm.org/3.4/tools/clang/docs/LanguageExtensions.html
Apple sets __clang_version__ to a different value, so use
__apple_build_version__ there. See:
https://lists.gnu.org/r/bug-gnulib/2020-02/msg00017.html
Pádraig Brady [Tue, 4 Feb 2020 00:57:12 +0000 (00:57 +0000)]
test-canonicalize: avoid an unused function warning
* tests/test-canonicalize.c: Protect the inclusion of null-ptr.h
with the same guard as that used to protect usage of the null_ptr
function, so that one doesn't get a -Wunused warning
about the function being defined but unused.
* tests/test-canonicalize-lgpl.c: Likewise.
Pádraig Brady [Sun, 2 Feb 2020 16:06:48 +0000 (16:06 +0000)]
read-file: reduce max size from SIZE_MAX to PTRDIFF_MAX
On x86_64 with glibc-2.30, gcc 9.2 is giving:
error: argument 2 value '18446744073709551615'
exceeds maximum object size 9223372036854775807
[-Werror=alloc-size-larger-than=]
The details of this restriction are discussed at:
https://stackoverflow.com/q/42574890/4421
* lib/read-file.c: s/SIZE_MAX/PTRDIFF_MAX/