From 140ccf1368a58716d8a05333a0b752597e33dbaf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 20 Jul 2021 20:59:45 +0200 Subject: [PATCH] deletePath(): Return ENFILE instead of EBADF when out of file descriptors Also remove an erroneous comment. --- src/libutil/util.cc | 5 +---- 1 file changed, 1 insertion(+), 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); }