Use readdir_r() instead of readdir().

Using a statically-allocated result seems fine under Linux. This program
isn't portable anyway, so there's nothing to worry about.
Use strerror_r() instead of strerror().

The GNU variant is being used here.