mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-27 01:44:20 +00:00
This closes some more races, by using openat+fstat instead of fstatat+openat which can get confused by some other process renaming files in the meantime. Not all races are closed of course. * bootstrap.conf (gnulib_modules): Add d-type. * src/diff.c (errno_encode, errno_decode): Remove, as file descriptors are no longer portmanteau variables. All uses removed. (detype_from_mode): New function. (dir_p): Use detype, not stat.st_mode. (compare_files): New args DETYPE0 and DETYPE1. All uses changed. Update detype and err as new info arrives. Adjust to desc's new use (no longer encodes errno). Do not ignore lseek failures on regular files. Prefer openat+fstat to fstatat+openat when detype shows that it's safe, and avoid both fstat and fstatat if detype suffices. Use ‘error’ with errno value rather than setting error and then calling perror_with_name. Coalesce two of these error diagnostics into one by moving an error check before the diagnostic is output. Coalesce two calls to diff_dirs. Print file type based on detype if available, in case neither fstat nor fstatat was called. * src/diff.h (enum detype): New type. (struct file_data): New slots err, detype. (NONEXISTENT, UNOPENED): Renumber so that -1 stands for open failed. * src/dir.c (HAVE_STRUCT_DIRENT_D_TYPE): Default to false. (dir_read): Return to caller the d_type, if available. (diff_dirs): Pass detype to compare_files.