small fixes: using fd-based io instead of FILE*-based,
missed O_TRUNC, etc
5 files changed