Move OS-specific driver configuration to grub_util_fd_open. This
moves OS-dependent parts from kern/emu/hostdisk.c to grub-core/osdep/*/hostdisk.c.
This commit is contained in:
parent
f7676b7016
commit
caca1c70cf
13 changed files with 101 additions and 93 deletions
|
@ -86,7 +86,6 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st,
|
|||
strerror (errno));
|
||||
return xstrdup (os_dev);
|
||||
}
|
||||
/* We don't call configure_device_driver since this isn't a floppy device name. */
|
||||
if (ioctl (fd, DIOCGWEDGEINFO, &dkw) == -1)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
|
@ -156,7 +155,7 @@ grub_util_find_partition_start_os (const char *dev)
|
|||
struct disklabel label;
|
||||
int p_index;
|
||||
|
||||
fd = open (dev, O_RDONLY);
|
||||
fd = grub_util_fd_open (dev, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
|
||||
|
@ -165,7 +164,6 @@ grub_util_find_partition_start_os (const char *dev)
|
|||
}
|
||||
|
||||
# if defined(__NetBSD__)
|
||||
configure_device_driver (fd);
|
||||
/* First handle the case of disk wedges. */
|
||||
if (ioctl (fd, DIOCGWEDGEINFO, &dkw) == 0)
|
||||
{
|
||||
|
|
|
@ -60,8 +60,8 @@
|
|||
after successfully opening the device. For now, it simply prevents the
|
||||
floppy driver from retrying operations on failure, as otherwise the
|
||||
driver takes a while to abort when there is no floppy in the drive. */
|
||||
void
|
||||
grub_hostdisk_configure_device_driver (grub_util_fd_t fd)
|
||||
static void
|
||||
configure_device_driver (grub_util_fd_t fd)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
|
@ -78,11 +78,24 @@ grub_hostdisk_configure_device_driver (grub_util_fd_t fd)
|
|||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
grub_hostdisk_configure_device_driver (grub_util_fd_t fd __attribute__ ((unused)))
|
||||
grub_util_fd_t
|
||||
grub_util_fd_open (const char *os_dev, int flags)
|
||||
{
|
||||
grub_util_fd_t ret;
|
||||
|
||||
#ifdef O_LARGEFILE
|
||||
flags |= O_LARGEFILE;
|
||||
#endif
|
||||
#ifdef O_BINARY
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
|
||||
ret = open (os_dev, flags);
|
||||
if (ret >= 0)
|
||||
configure_device_driver (fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
grub_int64_t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue