From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LtNoY-0008TY-TU for mharc-grub-devel@gnu.org; Mon, 13 Apr 2009 11:11:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LtNoW-0008Q5-9F for grub-devel@gnu.org; Mon, 13 Apr 2009 11:11:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LtNoR-0008LR-H4 for grub-devel@gnu.org; Mon, 13 Apr 2009 11:11:11 -0400 Received: from [199.232.76.173] (port=47195 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LtNoR-0008LI-DA for grub-devel@gnu.org; Mon, 13 Apr 2009 11:11:07 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:50281) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LtNoQ-0006iY-S4 for grub-devel@gnu.org; Mon, 13 Apr 2009 11:11:07 -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-1LtNoP1h1Z-0000qD; Mon, 13 Apr 2009 17:11:05 +0200 From: Felix Zielcke To: The development of GRUB 2 In-Reply-To: <20090413144902.GB22165@thorin> References: <1239629520.3747.28.camel@fz.local> <1239632779.3747.32.camel@fz.local> <20090413144902.GB22165@thorin> Content-Type: multipart/mixed; boundary="=-NK5+EGuSNjntSYSC7KqH" Date: Mon, 13 Apr 2009 17:11:04 +0200 Message-Id: <1239635464.3747.42.camel@fz.local> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 X-Provags-ID: V01U2FsdGVkX184jeEBa6WOd5O5Ubt8dRu1KFRBqOgIy48DpCC jDY48XFvOq6XQbCIhUMNEz4Q6P5WFs+YjD43nRhTmJkH+ll8OP 5E2Z3LZPRpjbJlhR9tEJA== 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 15:11:12 -0000 --=-NK5+EGuSNjntSYSC7KqH Content-Type: text/plain Content-Transfer-Encoding: 7bit Am Montag, den 13.04.2009, 16:49 +0200 schrieb Robert Millan: Thanks for reviewing. > On Mon, Apr 13, 2009 at 04:26:19PM +0200, Felix Zielcke wrote: > > +#ifdef __FreeBSD_kernel__ > > Unfortunately FreeBSD doesn't define __FreeBSD_kernel__, so we need > to check for both macros. Oh right. > > +#if defined __FreeBSD_kernel__ > > + int sysctl_flags, sysctl_oldflags; > > + size_t sysctl_size = sizeof (sysctl_flags); > > You can add a `const' on this one. > > > + sysctl_flags = sysctl_oldflags |= 0x10; > > Shouldn't this be "sysctl_oldflags | 0x10" ? Yes. > Btw you can avoid the two subsequent calls if sysctl_flags == sysctl_oldflags. Right and actually it can be even avoided if 0x10 is already set. Is it correct that I used now `[__FreeBSD__]: Likewise.' in the Changelog? The GCS unfortunately doestn't tell anything about the case that a change applies to 2 or more marcros and I couldn't find an example in the existing Changelog for this. -- Felix Zielcke --=-NK5+EGuSNjntSYSC7KqH Content-Disposition: attachment; filename="kfreebsd.patch.2" Content-Type: text/plain; name="kfreebsd.patch.2"; charset="UTF-8" Content-Transfer-Encoding: 7bit 2009-04-13 Felix Zielcke util/hostdisk.c [__FreeBSD_kernel]: Include and . [__FreeBSD__]: Likewise. (open_device) [__FreeBSD_kernel_]: Use sysctlgetbyname() to add 0x10 to `kern.geom.debugflags' if it's not already set, before opening the device and reset them afterwards. [__FreeBSD__]: Likewise. Index: util/hostdisk.c =================================================================== --- util/hostdisk.c (revision 2094) +++ util/hostdisk.c (working copy) @@ -88,6 +88,8 @@ struct hd_geometry #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include /* DIOCGMEDIASIZE */ +# include +# include #endif struct @@ -340,7 +342,24 @@ open_device (const grub_disk_t disk, gru sector -= disk->partition->start; } #else /* ! __linux__ */ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + int sysctl_flags, sysctl_oldflags; + const 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 (! sysctl_oldflags & 0x10 && 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__) || defined(__FreeBSD_kernel__) + if (! sysctl_oldflags & 0x10 && 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); --=-NK5+EGuSNjntSYSC7KqH--