Return value from bt_wait.
Added truncate mode flag.
Proper implementation of most newlib syscalls.