There is, however, a detail that we need to be aware of.
Optical discs in common use almost always use a block size of 2048 bytes, whereas vnconfig will by default present an image file as a device having 512-byte sectors.
Since disklabels store offset and size values as sector counts, the same disklabel describes a disk of a different size if it's moved from a 512-byte device to a 2048-byte device.
Trying to read such a disc may even cause the device to become unresponsive, for example on the test machine using a SATA connected BD-R drive:
ahci0: unrecoverable errors (IS: 1000000<OFS>), disabling port.
Fun fact!
The disklabel spoofing code automatically deals with block size
If you've worked with CD image files, such as the official install disc image files from the OpenBSD project, you might be wondering why you've never seen this discrepancy between 512 byte and 2048 byte sector sizes.
After all, in those cases, the same image that can be written to optical media can also be configured as a regular 512 bytes per sector vnode pseudo disk and mounted without the need for a special disk type.
This conveniently works because the code in iso_disklabelspoof() always simply sets the sizes of the partitions it spoofs to the same value as the whole disk size in sectors, thereby completely avoiding any issues with 512 byte vs 2048 byte block sizes.
This value for total device size in sectors is obtained and written to the disklabel by device specific code, (for example, on a cd device it's done in cdgetdisklabel() in cd.c), and this code obviously knows the correct sector size for the device in question.
We can see this effect by comparing the spoofed disklabel from an OpenBSD 7.7 installation image read from an actual BD-R disc, with the same image configured as a vnode pseudo disk:
# /dev/rcd0c:
type: ATAPI
disk: OpenBSD/amd64
label: 7.7 Install CD
duid: 0000000000000000
flags:
bytes/sector: 2048
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 3820
total sectors: 381920 # total bytes: 745.9M
boundstart: 0
boundend: 381920
16 partitions:
# size offset fstype [fsize bsize cpg]
a: 745.9M 0 ISO9660
c: 745.9M 0 ISO9660
2048-byte sectors
# /dev/rvnd0c:
type: vnd
disk: OpenBSD/amd64
label: 7.7 Install CD
duid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 15276
total sectors: 1527644 # total bytes: 745.9M
boundstart: 0
boundend: 1527644
16 partitions:
# size offset fstype [fsize bsize cpg]
a: 745.9M 0 ISO9660
c: 745.9M 0 ISO9660
512-byte sectors
Note that whilst the overall size is always reported as 745.9M, the cd0c device calculates this as 381920 * 2048 / 1024 / 1024 = 745, whereas the vnd0c device uses 1527644 * 512 / 1024 / 1024 = 745