minor fixes to return codes of closedir, telldir

closedir should set errno and return -1: http://linux.die.net/man/3/closedir
telldir should do the same: http://linux.die.net/man/3/telldir
`readdir_r` was added to dirent.h

and finally, I replaced two existing tests (test_folders and test_readdir) with a test I'd written throughout the VFS work for testing the dirent family of functions.

My ration was that it's a good practice to have the tests as focused and self-contained as possible (in my case, I couldn't run those tests on the VFS branch until I'd shimmed the JS API). If the purpose of the replaced tests was to test the JS APIs, lets create tests _just_ for that, otherwise this tests a few more situations (rewinddir, readdir_r) and is focused solely on the few dirent functions.