libc: split scandir() into scandir_dirp() and proper scandir()
The new helper scandir_dirp() takes DIR *, i.e. a pre-opened directory,
instead of the directory name.
Reviewed by: emaste, imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D36301