Fix xdirname on Linux.

Unlike the BSDs, Linux alters the char* it is given. To keep xdirname
portable on all platform, we copy everything.