From 4131c37368040602add83fb12dfda11505f884e7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 5 Oct 2006 22:49:57 +0000 Subject: [PATCH] [lib/ChangeLog] Fix some Darwin-7.9.0 porting problems reported by Bruno Haible in . * dirchownmod.c: Include lchown.h. * lchown.c: Don't include files that lchown.h now includes. Don't declare chown, since lchown.h now does that. * lchown.h: Include errno.h, sys/types.h, unistd.h. (lchown): Define to rpl_chown if lchown is declared but does not exist. Declare using a prototype if lchown is not declared. Add a copyright notice. * mkstemp.h: Include . * openat.c: Include lchown.h. [m4/ChangeLog] * lchown.m4 (gl_FUNC_LCHOWN): Check whether lchown is declared. --- lib/ChangeLog | 12 ++++++++++++ lib/dirchownmod.c | 1 + lib/lchown.c | 9 +-------- lib/lchown.h | 33 +++++++++++++++++++++++++++++++++ lib/mkstemp.h | 1 + lib/openat.c | 1 + m4/ChangeLog | 2 ++ m4/lchown.m4 | 3 ++- 8 files changed, 53 insertions(+), 9 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index bf1496aea..666478792 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,17 @@ 2006-10-05 Paul Eggert + Fix some Darwin-7.9.0 porting problems reported by Bruno Haible in + . + * dirchownmod.c: Include lchown.h. + * lchown.c: Don't include files that lchown.h now includes. + Don't declare chown, since lchown.h now does that. + * lchown.h: Include errno.h, sys/types.h, unistd.h. + (lchown): Define to rpl_chown if lchown is declared but + does not exist. Declare using a prototype if lchown is not + declared. Add a copyright notice. + * mkstemp.h: Include . + * openat.c: Include lchown.h. + * fcntl_.h (O_NOFOLLOW): Don't depend on O_NOFOLLOW_IS_INEFFECTIVE; we now test for that separately. * fts.c (fts_safe_changedir): Inspect HAVE_WORKING_O_NOFOLLOW diff --git a/lib/dirchownmod.c b/lib/dirchownmod.c index 3b654468f..b3e951808 100644 --- a/lib/dirchownmod.c +++ b/lib/dirchownmod.c @@ -28,6 +28,7 @@ #include #include "lchmod.h" +#include "lchown.h" #include "stat-macros.h" #ifndef HAVE_FCHMOD diff --git a/lib/lchown.c b/lib/lchown.c index f015cde9f..855db8f55 100644 --- a/lib/lchown.c +++ b/lib/lchown.c @@ -21,16 +21,9 @@ #include -#include -#include -#include - #include "lchown.h" -#include "stat-macros.h" -/* Declare chown to avoid a warning. Don't include unistd.h, - because it may have a conflicting prototype for lchown. */ -int chown (); +#include "stat-macros.h" /* Work just like chown, except when FILE is a symbolic link. In that case, set errno to EOPNOTSUPP and return -1. diff --git a/lib/lchown.h b/lib/lchown.h index d4824b171..6816d1f12 100644 --- a/lib/lchown.h +++ b/lib/lchown.h @@ -1,3 +1,36 @@ +/* Declare a replacement for lchown on hosts that lack it. + + Copyright (C) 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering. */ + +#include +#include +#include + +#if HAVE_DECL_LCHOWN +# if ! HAVE_LCHOWN +# undef lchown +# define lchown rpl_chown +# endif +#else +int lchown (char const *, uid_t, gid_t); +#endif + /* Some systems don't have EOPNOTSUPP. */ #ifndef EOPNOTSUPP # ifdef ENOTSUP diff --git a/lib/mkstemp.h b/lib/mkstemp.h index 69e6fec0a..9ed74116d 100644 --- a/lib/mkstemp.h +++ b/lib/mkstemp.h @@ -19,6 +19,7 @@ /* written by Jim Meyering */ #include +#include #ifdef __MKSTEMP_PREFIX # define _GL_CONCAT(x, y) x ## y diff --git a/lib/openat.c b/lib/openat.c index 82b4a06cf..7f92c7cc7 100644 --- a/lib/openat.c +++ b/lib/openat.c @@ -26,6 +26,7 @@ #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ #include "fcntl--.h" +#include "lchown.h" #include "lstat.h" #include "openat-priv.h" #include "save-cwd.h" diff --git a/m4/ChangeLog b/m4/ChangeLog index 814a42694..1b763ebc2 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,5 +1,7 @@ 2006-10-05 Paul Eggert + * lchown.m4 (gl_FUNC_LCHOWN): Check whether lchown is declared. + * fcntl_h.m4 (gl_FCNTL_H): Define HAVE_WORKING_O_NOFOLLOW instead of O_NOFOLLOW_IS_INEFFECTIVE. Define HAVE_WORKING_O_NOATIME if O_NOATIME works. diff --git a/m4/lchown.m4 b/m4/lchown.m4 index ae54522da..f64dd0820 100644 --- a/m4/lchown.m4 +++ b/m4/lchown.m4 @@ -1,4 +1,4 @@ -#serial 9 +#serial 10 dnl Copyright (C) 1998, 2001, 2003, 2004, 2005, 2006 Free Software dnl Foundation, Inc. @@ -15,5 +15,6 @@ AC_DEFUN([gl_FUNC_LCHOWN], AC_REQUIRE([AC_TYPE_UID_T]) AC_REQUIRE([gl_FUNC_CHOWN]) AC_REQUIRE([gl_STAT_MACROS]) + AC_CHECK_DECLS_ONCE([lchown]) AC_REPLACE_FUNCS(lchown) ]) -- 2.11.0