2009-04-14 Felix Zielcke <fzielcke@z-51.de>
* util/hostdisk.c [__FreeBSD__ || __FreeBSD_kernel__]: Include <sys/param.h> and <sys/sysctl.h>. (open_device) [__FreeBSD__ || __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.
This commit is contained in:
parent
1f1f580c2f
commit
e25b5a8c6c
2 changed files with 38 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2009-04-14 Felix Zielcke <fzielcke@z-51.de>
|
||||||
|
|
||||||
|
* util/hostdisk.c [__FreeBSD__ || __FreeBSD_kernel__]: Include
|
||||||
|
<sys/param.h> and <sys/sysctl.h>.
|
||||||
|
(open_device) [__FreeBSD__ || __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.
|
||||||
|
|
||||||
2009-04-13 Pavel Roskin <proski@gnu.org>
|
2009-04-13 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* conf/common.rmk (grub_fstest_SOURCES): Add normal/datetime.c.
|
* conf/common.rmk (grub_fstest_SOURCES): Add normal/datetime.c.
|
||||||
|
|
|
@ -88,6 +88,8 @@ struct hd_geometry
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
# include <sys/disk.h> /* DIOCGMEDIASIZE */
|
# include <sys/disk.h> /* DIOCGMEDIASIZE */
|
||||||
|
# include <sys/param.h>
|
||||||
|
# include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -340,7 +342,35 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
||||||
sector -= disk->partition->start;
|
sector -= disk->partition->start;
|
||||||
}
|
}
|
||||||
#else /* ! __linux__ */
|
#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_error (GRUB_ERR_BAD_DEVICE, "cannot get current flags of sysctl kern.geom.debugflags");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sysctl_flags = sysctl_oldflags | 0x10;
|
||||||
|
if (! (sysctl_oldflags & 0x10)
|
||||||
|
&& sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_flags, sysctl_size))
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
fd = open (map[disk->id].device, flags);
|
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_error (GRUB_ERR_BAD_DEVICE, "cannot set flags back to the old value for sysctl kern.geom.debugflags");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' in open_device()", map[disk->id].device);
|
grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' in open_device()", map[disk->id].device);
|
||||||
|
|
Loading…
Add table
Reference in a new issue