On Thu, Oct 28, 2010 at 12:09:46PM +0200, chefren wrote:
> Patch for a nasty silent assumption in i386 'installboot': that a 'vnd'
> device is guaranteed to be a floppy and can't possibly be a harddisk.
>
> We tried to create a normal bootable harddisk image file, to 'dd' to USB
> sticks. 'installboot' kept trampling the MBR like a blind elephant in a
> china shop.
>
> This patch leaves the default behaviour untouched, but provides a '-r'
> flag to force 'installboot' to treat 'vnd' like a harddisk instead of a
> floppy.
>
> Basic patch, no manpage update.
>
> patch -p0 -d /usr/src/sys/arch/i386/stand/installboot
> <usr.src.sys.installboot.diff
> patch -p0 -d /usr/src/sys/arch/amd64/stand/installboot
> <usr.src.sys.installboot.diff
>
> = = = =
>
> --- installboot.c
> +++ installboot.c
> @@ -70,7 +70,7 @@ struct sym_data {
> };
>
> extern char *__progname;
> -int verbose, nowrite = 0;
> +int verbose, force_findopenbsd = 0, nowrite = 0;
> char *boot, *proto, *dev, *realdev;
> struct sym_data pbr_symbols[] = {
> {"_fs_bsize_p", 2},
> @@ -121,12 +121,16 @@ main(int argc, char *argv[])
> long start = 0;
> int n = 8;
>
> - while ((c = getopt(argc, argv, "vn")) != -1) {
> + while ((c = getopt(argc, argv, "vrn")) != -1) {
> switch (c) {
> case 'n':
> /* Do not actually write the bootblock to disk. */
> nowrite = 1;
> break;
> + case 'r':
> + /* Force 'vnd' to be treated like harddisk instead of
> floppy. */
> + force_findopenbsd = 1;
> + break;
> case 'v':
> /* Give more information. */
> verbose = 1;
> @@ -193,8 +197,9 @@ main(int argc, char *argv[])
> sync(); sleep(1);
> }
>
> - if (dl.d_type != 0 && dl.d_type != DTYPE_FLOPPY &&
> - dl.d_type != DTYPE_VND) {
> + if ((dl.d_type != 0 && dl.d_type != DTYPE_FLOPPY && dl.d_type !=
> DTYPE_VND) ||
> + force_findopenbsd)
> + {
> /* Find OpenBSD partition. */
> start = findopenbsd(devfd, &dl, (off_t)DOSBBSECTOR, &n);
> if (start == -1)
>
Perhaps a bit more context, like describing your vnd creation process, etc.
.... Ken