aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-07-20 20:59:45 +0200
committerEelco Dolstra <edolstra@gmail.com>2021-07-20 20:59:45 +0200
commit140ccf1368a58716d8a05333a0b752597e33dbaf (patch)
tree87eb2c4e74f81a693c16fbfd61d83931c9f2cc71
parentc5fafca5a477debff123675b4c2167b8311f9ddf (diff)
deletePath(): Return ENFILE instead of EBADF when out of file descriptors
Also remove an erroneous comment.
-rw-r--r--src/libutil/util.cc5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index ee9f17228..b8334defc 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -413,7 +413,7 @@ static void _deletePath(int parentfd, const Path & path, uint64_t & bytesFreed)
}
int fd = openat(parentfd, path.c_str(), O_RDONLY);
- if (!fd)
+ if (fd == -1)
throw SysError("opening directory '%1%'", path);
AutoCloseDir dir(fdopendir(fd));
if (!dir)
@@ -437,10 +437,7 @@ static void _deletePath(const Path & path, uint64_t & bytesFreed)
AutoCloseFD dirfd(open(dir.c_str(), O_RDONLY));
if (!dirfd) {
- // This really shouldn't fail silently, but it's left this way
- // for backwards compatibility.
if (errno == ENOENT) return;
-
throw SysError("opening directory '%1%'", path);
}