From: Paul Eggert Date: Thu, 24 Dec 2020 19:38:48 +0000 (-0800) Subject: linkat: use eloop-threshold X-Git-Tag: v1.0~3320 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=0008af95e3335e70bc5a08f17a68378bd32f92ab;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index edca84874c..7b1bcd8ffb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2020-12-24 Paul Eggert + 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. diff --git a/lib/linkat.c b/lib/linkat.c index 13313e9d17..6fc9635376 100644 --- a/lib/linkat.c +++ b/lib/linkat.c @@ -29,20 +29,10 @@ #include "areadlink.h" #include "dirname.h" +#include "eloop-threshold.h" #include "filenamecat.h" #include "openat-priv.h" -#if HAVE_SYS_PARAM_H -# include -#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))) diff --git a/m4/linkat.m4 b/m4/linkat.m4 index e9b3d8266c..a4e61c332a 100644 --- a/m4/linkat.m4 +++ b/m4/linkat.m4 @@ -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 diff --git a/modules/linkat b/modules/linkat index e6f70ffa45..1fb4f8ff46 100644 --- a/modules/linkat +++ b/modules/linkat @@ -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]