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 17:11:04 +0200 [thread overview]
Message-ID: <1239635464.3747.42.camel@fz.local> (raw)
In-Reply-To: <20090413144902.GB22165@thorin>
[-- Attachment #1: Type: text/plain, Size: 983 bytes --]
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
[-- Attachment #2: kfreebsd.patch.2 --]
[-- Type: text/plain, Size: 1865 bytes --]
2009-04-13 Felix Zielcke <fzielcke@z-51.de>
util/hostdisk.c [__FreeBSD_kernel]: Include <sys/param.h> and
<sys/sysctl.h>.
[__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 <sys/disk.h> /* DIOCGMEDIASIZE */
+# include <sys/param.h>
+# include <sys/sysctl.h>
#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);
next prev parent reply other threads:[~2009-04-13 15:11 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
2009-04-13 14:49 ` Robert Millan
2009-04-13 15:11 ` Felix Zielcke [this message]
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=1239635464.3747.42.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.