Skip to contentSkip to conversation

Let user specify OpenBSD root device.

PATCH In review Vladimir 'phcoder' Serbinenko 2 participants 6 messages Aug 25, 2009 – Oct 16, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Let user specify OpenBSD root device.

OpenBSD recieves a root specification in a form of pair <device, partition>. I thought that device number referred to biosnumber AND'ed with 0x7f as it was implemented but experiments with grub-qemu showed that OpenBSD doesn't rely on BIOS at all. So hence this patch

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
ChangeLog +10 -0
index 1de68ad..717904e 100644
@@ -1,5 +1,15 @@
 2009-08-25  Vladimir Serbinenko  <[email protected]>
 
+	Let user specify OpenBSD root device.
+
+	* loader/i386/bsd.c (openbsd_root): New variable.
+	(openbsd_opts): New option 'root'.
+	(OPENBSD_ROOT_ARG): New macro.
+	(grub_openbsd_boot): Use 'openbsd_root'.
+	(grub_cmd_openbsd): Fill 'openbsd_root'.
+
+2009-08-25  Vladimir Serbinenko  <[email protected]>
+
 	Cleanup NetBSD root support.
 
 	* loader/i386/bsd.c (grub_netbsd_boot): Remove call to
loader/i386/bsd.c +34 -7

81 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Vladimir 'phcoder' Serbinenko
loader/i386/bsd.c +4 -0
+  if (cmd->state[OPENBSD_ROOT_ARG].set)
+    {
+      const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
+      int unit, part;

loader/i386/bsd.c grub_cmd_freebsd (grub_extcmd_t cmd, int argc, char *argv[]) · line 970

Quoted 10 lines
loader/i386/bsd.c +10 -0
+      if (*(arg++) != 'w' || *(arg++) != 'd')
+	return grub_error (GRUB_ERR_BAD_ARGUMENT,
+			   "Only device specifications of form "
+			   "wd<number><lowercase letter> are supported.");
+
+      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><letter> are supported.");

Looks like the first error string could be used for both cases, saving a few bytes.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#2 lore raw
Quoted 32 lines · Robert Millan
Quoted 6 lines · Vladimir 'phcoder' Serbinenko

+  if (cmd->state[OPENBSD_ROOT_ARG].set)
+    {
+      const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
+      int unit, part;
+      if (*(arg++) != 'w' || *(arg++) != 'd')
+     return grub_error (GRUB_ERR_BAD_ARGUMENT,

Quoted 8 lines

+                        "Only device specifications of form "
+                        "wd<number><lowercase letter> are supported."); +
+      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><letter> are supported.");

Looks like the first error string could be used for both cases, saving a few bytes.

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
ChangeLog +10 -0
index 54b3e48..9aba062 100644
@@ -1,5 +1,15 @@
 2009-08-25  Vladimir Serbinenko  <[email protected]>
 
+	Let user specify OpenBSD root device.
+
+	* loader/i386/bsd.c (openbsd_root): New variable.
+	(openbsd_opts): New option 'root'.
+	(OPENBSD_ROOT_ARG): New macro.
+	(grub_openbsd_boot): Use 'openbsd_root'.
+	(grub_cmd_openbsd): Fill 'openbsd_root'.
+
+2009-08-25  Vladimir Serbinenko  <[email protected]>
+
 	NetBSD memory map support.
 
 	* include/grub/i386/bsd.h (NETBSD_BTINFO_MEMMAP): New definition.
loader/i386/bsd.c +34 -7

81 lines not on this page · raw message

#3 lore raw
Quoted 19 lines · Vladimir 'phcoder' Serbinenko
Quoted 17 lines · Robert Millan
Quoted 15 lines · Vladimir 'phcoder' Serbinenko
loader/i386/bsd.c +14 -0
+  if (cmd->state[OPENBSD_ROOT_ARG].set)
+    {
+      const char *arg = cmd->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.");
+
+      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><letter> are supported.");
Quoted 4 lines
Quoted 4 lines

Looks like the first error string could be used for both cases, saving a few bytes.

This was fixed. Can this patch be comitted before release to avoid changing command syntax after release?

Quoted 18 lines
Quoted 14 lines

--
Robert Millan

The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 3 lines
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git 
#4 lore raw
Quoted 20 lines · Vladimir 'phcoder' Serbinenko
Quoted 19 lines · Vladimir 'phcoder' Serbinenko
Quoted 17 lines · Robert Millan
Quoted 15 lines · Vladimir 'phcoder' Serbinenko
loader/i386/bsd.c +14 -0
+  if (cmd->state[OPENBSD_ROOT_ARG].set)
+    {
+      const char *arg = cmd->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.");
+
+      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><letter> are supported.");
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Looks like the first error string could be used for both cases, saving a few bytes.

This was fixed. Can this patch be comitted before release to avoid changing command syntax after release?

Ok.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#5 lore raw
Quoted 31 lines · Robert Millan
Quoted 29 lines · Vladimir 'phcoder' Serbinenko
Quoted 27 lines · Vladimir 'phcoder' Serbinenko
Quoted 24 lines · Robert Millan
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
loader/i386/bsd.c +4 -0
+  if (cmd->state[OPENBSD_ROOT_ARG].set)
+    {
+      const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
+      int unit, part;

loader/i386/bsd.c grub_cmd_freebsd (grub_extcmd_t cmd, int argc, char *argv[])

Quoted 10 lines
loader/i386/bsd.c +10 -0
+      if (*(arg++) != 'w' || *(arg++) != 'd')
+     return grub_error (GRUB_ERR_BAD_ARGUMENT,
+                        "Only device specifications of form "
+                        "wd<number><lowercase letter> are supported.");
+
+      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><letter> are supported.");

Looks like the first error string could be used for both cases, saving a few bytes.

Quoted 7 lines
Quoted 3 lines

This was fixed. Can this patch be comitted before release to avoid changing command syntax after release?

Ok.

Comitted

Signature · 3 lines
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git