Fix mkdir: we have sub-directories!

(cherry picked from commit 53e103c3cda2b1cf78fa04cfc1d589af4cd8ac62)