cleanupJails: Postpone removing tmp directory until the end.

Otherwise, coolmount refuses to unmount devfs hierarchy on FreeBSD, because
the tmp/dev directory doesn't exist anymore.

Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I412f6947c4e1f3c04c2504e6cd88ca5645219878
This commit is contained in:
Gleb Popov 2022-01-26 17:58:45 +03:00 committed by Andras Timar
parent 34574724b4
commit cec1a927c2

View file

@ -171,12 +171,21 @@ void cleanupJails(const std::string& root)
for (const auto& jail : jails)
{
const Poco::Path path(root, jail);
// Postpone deleting "tmp" directory until we clean all the jails
// On FreeBSD the "tmp" dir contains a devfs moint point. Normally,
// it gets unmounted by coolmount during shutdown, but coolmount
// does nothing if it is called on the non-existing path.
// Removing this dir there prevents clean unmounting of devfs later.
if (jail == "tmp")
continue;
// Delete tmp and link cache with prejudice.
if (jail == "tmp" || jail == "linkable")
if (jail == "linkable")
FileUtil::removeFile(path.toString(), true);
else
cleanupJails(path.toString());
}
const Poco::Path tmpPath(root, "tmp");
FileUtil::removeFile(tmpPath.toString(), true);
}
// Remove empty directories.