utils: Teach mkdir_p to fail if the existing target isn't a directory

Existing symlinks to directories will still pass, because isdir() follows
symbolic links.