At least GETENTROPY_MAX is not defined and the return value for buflen > GETENTROPY_MAX should be EINVAL not EIO.