X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=m4%2Funlink.m4;h=1c559af67d18080d6df88becd39e11f900b3e26c;hb=423d3cac13c30bb0d5f85e5fac6ab1406ed1731a;hp=01f2aabf4d9a7abce33c4d1b22a491b6daaf2dbb;hpb=12107b837dd1b31678c9e14923ac989bad91a92d;p=gnulib.git diff --git a/m4/unlink.m4 b/m4/unlink.m4 index 01f2aabf4..1c559af67 100644 --- a/m4/unlink.m4 +++ b/m4/unlink.m4 @@ -1,4 +1,4 @@ -# unlink.m4 serial 4 +# unlink.m4 serial 6 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_UNLINK], AC_REQUIRE([gl_AC_DOS]) AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) - dnl Detect Solaris 9 and FreeBSD 7.2 bug. + dnl Detect FreeBSD 7.2, AIX 7.1, Solaris 9 bug. AC_CACHE_CHECK([whether unlink honors trailing slashes], [gl_cv_func_unlink_honors_slashes], [touch conftest.file @@ -21,21 +21,35 @@ AC_DEFUN([gl_FUNC_UNLINK], [AC_LANG_PROGRAM( [[#include #include -]], [[if (!unlink ("conftest.file/") || errno != ENOTDIR) return 1; + ]], + [[int result = 0; + if (!unlink ("conftest.file/")) + result |= 1; + else if (errno != ENOTDIR) + result |= 2; #if HAVE_LSTAT - if (!unlink ("conftest.lnk/") || errno != ENOTDIR) return 2; + if (!unlink ("conftest.lnk/")) + result |= 4; + else if (errno != ENOTDIR) + result |= 8; #endif - ]])], + return result; + ]])], [gl_cv_func_unlink_honors_slashes=yes], [gl_cv_func_unlink_honors_slashes=no], [gl_cv_func_unlink_honors_slashes="guessing no"]) rm -f conftest.file conftest.lnk]) dnl Detect MacOS X 10.5.6 bug: On read-write HFS mounts, unlink("..") or dnl unlink("../..") succeeds without doing anything. - AC_CACHE_CHECK([whether unlink of a parent directory fails is it should], + AC_CACHE_CHECK([whether unlink of a parent directory fails as it should], [gl_cv_func_unlink_parent_fails], [case "$host_os" in darwin*) + dnl Try to unlink a subdirectory of /tmp, because /tmp is usually on a + dnl HFS mount on MacOS X. Use a subdirectory, owned by the current + dnl user, because otherwise unlink() may fail due to permissions + dnl reasons, and because when running as root we don't want to risk + dnl destroying the entire /tmp. if { # Use the mktemp program if available. If not available, hide the error # message. @@ -52,23 +66,27 @@ AC_DEFUN([gl_FUNC_UNLINK], (umask 077 && mkdir "$tmp") }; then mkdir "$tmp/subdir" - export tmp + GL_SUBDIR_FOR_UNLINK="$tmp/subdir" + export GL_SUBDIR_FOR_UNLINK AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include #include int main () { - if (chdir (getenv ("tmp")) != 0) - return 1; - return unlink ("..") == 0; + int result = 0; + if (chdir (getenv ("GL_SUBDIR_FOR_UNLINK")) != 0) + result |= 1; + else if (unlink ("..") == 0) + result |= 2; + return result; } ]])], [gl_cv_func_unlink_parent_fails=yes], [gl_cv_func_unlink_parent_fails=no], [gl_cv_func_unlink_parent_fails="guessing no"]) + unset GL_SUBDIR_FOR_UNLINK rm -rf "$tmp" - unset tmp else gl_cv_func_unlink_parent_fails="guessing no" fi