Jens A Nilsson in private e-mail.
Provided in pr 7018 by Jens A Nilsson with some modifications by myself to make it work with current (sys/errno.h vs errno.h).