Fix mkdirp.

We need to copy the input string of mkdirp to be able to maintain an external
API that accepts const pointers.