Even better emulate POSIX file functions (reduced)

This is reduced version of #5694.
Only obvious fixes.
what is the point of this? None of our file system sets errno. If they do it's just by pure luck. If anything errno should be set only based on the negative value of ret.