Backport the blockdev code