Improve dir checking in make_directories

Prefer faccessat to fstatat for dir checking.
Also, don’t bother doing either check if caller
is about to check the rough equivalent anyway.
* src/extract.c (make_directories): Now static.
2nd arg is now a three-way flag.  All uses changed.
Use faccessat instead of fstatat, to avoid EOVERFLOW issues.
(create_dir): New function, for use outside this module.
External caller changed.
(maybe_recoverable): Set *INTERDIR_MADE if make_directories
said we made the parent.
This commit is contained in:
Paul Eggert
2026-07-29 23:12:46 -07:00
parent b7704c8d98
commit bad45bee3e
3 changed files with 88 additions and 43 deletions
+2 -2
View File
@@ -1129,8 +1129,8 @@ chdir_do (idx_t i, bool create)
directory. The one-top-level directory is
allowed to be given as an absolute path. */
open_searchdir_how.resolve = 0;
if (0 <= make_directories (curr->name, false))
/* Directory created, retry */
if (create_dir (curr->name))
/* Directory likely exists now; retry. */
fd = openat (chdir_fd, curr->name,
open_searchdir_how.flags & ~O_NOFOLLOW);
open_searchdir_how = saved_open_searchdir_how;