Make some stubs return NULL so as to signal the caller.
set errno in stubs
Use high-level libc interface for reading directory.