tar: ENFILE is like EMFILE

* src/create.c (open_failure_recover):
* src/misc.c (fdbase_opendir):
Treat ENFILE like EMFILE.
This commit is contained in:
Paul Eggert
2026-04-13 00:02:17 -07:00
parent 79d61af0e1
commit 55e8233438
2 changed files with 6 additions and 5 deletions
+4 -3
View File
@@ -1230,7 +1230,7 @@ ensure_slash (char **pstr)
/* If we just ran out of file descriptors, release a file descriptor
in the directory chain somewhere leading from DIR->parent->parent
up through the root. Return true if successful, false (preserving
errno == EMFILE) otherwise.
errno) otherwise.
Do not release DIR's file descriptor, or DIR's parent, as other
code assumes that they work. On some operating systems, another
@@ -1241,7 +1241,8 @@ ensure_slash (char **pstr)
static bool
open_failure_recover (struct tar_stat_info const *dir)
{
if (errno == EMFILE && dir && dir->parent)
int err = errno;
if ((err == EMFILE || err == ENFILE) && dir && dir->parent)
{
struct tar_stat_info *p;
for (p = dir->parent->parent; p; p = p->parent)
@@ -1250,7 +1251,7 @@ open_failure_recover (struct tar_stat_info const *dir)
tar_stat_close (p);
return true;
}
errno = EMFILE;
errno = err;
}
return false;
+2 -2
View File
@@ -1238,13 +1238,13 @@ fdbase_opendir (char const *file_name, bool alternate)
if (subfd < 0)
{
/* Keep the old directory cached and report open failure,
unless EMFILE means it's possible that falling
unless EMFILE/ENFILE means it's possible that falling
through to close the old directory would mean we
could successfully retry from the chdir_fd level.
When reporting failure, there is no need to
null-terminate the old directory, since the code does
not assume null termination. */
if (errno != EMFILE)
if (errno != EMFILE && errno != ENFILE)
return (struct fdbase) { .fd = BADFD, .base = base };
}
else