misc ungetc fixes

I'm going through changes on my VFS branch and cherry-picking issues that aren't necessarily related, but that I made in the process.

This change namely moves out the checking of characters pushed by ungetc from pread / read to fread. As far as I can tell, this is a feature of the buffered stdio streams and shouldn't ever be considered when calling pread or read. A side effect of this was that fgetc now calls fread instead of read.

Also, there were a few small issues with ungetc. It wasn't early outing when receiving the EOF character, and it wasn't clearing the EOF indicator when called.

Ran o1 and other tests.