]> Savannah Git Hosting - gnulib.git/commitdiff
fchownat: Fix compilation error on Android 4.3.
authorBruno Haible <bruno@clisp.org>
Thu, 24 Jan 2019 22:51:11 +0000 (23:51 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 25 Jan 2019 01:14:26 +0000 (02:14 +0100)
* lib/unistd.in.h: Include <sys/stat.h> when module 'fchownat' is in
use.
* m4/fchownat.m4 (gl_FUNC_FCHOWNAT_DEREF_BUG,
gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG): Include also <sys/stat.h>.
* doc/posix-functions/fchownat.texi: Mention the issue.

ChangeLog
doc/posix-functions/fchownat.texi
lib/unistd.in.h
m4/fchownat.m4

index 7ba92a91926b27d81b892bb60d3e459e140deb15..56066811850e5a876e849f97a76a95d876a7682c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-01-24  Bruno Haible  <bruno@clisp.org>
+
+       fchownat: Fix compilation error on Android 4.3.
+       * lib/unistd.in.h: Include <sys/stat.h> when module 'fchownat' is in
+       use.
+       * m4/fchownat.m4 (gl_FUNC_FCHOWNAT_DEREF_BUG,
+       gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG): Include also <sys/stat.h>.
+       * doc/posix-functions/fchownat.texi: Mention the issue.
+
 2019-01-23  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool: Support running testdirs on Android.
index c33bdc40d2ab7bef810a400c85228a2e7b65ddf0..47a7225adc90d842494b8f1643431accdc4e148b 100644 (file)
@@ -9,6 +9,18 @@ Gnulib module: fchownat
 Portability problems fixed by Gnulib:
 @itemize
 @item
+This function is missing on some platforms:
+glibc 2.3.6, Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8,
+AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Cygwin 1.5.x, mingw, MSVC 14, Interix 3.5, BeOS.
+But the replacement function is not safe to be used in libraries and
+is not multithread-safe.  Also, the replacement may fail to change
+symlinks if @code{lchown} is unsupported, or fail altogether if
+@code{chown} is unsupported.
+@item
+This function is declared in @code{<sys/stat.h>}, not in @code{<unistd.h>},
+on some platforms:
+Android 4.3.
+@item
 Some platforms fail to detect trailing slash on non-directories, as in
 @code{fchown(dir,"link-to-file/",uid,gid,flag)}:
 Solaris 9.
@@ -19,14 +31,6 @@ Linux kernel 2.6.17.
 @item
 This function does not fail for an empty filename on some platforms:
 Linux with glibc < 2.11.
-@item
-This function is missing on some platforms:
-glibc 2.3.6, Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8,
-AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Cygwin 1.5.x, mingw, MSVC 14, Interix 3.5, BeOS.
-But the replacement function is not safe to be used in libraries and
-is not multithread-safe.  Also, the replacement may fail to change
-symlinks if @code{lchown} is unsupported, or fail altogether if
-@code{chown} is unsupported.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 49e56734bfa3f8f652df6d4a5eca7cab7ca0e8b8..eb2534e6037157a146b73242803d9351ac19d469 100644 (file)
 # include <netdb.h>
 #endif
 
+/* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
+    && !defined __GLIBC__
+# include <sys/stat.h>
+#endif
+
 /* MSVC defines off_t in <sys/types.h>.
    May also define off_t to a 64-bit type on native Windows.  */
 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
index 5cca8b5a7d0b5b921c819a68965f6291a93ea67d..023e3cb41df4896de27952c070d05e5512e4f157 100644 (file)
@@ -1,4 +1,4 @@
-# fchownat.m4 serial 2
+# fchownat.m4 serial 3
 dnl Copyright (C) 2004-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -56,6 +56,8 @@ AC_DEFUN([gl_FUNC_FCHOWNAT_DEREF_BUG],
           [[
 #include <fcntl.h>
 #include <unistd.h>
+/* Android 4.3 declares fchownat() in <sys/stat.h> instead.  */
+#include <sys/stat.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -86,6 +88,8 @@ AC_DEFUN([gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG],
        [AC_LANG_PROGRAM(
           [[#include <unistd.h>
             #include <fcntl.h>
+            /* Android 4.3 declares fchownat() in <sys/stat.h> instead.  */
+            #include <sys/stat.h>
           ]],
           [[int fd;
             int ret;