It seems to me that:
fp->_flags |= _IO_EOF_SEEN;
in _IO_wfile_underflow_mmap is wrong. In that case,
_IO_file_underflow_mmap has already set either the EOF or ERROR flag bit.
If there was an error rather than EOF, the EOF bit should not be set too.
Am I missing something or should I remove this line?