Patches for Solaris/Illumos

Ignore the former pull request upstream3.
All changes are included in this pull request.