HomeFreeBSD

Reimplement dirname(3) to be thread-safe.

Description

Reimplement dirname(3) to be thread-safe.

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 glibc, musl and the one that's part of Solaris 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.

Reviewed by: emaste, jilles
Differential Revision: https://reviews.freebsd.org/D7355

Details

Provenance
edAuthored on
Reviewer
emaste
Differential Revision
D7355: Reimplement dirname(3) to be thread-safe.
Parents
rS303987: Copy snapshot of .../dist to .../08.11.2016_18.01
Branches
Unknown
Tags
Unknown