From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LtN7H-0006he-Nq for mharc-grub-devel@gnu.org; Mon, 13 Apr 2009 10:26:31 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LtN7E-0006gu-W3 for grub-devel@gnu.org; Mon, 13 Apr 2009 10:26:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LtN78-0006fJ-Ka for grub-devel@gnu.org; Mon, 13 Apr 2009 10:26:27 -0400 Received: from [199.232.76.173] (port=40406 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LtN78-0006f8-Bh for grub-devel@gnu.org; Mon, 13 Apr 2009 10:26:22 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:64368) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LtN77-0005t7-Re for grub-devel@gnu.org; Mon, 13 Apr 2009 10:26:22 -0400 Received: from [85.180.44.158] (e180044158.adsl.alicedsl.de [85.180.44.158]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MKv5w-1LtN763rKw-0001Ef; Mon, 13 Apr 2009 16:26:21 +0200 From: Felix Zielcke To: The development of GRUB 2 In-Reply-To: <1239629520.3747.28.camel@fz.local> References: <1239629520.3747.28.camel@fz.local> Content-Type: multipart/mixed; boundary="=-bC1pGoM84/vCG2oafrZS" Date: Mon, 13 Apr 2009 16:26:19 +0200 Message-Id: <1239632779.3747.32.camel@fz.local> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 X-Provags-ID: V01U2FsdGVkX19r3PCOyZp8OAGLyUTG0oTwbvv5UPrjMiuLpmg QfUdGnqp2QJEJB5RgWYNpm/LVfvizNqD4MLG84qCY2PQavnzce XZj1n7GqAXMoPeqCf1E4w== X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [PATCH] fix grub-setup on kfreebsd by adding 0x10 to the sysctl ("kern.geom.debugflags") flags X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Apr 2009 14:26:29 -0000 --=-bC1pGoM84/vCG2oafrZS Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 --=-bC1pGoM84/vCG2oafrZS Content-Disposition: attachment; filename="kfreebsd.patch" Content-Type: text/x-patch; name="kfreebsd.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit 2009-04-13 Felix Zielcke util/hostdisk.c [__FreeBSD_kernel]: Include and (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 /* DIOCGMEDIASIZE */ #endif +#ifdef __FreeBSD_kernel__ +#include +#include +#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); --=-bC1pGoM84/vCG2oafrZS--