modules/fcntl: fix error reporting by dupfd

* lib/fcntl.c (dupfd) [_WIN32]: Don't overwrite the value of
errno set by _open_osfhandle by EMFILE.  Convert errors
returned by DuplicateHandle to corresponding errno values.
remove spurious {
readlinkat: port to AIX 7.1

* doc/posix-functions/readlink.texi (readlink):
* doc/posix-functions/readlinkat.texi (readlinkat):
Mention AIX porting problem.
* lib/readlinkat.c (rpl_readlinkat) [HAVE_READLINKAT]:
New function.
* lib/unistd.in.h (readlinkat): Add replacement machinery.
* m4/readlinkat.m4 (gl_FUNC_READLINKAT): Check readlinkat signature.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add REPLACE_READLINKAT.
* modules/readlinkat (configure.ac): Also compile replacement
if REPLACE_READLINKAT.
* modules/unistd (unistd.h): Substitute REPLACE_READLINKAT.
symlinkat: port to AIX 7.1

* doc/posix-functions/symlinkat.texi (symlinkat):
Mention AIX porting problem.
* lib/symlinkat.c: Always include errno.h.
(rpl_symlinkat) [HAVE_SYMLINKAT]: New function.
* lib/unistd.in.h (symlinkat): Add replacement machinery.
* m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Check symlinkat behavior.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add REPLACE_SYMLINKAT.
* modules/symlinkat (Depends-on): Add fstatat if REPLACE_SYMLINKAT.
(configure.ac): Also compile replacement if REPLACE_SYMLINKAT.
* modules/unistd (unistd.h): Substitute REPLACE_SYMLINKAT.
bootstrap: only update the gnulib submodule

* build-aux/bootstrap: Restrict the "submodule update" command
to the gnulib path.

Reported by Reuben Thomas
bootstrap: print more diagnostics for missing programs

* build-aux/bootstrap: only suppress stderr when checking for
alternative program names.  This supports programs issuing non
standard error messages like:
  "Provide an AUTOMAKE_VERSION environment variable, please"
Reported by Ingo Schwarze with OpenBSD
iconv: avoid false detection of non-working iconv

The INBUF arguments of iconv can be either 'const char **'
or 'char **'.  If CC is g++, the difference causes a compile error
and thus leads to a false detection of non-working iconv.
Reported by Eli Zaretskii and Werner LEMBERG in:
<https://lists.gnu.org/archive/html/bug-gnulib/2014-10/msg00023.html>.
* m4/iconv.m4 (AM_ICONV_LINK): Try all possible argument types of
iconv.  Bump serial number.
socketlib, sockets, sys_socket: Use AC_REQUIRE to pacify autoconf.

Without this change, in bleeding-edge fileutils Autoconf complains
that gl_SOCKETLIB etc. are AC_REQUIREd after being invoked.
* modules/socketlib (configure.ac): AC_REQUIRE gl_SOCKETLIB.
* modules/sockets (configure.ac): AC_REQUIRE gl_SOCKETS.
* modules/sys_socket (configure.ac): AC_REQUIRE gl_HEADER_SYS_SOCKET.
obstack: tidy part 1

a) Rename temp fields.  temp.tempint and temp.tempptr just looks ugly
   to me, and result in overlong lines after later patches.
b) Move error handling code, to avoid a forward declaration and to
   simplify later patches in this series.

	* lib/obstack.h (struct obstack <temp>): Rename fields of union
	and update all uses.
	* lib/obstack.c: Include stdlib.h earlier.
	(obstack_exit_failure, obstack_alloc_failed_handler): Move later
	in file.
	(print_and_abort): Remove now redundant forward declaration.
obstack: tidy part 2

a) Don't be concerned about "not polluting the namespace with stddef.h
   symbols" in obstack.h, since gnulib string.h includes stddef.h
   anyway, and it seems unlikely that anyone would care.
b) Don't roll our own slow memcpy in _obstack_newchunk.
c) Rename obstack_free to _obstack_free.  This makes the naming
   consistent with other obstack functions and obviates the need for
   __obstack_free.  Ancient obstack.c defined both obstack_free and
   _obstack_free.  We continue to do that for _LIBC via an alias.
d) Miscellaneous macro fixes.  The expression used to test for gcc-2.8
   is clever, but nowadays gcc warns on undefined macros.  You'll get
   an undefined macro warning if simulating an old gcc with -U__GNUC__
   -U__GNUC_MINOR__ -D__GNUC__=1.

	* lib/obstack.h: Include stddef.h unconditionally.  Formatting fixes.
	(PTR_INT_TYPE): Delete, replace with ptrdiff_t.
	(__obstack_free): Delete, update refs.
	(_obstack_free): Rename from obstack_free.
	(__extension__): Avoid undefined macro warning for __GNUC_MINOR__.
	(obstack_object_size, obstack_room): Parenthesise !__GNUC__ versions.
	* lib/obstack.c: Don't include stddef.h.
	(COPYING_UNIT): Delete.
	(_obstack_begin): Formatting fix.
	(_obstack_newchunk): Use memcpy to move existing object to new chunk.
	(_obstack_free): Rename from __obstack_free, update alias.  Move
	undef of obstack_free to where it is needed.
obstack: 64-bit obstack support, part 1

a) Correct calls to alloc function, to use a size_t arg.  "long" is
   just wrong on targets like x86_64-mingw64 where "long" is 32 bits
   and "size_t" 64 bits.
b) Consolidate _obstack_begin and _obstack_begin1 code.

	* lib/obstack.h (struct obstack <chunkfun>): Correct prototype to
	use "size_t" rather than "long".
	(_obstack_begin, _obstack_begin1): Likewise.
	(obstack_init, obstack_begin, obstack_specify_allocation_with_arg,
	obstack_chunkfun): Update alloc function casts.
	* lib/obstack.c (CALL_CHUNKFUN): Update chunkfun cast.
	(chunkfun_type, freefun_type): New typdefs.
	(_obstack_begin_worker): Split out from ..
	(_obstack_begin, _obstack_begin_1): ..here.
obstack: 64-bit obstack support, part 2

This gets us 4G obstack support, without changing ABI compatibility,
apart from possibly introducing some signed/unsigned comparison
warnings in code that uses obstack.h.

a) Replace "int" size parameters, return values, and macro local vars
   with _OBSTACK_SIZE_T, an "unsigned int" for now.
b) Make obstack.chunk_size a _CHUNK_SIZE_T, an "unsigned long" for now.
c) Make all obstack macros checking available room use obstack_room.
   "next_free + desired > chunk_limit" may wrap the lhs for chunks
   allocated near the top of memory.
d) Use unsigned comparisons, and macro locals to support >2G on 32-bit.

	* lib/obstack.h (_OBSTACK_SIZE_T): Define.  Use throughout
	in place of "int" size parameters, return values and local vars.
	(_CHUNK_SIZE_T): Define.
	(struct obstack): Make chunk_size a _CHUNK_SIZE_T.  Make temp
	union use an _OBSTACK_SIZE_T integer type.
	For __GNUC__ versions of the following macros...
	(obstack_room): Rename local var.
	(obstack_make_room): Use obstack_room.
	(obstack_grow, obstack_grow0, obstack_1grow, obstack_ptr_grow,
	obstack_int_grow, obstack_blank): Likewise.
	(obstack_finish): Use unsigned comparison when comparing aligned
	next_free against chunk_limit.
	(obstack_free): Cast OBJ to remove possible const qualifier.
	For !__GNUC__ versions of the following macros...
	(obstack_make_room): Use obstack_room.
	(obstack_grow, obstack_grow0, obstack_1grow, obstack_ptr_grow,
	obstack_int_grow, obstack_blank): Likewise.
	(obstack_finish): Use unsigned comparision when comparing aligned
	next_free against chunk_limit.
	(obstack_free): Use temp.p and same comparisons as __GNUC__ version.
	* lib/obstack.c (_obstack_begin_worker): Make "size" parameter
	_OBSTACK_SIZE_T.
	(_obstack_begin, _obstack_begin_1): Likewise.
	(_obstack_newchunk): Likewise for length parameter.  Use size_t locals.
	(_obstack_memory_used): Return and use _OBSTACK_SIZE_T local.
obstack: 64-bit obstack support, part 3

This finally enables full 64-bit obstack support.  The glibc shared library
specific code is removed from obstack.c too, and the error handling code
conditionally compiled under control of another macro,
_OBSTACK_NO_ERROR_HANDLER.

	* lib/obstack.h: Include string.h earlier.
	(_OBSTACK_INTERFACE_VERSION): Define.
	(_OBSTACK_SIZE_T, _CHUNK_SIZE_T): Define as size_t for version 2.
	* lib/obstack.c: Don't include shlib-compat.h.
	(OBSTACK_INTERFACE_VERSION): Delete.
	(_OBSTACK_ELIDE_CODE): Rename from ELIDE_CODE.  Define when version 1
	glibc code is compatible with version 2.  Don't include stdio.h for
	__GNU_LIBRARY.
	(obstack_exit_failure, print_and_abort, obstack_alloc_failed_handler):
	Omit when _OBSTACK_NO_ERROR_HANDLER defined.  Include stdio.h here.
	(_obstack_compat, _obstack, _obstack_newchunk, obstack_free): Delete
	glibc shared library specific source.
obstack: use size_t alignments and check for overflow

* lib/obstack.c, lib/obstack.h (_obstack_begin, _obstack_begin_1):
* lib/obstack.c (_obstack_begin_worker, _obstack_newchunk):
* lib/obstack.h (struct obstack.alignment_mask):
Use _OBSTACK_SIZE_T, not int, for alignments.
* lib/obstack.c (_obstack_newchunk): Fail if the size calculation
overflows, e.g., when adding the alignment.
obstack: prefer alignof to calculating alignments by hand

* lib/obstack.c: Include <stdalign.h>.
(struct fooalign): Remove.
(DEFAULT_ALIGNMENT): Use alignof rather than the old offsetof hack.
* modules/obstack (Depends-on): Add stdalign.
obstack: prefer __alignof__ to alignof

This is for portability to pre-4.7 GCC when compiling glibc.
See Joseph S. Myers in:
http://sourceware.org/ml/libc-alpha/2014-10/msg00703.html
* lib/obstack.c (__alignof__) [!_LIBC && !__GNUC__]:
New macro, defined by including and using <alignof.h>.
(MAX): New macro.
(DEFAULT_ALIGNMENT, DEFAULT_ROUNDING): Redefine in terms of these.
Do not use enums as they are not portable to some broken compilers.
* modules/obstack (Depends-on): Depend on alignof, not stdalign.
maint: add missing ChangeLog entries for Modra's obstack changes

See: http://lists.gnu.org/archive/html/bug-gnulib/2014-10/msg00072.html
mountlist: don't use libmount to decide on dummy/remote

* lib/mountlist.c (read_file_system_list): Don't use the libmount
routines to determine whether a file system is dummy or remote,
as they're not currently compatible.  For example the remoteness
is determined on file system type (for which the list seems incomplete),
rather than simply checking for a ':' in the device name.
Also libmount currently determines that 'tmpfs' is a dummy file system
even though it has associated storage.
obstack: add NEWS entry for recent incompatible changes

* NEWS: Describe recent changes.
open, openat: document nonstandard FreeBSD, NetBSD O_NOFOLLOW errno

* doc/posix-functions/open.texi (open):
* doc/posix-functions/openat.texi (openat):
Document that these functions do not set errno to ELOOP when
a symlink is opened with O_NOFOLLOW.