]> Savannah Git Hosting - gnulib.git/commitdiff
mkdir-p: Don't reference an undefined function on native Windows.
authorBruno Haible <bruno@clisp.org>
Tue, 27 Aug 2024 20:28:36 +0000 (22:28 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 17 Sep 2024 13:24:20 +0000 (15:24 +0200)
* m4/mkdir-p.m4 (gl_MKDIR_PARENTS): Test whether fchown exists.
* lib/dirchownmod.c (fchown): Define to a fallback if the system does
not have fchown.
(dirchownmod): Test HAVE_FCHOWN.

ChangeLog
lib/dirchownmod.c
m4/mkdir-p.m4

index 2238efe01557a19da7a73722b8c4d9de0a72a241..852c705a310bf0086e0c1b8f310a414c15caebeb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-08-27  Bruno Haible  <bruno@clisp.org>
+
+       mkdir-p: Don't reference an undefined function on native Windows.
+       * m4/mkdir-p.m4 (gl_MKDIR_PARENTS): Test whether fchown exists.
+       * lib/dirchownmod.c (fchown): Define to a fallback if the system does
+       not have fchown.
+       (dirchownmod): Test HAVE_FCHOWN.
+
 2024-08-27  Bruno Haible  <bruno@clisp.org>
 
        fts: Don't assume that a pointer is as wide as a 'long'.
index 633e6cb5dad4f80ef983e8b81667ec83c3c8ddd4..d5f7b5432abeec6c0e45da102a1c7da0a1eeeddf 100644 (file)
 # define fchmod(fd, mode) (-1)
 #endif
 
+#ifndef HAVE_FCHOWN
+# define HAVE_FCHOWN 0
+# undef fchown
+# define fchown(fd, owner, group) (-1)
+#endif
+
 /* Change the ownership and mode bits of a directory.  If FD is
    nonnegative, it should be a file descriptor associated with the
    directory; close it before returning.  DIR is the name of the
@@ -94,7 +100,7 @@ dirchownmod (int fd, char const *dir, mode_t mkdir_mode,
           if ((owner != (uid_t) -1 && owner != st.st_uid)
               || (group != (gid_t) -1 && group != st.st_gid))
             {
-              result = (0 <= fd
+              result = (HAVE_FCHOWN && 0 <= fd
                         ? fchown (fd, owner, group)
                         : mkdir_mode != (mode_t) -1
                         ? lchown (dir, owner, group)
index 70676eaa5cd4adbf8f710dc0e1e597dc05548fd1..35dd209f795f3a2e2bfdc32173938fa0f2876ec2 100644 (file)
@@ -1,4 +1,4 @@
-# mkdir-p.m4 serial 15
+# mkdir-p.m4 serial 16
 dnl Copyright (C) 2002-2006, 2009-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,5 +7,5 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_MKDIR_PARENTS],
 [
   dnl Prerequisites of lib/dirchownmod.c.
-  AC_CHECK_FUNCS_ONCE([fchmod])
+  AC_CHECK_FUNCS_ONCE([fchmod fchown])
 ])