This code has been adapted from an implementation that has been tested on real hardware; however, it has not undergone such testing itself.
It currently fails in the presence of ZFS partitions, though this is almost certainly due to the presence of a bug that also manifests in https://reviews.freebsd.org/D10447.