]> Savannah Git Hosting - gnulib.git/commitdiff
linkat: use eloop-threshold
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 24 Dec 2020 19:38:48 +0000 (11:38 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 24 Dec 2020 20:06:49 +0000 (12:06 -0800)
* lib/linkat.c: Include eloop-threshold.h.
Do not include sys/param.h.
(MAXSYMLINKS): Remove.
(link_follow, linkat_follow): Use __eloop_threshold instead
of MAXSYMLINKS.
* m4/linkat.m4 (gl_FUNC_LINKAT): Omit sys/param.h check.
* modules/linkat (Depends-on): Add eloop-threshold.  Sort.

ChangeLog
lib/linkat.c
m4/linkat.m4
modules/linkat

index edca84874ceffd3332ce2abc4a5f3cf10ae8476f..7b1bcd8ffb0a93a6cac4c3511cf5c9de6d79e3fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2020-12-24  Paul Eggert  <eggert@cs.ucla.edu>
 
+       linkat: use eloop-threshold
+       * lib/linkat.c: Include eloop-threshold.h.
+       Do not include sys/param.h.
+       (MAXSYMLINKS): Remove.
+       (link_follow, linkat_follow): Use __eloop_threshold instead
+       of MAXSYMLINKS.
+       * m4/linkat.m4 (gl_FUNC_LINKAT): Omit sys/param.h check.
+       * modules/linkat (Depends-on): Add eloop-threshold.  Sort.
+
        canonicalize-lgpl: use eloop-threshold
        * lib/canonicalize-lgpl.c [!_LIBC]: Include eloop-threshold.h.
        (MAXSYMLINKS, __eloop_threshold): Remove.
index 13313e9d176f6d79c1df4efdf5d8c48f72d40109..6fc9635376e86e3fc6bc213ae81cce4e372706b7 100644 (file)
 
 #include "areadlink.h"
 #include "dirname.h"
+#include "eloop-threshold.h"
 #include "filenamecat.h"
 #include "openat-priv.h"
 
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-#ifndef MAXSYMLINKS
-# ifdef SYMLOOP_MAX
-#  define MAXSYMLINKS SYMLOOP_MAX
-# else
-#  define MAXSYMLINKS 20
-# endif
-#endif
-
 #if !HAVE_LINKAT || LINKAT_SYMLINK_NOTSUP
 
 /* Create a link.  If FILE1 is a symlink, either create a hardlink to
@@ -105,7 +95,7 @@ link_follow (char const *file1, char const *file2)
   char *name = (char *) file1;
   char *target;
   int result;
-  int i = MAXSYMLINKS;
+  int i = __eloop_threshold ();
 
   /* Using realpath or canonicalize_file_name is too heavy-handed: we
      don't need an absolute name, and we don't need to resolve
@@ -231,7 +221,7 @@ linkat_follow (int fd1, char const *file1, int fd2, char const *file2)
   char *name = (char *) file1;
   char *target;
   int result;
-  int i = MAXSYMLINKS;
+  int i = __eloop_threshold ();
 
   /* There is no realpathat.  */
   while (i-- && (target = areadlinkat (fd1, name)))
index e9b3d8266c66e30f091f21c11122b33a2892968e..a4e61c332ae7f1e45d6a03a9c9366ade56438da0 100644 (file)
@@ -1,4 +1,4 @@
-# serial 13
+# serial 14
 # See if we need to provide linkat replacement.
 
 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc.
@@ -16,7 +16,6 @@ AC_DEFUN([gl_FUNC_LINKAT],
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_CHECK_FUNCS_ONCE([linkat symlink])
-  AC_CHECK_HEADERS_ONCE([sys/param.h])
   if test $ac_cv_func_linkat = no; then
     HAVE_LINKAT=0
   else
index e6f70ffa45b668c6c993f85677324781f31b2396..1fb4f8ff4606aba09c6e484476a751d2dfa750a5 100644 (file)
@@ -9,20 +9,21 @@ m4/linkat.m4
 Depends-on:
 unistd
 extensions
+areadlink        [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
+at-internal      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 dirname-lgpl     [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
+eloop-threshold  [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 errno            [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 fcntl-h          [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 filenamecat-lgpl [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
-link-follow      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
-areadlink        [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
-at-internal      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 filename         [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 fstat            [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 getcwd-lgpl      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
-openat-h         [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
-openat-die       [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
+link-follow      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 link             [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 lstat            [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
+openat-die       [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
+openat-h         [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 same-inode       [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 save-cwd         [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 stat             [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]