Factor out and improve the block regeneration code.
Factor out and improve the block regeneration code.

ok krw@

orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars