Even better emulate POSIX file functions (reduced)

This is reduced version of #5694.
Only obvious fixes.
uint8_t