Now that we've updated the prototypes of the basename(3) and dirname(3)
functions to conform to POSIX, let's go ahead and reimplement dirname(3)
in such a way that it's thread-safe, but also guaranteed to succeed.
C libraries like the one that's part of Solaris and musl already follow
such an approach.
Move the existing implementation to another source file,
freebsd11_dirname.c to keep existing users of the API that pass in a
constant string happy, using symbol versioning.
Put a new version of the function in dirname.c, obtained from CloudABI's
C library. This version scans through the pathname string from left to
right, normalizing it, while discarding the last pathname component.
Note: this change will not be committed immediately. I'm only planning
on doing this in a couple of weeks from now, to see if the previous
change (to switch over to the POSIX prototypes) causes any unexpected
regressions.