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
2009-04-13 Felix Zielcke <[email protected]> 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);
_______________________________________________ Grub-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/grub-devel
