]> 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, 27 Aug 2024 20:28:36 +0000 (22:28 +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 9ffb43fd6b18fa22f0a859a07bae221c88fa9f74..ff7162d1277dfac52a1deb8d1f7c533f039d8f74 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>
 
        getusershell: Don't completely ignore lines that contain a comment.
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 1c8b02c5350ff1ef81fe161ff9be88b0f0754faf..351a86ff021c4a76b8d96e8e8e856d801d7899ff 100644 (file)
@@ -1,5 +1,5 @@
 # mkdir-p.m4
-# serial 15
+# 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,
@@ -8,5 +8,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])
 ])