Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1FWurE-0007WR-3S for mharc-grub-devel@gnu.org; Fri, 21 Apr 2006 08:35:32 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FWurA-0007Vc-PJ for grub-devel@gnu.org; Fri, 21 Apr 2006 08:35:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FWur7-0007Us-9P for grub-devel@gnu.org; Fri, 21 Apr 2006 08:35:27 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FWur7-0007Ui-1s for grub-devel@gnu.org; Fri, 21 Apr 2006 08:35:25 -0400 Received: from [62.81.186.14] (helo=smtp04.retemail.es) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FWusf-0001U1-8t for grub-devel@gnu.org; Fri, 21 Apr 2006 08:37:01 -0400 Received: from khazad.dyndns.org ([62.57.139.54]) by smtp04.retemail.es (InterMail vM.6.01.04.01 201-2131-118-101-20041129) with ESMTP id <20060421123326.BANV15001.smtp04.retemail.es@khazad.dyndns.org> for ; Fri, 21 Apr 2006 14:33:26 +0200 Received: from rmh by khazad.dyndns.org with local (Exim 4.61) (envelope-from ) id 1FWup9-0005XD-9c for grub-devel@gnu.org; Fri, 21 Apr 2006 14:33:23 +0200 Date: Fri, 21 Apr 2006 14:33:22 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20060421123322.GA21231@khazad.dyndns.org> References: <20060420125413.GA13195@khazad.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20060420125413.GA13195@khazad.dyndns.org> Sender: Robert Millan Organization: free as in freedom User-Agent: Mutt/1.5.11+cvs20060403 Subject: Re: [patch] fixes for kernel of FreeBSD 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: Fri, 21 Apr 2006 12:35:29 -0000 Followup to my previous sysctl commit. When modifying kern.geom.debugflags is not necessary, this avoids the third sysctlbyname() call (and allocating "flags" into the stack ;)). 2006-04-21 Robert Millan * grub/asmstub.c (get_diskinfo): Optimize sysctl routine. Index: grub/asmstub.c =================================================================== RCS file: /sources/grub/grub/grub/asmstub.c,v retrieving revision 1.85 diff -u -r1.85 asmstub.c --- grub/asmstub.c 20 Apr 2006 13:46:45 -0000 1.85 +++ grub/asmstub.c 21 Apr 2006 12:28:17 -0000 @@ -785,7 +785,7 @@ /* By default, kernel of FreeBSD does not allow overwriting MBR */ #if defined(__FreeBSD_kernel__) || defined(__FreeBSD__) #define GEOM_SYSCTL "kern.geom.debugflags" - int old_flags, flags; + int old_flags; size_t sizeof_int = sizeof (int); if (sysctlbyname (GEOM_SYSCTL, &old_flags, &sizeof_int, NULL, 0) != 0) @@ -794,7 +794,7 @@ if ((old_flags & 0x10) == 0) { /* "allow foot shooting", see geom(4) */ - flags = old_flags | 0x10; + int flags = old_flags | 0x10; if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &flags, sizeof (int)) != 0) grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno)); @@ -802,7 +802,7 @@ #endif disks[drive].flags = open (devname, O_RDWR); #if defined(__FreeBSD_kernel__) || defined(__FreeBSD__) - if (flags != old_flags) + if ((old_flags & 0x10) == 0) { if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &old_flags, sizeof (int)) != 0) grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno)); -- Robert Millan