Fix build on OS X

* There is no direct equivalent of O_DIRECT, just warn.
* error(3) is glibc-specific.
* There were a couple missing includes.
Merge pull request #8 from eregon/master

Fix build on OS X