summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-12-24 11:38:48 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2020-12-24 12:06:48 -0800
commitf58714504e607a7c9d631073a356b2cd3cbf96c7 (patch)
treec1f6d14c4920f4effa37ba1f1595dc717a0e91f0 /config
parent6c98a29696b591c9a357183fac657f5547b6118a (diff)
downloadgnulib-f58714504e607a7c9d631073a356b2cd3cbf96c7.tar.gz
canonicalize: prefer faccessat to stat
A proper faccessat doesn't have the EOVERFLOW problem, and can be more efficient as it needn't gather data from the filesystem to fill in struct stat. So use stat only if faccessat is absent, or when checking for symlink loops in canonicalize.c. * lib/canonicalize-lgpl.c, lib/canonicalize.c: Include fcntl.h, for AT_EACCESS. (FACCESSAT_NEVER_EOVERFLOWS): Default to false. (file_accessible): New function, based on faccessat but with a fallback to stat and with an EOVERFLOW workaround. (dir_check): Use it. (dir_suffix): New static constant. * lib/canonicalize-lgpl.c (FACCESSAT_NEVER_EOVERFLOWS) [_LIBC]: Use __ASSUME_FACCESSAT2 to set FACCESSAT_NEVER_EOVERFLOWS (__faccessat) [!_LIBC]: Define. (realpath_stk): Use dir_suffix now. * lib/canonicalize.c (canonicalize_filename_mode_stk): If logical, don't check each component's existence; just check at the end, as that's enough. * m4/canonicalize.m4 (gl_FUNC_CANONICALIZE_FILENAME_MODE) (gl_CANONICALIZE_LGPL_SEPARATE): Require gl_FUNC_FACCESSAT_EOVERFLOW, gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, and check for faccessat. (gl_CANONICALIZE_LGPL_SEPARATE): Do not check for readlink, as the code does not use HAVE_READLINK. * modules/canonicalize, modules/canonicalize-lgpl (Files): Add m4/faccessat.m4, m4/lstat.m4. (Depends-on): Add fcntl-lh.
Diffstat (limited to 'config')
0 files changed, 0 insertions, 0 deletions