fix the handling of overlays (gentoo bug #376775)

do not even try to open a non-existent directories

https://bugs.gentoo.org/show_bug.cgi?id=376775