summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog21
-rw-r--r--NEWS3
-rw-r--r--lib/dirchownmod.c3
-rw-r--r--lib/lchmod.h34
-rw-r--r--lib/sys_stat.in.h31
-rw-r--r--m4/lchmod.m412
-rw-r--r--m4/sys_stat_h.m44
-rw-r--r--modules/lchmod6
-rw-r--r--modules/sys_stat4
9 files changed, 76 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index 92c2d67595..d2f0bc965d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2008-10-18 Bruno Haible <bruno@clisp.org>
+ * lib/dirchownmod.c: Don't include lchmod.h.
+
+ Move the lchmod() declaration to <sys/stat.h>.
+ * lib/lchmod.h: Remove file.
+ * lib/sys_stat.in.h: Add placeholder for GL_LINK_WARNING.
+ (lchmod): New declaration, moved here from lib/lchown.h.
+ * m4/lchmod.m4 (gl_FUNC_LCHMOD): Require gl_SYS_STAT_H_DEFAULTS and
+ AC_USE_SYSTEM_EXTENSIONS. Set HAVE_LCHMOD.
+ * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Initialize GNULIB_LCHMOD
+ and HAVE_LCHMOD.
+ * modules/lchmod (Files): Remove lib/lchmod.h.
+ (Depends-on): Add sys_stat, extensions.
+ (configure.ac): Invoke gl_SYS_STAT_MODULE_INDICATOR.
+ (Include): Specify <sys/stat.h> instead of lchmod.h.
+ * modules/sys_stat (Depends-on): Add link-warning.
+ (Makefile.am): Substitute GNULIB_LCHMOD, HAVE_LCHMOD, and the
+ definition of GL_LINK_WARNING.
+ * NEWS: Mention the change.
+
+2008-10-18 Bruno Haible <bruno@clisp.org>
+
* lib/fchdir.c: Don't include dirfd.h.
* lib/fts.c: Likewise.
* lib/getcwd.c: Likewise.
diff --git a/NEWS b/NEWS
index bacb310ed7..9bd4337f8f 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ User visible incompatible changes
Date Modules Changes
+2008-10-18 lchmod The include file is changed from "lchmod.h" to
+ <sys/stat.h>.
+
2008-10-18 dirfd The include file is changed from "dirfd.h" to
<dirent.h>.
diff --git a/lib/dirchownmod.c b/lib/dirchownmod.c
index f2646f1429..3b21a758a5 100644
--- a/lib/dirchownmod.c
+++ b/lib/dirchownmod.c
@@ -1,6 +1,6 @@
/* Change the ownership and mode bits of a directory.
- Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007, 2008 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
@@ -26,7 +26,6 @@
#include <sys/stat.h>
#include <unistd.h>
-#include "lchmod.h"
#include "stat-macros.h"
#ifndef HAVE_FCHMOD
diff --git a/lib/lchmod.h b/lib/lchmod.h
deleted file mode 100644
index d6ea493d97..0000000000
--- a/lib/lchmod.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Provide a replacement for lchmod on hosts that lack it.
-
- Copyright (C) 2005 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Paul Eggert. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifndef HAVE_LCHMOD
-
-/* The lchmod replacement follows symbolic links. Callers should take
- this into account; lchmod should be applied only to arguments that
- are known to not be symbolic links. On hosts that lack lchmod,
- this can lead to race conditions between the check and the
- invocation of lchmod, but we know of no workarounds that are
- reliable in general. You might try requesting support for lchmod
- from your operating system supplier. */
-
-# define lchmod chmod
-#endif
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 6226544762..fef9dd6cce 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -1,5 +1,5 @@
/* Provide a more complete sys/stat header file.
- Copyright (C) 2006-2008 Free Software Foundation, Inc.
+ Copyright (C) 2005-2008 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
@@ -33,6 +33,8 @@
#ifndef _GL_SYS_STAT_H
#define _GL_SYS_STAT_H
+/* The definition of GL_LINK_WARNING is copied here. */
+
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
headers that may declare mkdir(). */
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
@@ -291,5 +293,32 @@ rpl_mkdir (char const *name, mode_t mode)
# endif
#endif
+
+/* Declare BSD extensions. */
+
+#if @GNULIB_LCHMOD@
+/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
+ denotes a symbolic link. */
+# if !@HAVE_LCHMOD@
+/* The lchmod replacement follows symbolic links. Callers should take
+ this into account; lchmod should be applied only to arguments that
+ are known to not be symbolic links. On hosts that lack lchmod,
+ this can lead to race conditions between the check and the
+ invocation of lchmod, but we know of no workarounds that are
+ reliable in general. You might try requesting support for lchmod
+ from your operating system supplier. */
+# define lchmod chmod
+# endif
+# if 0 /* assume already declared */
+extern int lchmod (const char *filename, mode_t mode);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lchmod
+# define lchmod(f,m) \
+ (GL_LINK_WARNING ("lchmod is unportable - " \
+ "use gnulib module lchmod for portability"), \
+ lchmod (f, m))
+#endif
+
#endif /* _GL_SYS_STAT_H */
#endif /* _GL_SYS_STAT_H */
diff --git a/m4/lchmod.m4 b/m4/lchmod.m4
index 06467a04b0..8270d3ed02 100644
--- a/m4/lchmod.m4
+++ b/m4/lchmod.m4
@@ -1,6 +1,6 @@
-#serial 2
+#serial 3
-dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -10,5 +10,13 @@ dnl Provide a replacement for lchmod on hosts that lack it.
AC_DEFUN([gl_FUNC_LCHMOD],
[
+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+
+ dnl Persuade glibc <sys/stat.h> to declare lchmod().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
AC_CHECK_FUNCS_ONCE([lchmod])
+ if test $ac_cv_func_lchmod = no; then
+ HAVE_LCHMOD=0
+ fi
])
diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4
index cfe80110c6..3fb6b5c0d5 100644
--- a/m4/sys_stat_h.m4
+++ b/m4/sys_stat_h.m4
@@ -1,4 +1,4 @@
-# sys_stat_h.m4 serial 8 -*- Autoconf -*-
+# sys_stat_h.m4 serial 9 -*- Autoconf -*-
dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -50,6 +50,8 @@ AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
[
+ GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD])
dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
])
diff --git a/modules/lchmod b/modules/lchmod
index 63b4cf6e30..a0ac7a5346 100644
--- a/modules/lchmod
+++ b/modules/lchmod
@@ -2,18 +2,20 @@ Description:
lchmod that is actually chmod (!) on hosts lacking lchmod
Files:
-lib/lchmod.h
m4/lchmod.m4
Depends-on:
+sys_stat
+extensions
configure.ac:
gl_FUNC_LCHMOD
+gl_SYS_STAT_MODULE_INDICATOR([lchmod])
Makefile.am:
Include:
-"lchmod.h"
+<sys/stat.h>
License:
GPL
diff --git a/modules/sys_stat b/modules/sys_stat
index f36f57a6d1..84a7f36c1f 100644
--- a/modules/sys_stat
+++ b/modules/sys_stat
@@ -7,6 +7,7 @@ m4/sys_stat_h.m4
Depends-on:
include_next
+link-warning
configure.ac:
gl_HEADER_SYS_STAT_H
@@ -24,8 +25,11 @@ sys/stat.h: sys_stat.in.h
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+ -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
+ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
-e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
-e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
+ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
< $(srcdir)/sys_stat.in.h; \
} > $@-t
mv $@-t $@