2006-10-05 Paul Eggert <eggert@cs.ucla.edu>
+ Fix some Darwin-7.9.0 porting problems reported by Bruno Haible in
+ <http://lists.gnu.org/archive/html/bug-coreutils/2006-10/msg00063.html>.
+ * 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 <unistd.h>.
+ * 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
#include <unistd.h>
#include "lchmod.h"
+#include "lchown.h"
#include "stat-macros.h"
#ifndef HAVE_FCHMOD
#include <config.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-
#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.
+/* 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 <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#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
/* written by Jim Meyering */
#include <stdlib.h>
+#include <unistd.h>
#ifdef __MKSTEMP_PREFIX
# define _GL_CONCAT(x, y) x ## y
#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"
2006-10-05 Paul Eggert <eggert@cs.ucla.edu>
+ * 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.
-#serial 9
+#serial 10
dnl Copyright (C) 1998, 2001, 2003, 2004, 2005, 2006 Free Software
dnl Foundation, Inc.
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)
])