chmod(2) sets errno, so use it.