All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Zielcke <fzielcke@z-51.de>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] fix grub-setup on kfreebsd by adding 0x10 to the sysctl ("kern.geom.debugflags") flags
Date: Mon, 13 Apr 2009 16:26:19 +0200	[thread overview]
Message-ID: <1239632779.3747.32.camel@fz.local> (raw)
In-Reply-To: <1239629520.3747.28.camel@fz.local>

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

Am Montag, den 13.04.2009, 15:32 +0200 schrieb Felix Zielcke:
> Here's a patch to fix grub-setup on Debian GNU/kFreeBSD.
> Without it, it fails always with `grub-setup: error: cannot open
> `/dev/da0' in open_device()'
> With it, it works fine.

Args there should be a patch attached. Fixed.
-- 
Felix Zielcke

[-- Attachment #2: kfreebsd.patch --]
[-- Type: text/x-patch, Size: 1672 bytes --]

2009-04-13  Felix Zielcke  <fzielcke@z-51.de>

	util/hostdisk.c [__FreeBSD_kernel]: Include <sys/param.h> and
	<sys/sysctl.h>
	(open_device) [__FreeBSD_kernel_]: Use sysctlgetbyname() to add 0x10 to
	`kern.geom.debugflags', before opening the device and reset them afterwards.

Index: util/hostdisk.c
===================================================================
--- util/hostdisk.c	(revision 2094)
+++ util/hostdisk.c	(working copy)
@@ -90,6 +90,11 @@ struct hd_geometry
 # include <sys/disk.h> /* DIOCGMEDIASIZE */
 #endif
 
+#ifdef __FreeBSD_kernel__
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
+
 struct
 {
   char *drive;
@@ -340,7 +345,24 @@ open_device (const grub_disk_t disk, gru
       sector -= disk->partition->start;
   }
 #else /* ! __linux__ */
+#if defined __FreeBSD_kernel__
+  int sysctl_flags, sysctl_oldflags;
+  size_t sysctl_size = sizeof (sysctl_flags);
+
+  if (sysctlbyname ("kern.geom.debugflags", &sysctl_oldflags, &sysctl_size, NULL, 0))
+    grub_util_error ("cannot get current flags of sysctl kern.geom.debugflags");
+  sysctl_flags = sysctl_oldflags |= 0x10;
+  if (sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_flags, sysctl_size))
+    grub_util_error ("cannot set flags of sysctl kern.geom.debugflags");
+#endif
+
   fd = open (map[disk->id].device, flags);
+
+#if defined __FreeBSD_kernel__
+  if (sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_oldflags, sysctl_size))
+    grub_util_error ("cannot set flags back to the old value for sysctl kern.geom.debugflags");
+#endif
+
   if (fd < 0)
     {
       grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' in open_device()", map[disk->id].device);

  reply	other threads:[~2009-04-13 14:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-13 13:32 [PATCH] fix grub-setup on kfreebsd by adding 0x10 to the sysctl ("kern.geom.debugflags") flags Felix Zielcke
2009-04-13 14:26 ` Felix Zielcke [this message]
2009-04-13 14:49   ` Robert Millan
2009-04-13 15:11     ` Felix Zielcke
2009-04-13 19:11       ` Robert Millan
2009-04-14  7:01         ` Felix Zielcke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1239632779.3747.32.camel@fz.local \
    --to=fzielcke@z-51.de \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.