bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] linkat: replace on OS X 10.10


From: Pádraig Brady
Subject: [PATCH 1/2] linkat: replace on OS X 10.10
Date: Fri, 31 Oct 2014 18:25:22 +0000

* m4/linkat.m4 (gl_FUNC_LINKAT): linkat() is available on Yosemite
but not usable because it doesn't support creating hardlinks
to symlinks.  Therefore add a generic test for this capability
and replace with our emulation if needed.
---
 ChangeLog    |    8 ++++++++
 m4/linkat.m4 |   22 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0d6c285..7676634 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-10-31  Pádraig Brady  <address@hidden>
+
+       linkat: replace on OS X 10.10
+       * m4/linkat.m4 (gl_FUNC_LINKAT): linkat() is available on Yosemite
+       but not usable because it doesn't support creating hardlinks
+       to symlinks.  Therefore add a generic test for this capability
+       and replace with our emulation if needed.
+
 2014-10-30  Pádraig Brady  <address@hidden>
 
        mountlist: don't use libmount to decide on dummy/remote
diff --git a/m4/linkat.m4 b/m4/linkat.m4
index 2da0e30..c9463b1 100644
--- a/m4/linkat.m4
+++ b/m4/linkat.m4
@@ -20,6 +20,25 @@ AC_DEFUN([gl_FUNC_LINKAT],
   if test $ac_cv_func_linkat = no; then
     HAVE_LINKAT=0
   else
+    dnl OS X Yosemite has linkat() but it's not sufficient
+    dnl to our needs since it doesn't support creating
+    dnl hardlinks to symlinks.  Therefore check for that
+    dnl capability before considering using the system version.
+    AC_CACHE_CHECK([whether linkat() can link symlinks],
+      [gl_cv_func_linkat_nofollow],
+      [rm -rf conftest.l1 conftest.l2
+       ln -s target conftest.l1
+       AC_RUN_IFELSE([AC_LANG_PROGRAM(
+                        [[#include <fcntl.h>
+                          #include <unistd.h>
+                        ]],
+                        [return linkat (AT_FDCWD, "conftest.l1", AT_FDCWD,
+                                            "conftest.l2", 0);
+                        ])],
+         [gl_cv_func_linkat_nofollow=yes],
+         [gl_cv_func_linkat_nofollow=no])
+       rm -rf conftest.l1 conftest.l2])
+
     AC_CACHE_CHECK([whether linkat(,AT_SYMLINK_FOLLOW) works],
       [gl_cv_func_linkat_follow],
       [rm -rf conftest.f1 conftest.f2
@@ -37,6 +56,7 @@ choke me
          [gl_cv_func_linkat_follow=yes],
          [gl_cv_func_linkat_follow="need runtime check"])
        rm -rf conftest.f1 conftest.f2])
+
     AC_CACHE_CHECK([whether linkat handles trailing slash correctly],
       [gl_cv_func_linkat_slash],
       [rm -rf conftest.a conftest.b conftest.c conftest.d
@@ -85,7 +105,9 @@ choke me
       *yes) gl_linkat_slash_bug=0 ;;
       *)    gl_linkat_slash_bug=1 ;;
     esac
+
     if test "$gl_cv_func_linkat_follow" != yes \
+       || test "$gl_cv_func_linkat_nofollow" != yes \
        || test $gl_linkat_slash_bug = 1; then
       REPLACE_LINKAT=1
       AC_DEFINE_UNQUOTED([LINKAT_TRAILING_SLASH_BUG], [$gl_linkat_slash_bug],
-- 
1.7.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]