Skip to content

Commit

Permalink
Allow "sd" to be used for the prefix of OpenBSD root device names.
Browse files Browse the repository at this point in the history
  • Loading branch information
grehan-freebsd committed Jun 13, 2014
1 parent 969212e commit 8f5ad7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
25 changes: 16 additions & 9 deletions grub-core/loader/i386/bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static const struct grub_arg_option openbsd_opts[] =
{"config", 'c', 0, N_("Change configured devices."), 0, 0},
{"single", 's', 0, N_("Boot into single mode."), 0, 0},
{"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0},
{"root", 'r', 0, N_("Set root device."), "wdXY", ARG_TYPE_STRING},
{"root", 'r', 0, N_("Set root device."), "[sd|wd]XY", ARG_TYPE_STRING},
{"serial", 'h', GRUB_ARG_OPTION_OPTIONAL,
N_("Use serial console."),
/* TRANSLATORS: "com" is static and not to be translated. It refers to
Expand Down Expand Up @@ -1615,21 +1615,28 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
{
const char *arg = ctxt->state[OPENBSD_ROOT_ARG].arg;
int unit, part;
if (*(arg++) != 'w' || *(arg++) != 'd')
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"only device specifications of form "
"wd<number><lowercase letter> are supported");
int major;
#define OPENBSD_ROOT_ERR \
"only device specifications of form " \
"[sd|wd]<number><lowercase letter> are supported"

if (*arg != 'w' && *arg != 's')
return grub_error (GRUB_ERR_BAD_ARGUMENT, OPENBSD_ROOT_ERR);

major = (*arg == 's') ? OPENBSD_MAJOR_SD : OPENBSD_MAJOR_WD;

arg++;
if (*(arg++) != 'd')
return grub_error (GRUB_ERR_BAD_ARGUMENT, OPENBSD_ROOT_ERR);

unit = grub_strtoul (arg, (char **) &arg, 10);
if (! (arg && *arg >= 'a' && *arg <= 'z'))
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"only device specifications of form "
"wd<number><lowercase letter> are supported");
return grub_error (GRUB_ERR_BAD_ARGUMENT, OPENBSD_ROOT_ERR);

part = *arg - 'a';

bootdev = (OPENBSD_B_DEVMAGIC + (unit << OPENBSD_B_UNITSHIFT) +
(part << OPENBSD_B_PARTSHIFT));
(part << OPENBSD_B_PARTSHIFT) + major);
}
else
bootdev = 0;
Expand Down
3 changes: 3 additions & 0 deletions include/grub/i386/openbsd_reboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@
#define OPENBSD_B_PARTSHIFT 8
#define OPENBSD_B_TYPESHIFT 0

#define OPENBSD_MAJOR_WD 0 /* 'wd' major number */
#define OPENBSD_MAJOR_SD 4 /* 'sd' major number */

#endif

0 comments on commit 8f5ad7a

Please sign in to comment.