* grub-core/kern/emu/hostdisk.c (open_device): Sync on close and not
on open. (grub_util_biosdisk_close): Likewise.
This commit is contained in:
parent
72a89a54e1
commit
478182a838
2 changed files with 37 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2011-04-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/kern/emu/hostdisk.c (open_device): Sync on close and not
|
||||||
|
on open.
|
||||||
|
(grub_util_biosdisk_close): Likewise.
|
||||||
|
|
||||||
2011-04-08 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-04-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/kern/emu/getroot.c (grub_util_get_grub_dev): Add missing
|
* grub-core/kern/emu/getroot.c (grub_util_get_grub_dev): Add missing
|
||||||
|
|
|
@ -664,7 +664,17 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
||||||
{
|
{
|
||||||
free (data->dev);
|
free (data->dev);
|
||||||
if (data->fd != -1)
|
if (data->fd != -1)
|
||||||
|
{
|
||||||
|
if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY)
|
||||||
|
{
|
||||||
|
fsync (data->fd);
|
||||||
|
#ifdef __linux__
|
||||||
|
ioctl (data->fd, BLKFLSBUF, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
close (data->fd);
|
close (data->fd);
|
||||||
|
}
|
||||||
|
|
||||||
/* Open the partition. */
|
/* Open the partition. */
|
||||||
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev);
|
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev);
|
||||||
|
@ -675,10 +685,6 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush the buffer cache to the physical disk.
|
|
||||||
XXX: This also empties the buffer cache. */
|
|
||||||
ioctl (fd, BLKFLSBUF, 0);
|
|
||||||
|
|
||||||
data->dev = xstrdup (dev);
|
data->dev = xstrdup (dev);
|
||||||
data->access_mode = (flags & O_ACCMODE);
|
data->access_mode = (flags & O_ACCMODE);
|
||||||
data->fd = fd;
|
data->fd = fd;
|
||||||
|
@ -716,7 +722,16 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
||||||
{
|
{
|
||||||
free (data->dev);
|
free (data->dev);
|
||||||
if (data->fd != -1)
|
if (data->fd != -1)
|
||||||
|
{
|
||||||
|
if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY)
|
||||||
|
{
|
||||||
|
fsync (data->fd);
|
||||||
|
#ifdef __linux__
|
||||||
|
ioctl (data->fd, BLKFLSBUF, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
close (data->fd);
|
close (data->fd);
|
||||||
|
}
|
||||||
|
|
||||||
fd = open (map[disk->id].device, flags);
|
fd = open (map[disk->id].device, flags);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
|
@ -932,7 +947,16 @@ grub_util_biosdisk_close (struct grub_disk *disk)
|
||||||
|
|
||||||
free (data->dev);
|
free (data->dev);
|
||||||
if (data->fd != -1)
|
if (data->fd != -1)
|
||||||
|
{
|
||||||
|
if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY)
|
||||||
|
{
|
||||||
|
fsync (data->fd);
|
||||||
|
#ifdef __linux__
|
||||||
|
ioctl (data->fd, BLKFLSBUF, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
close (data->fd);
|
close (data->fd);
|
||||||
|
}
|
||||||
free (data);
|
free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue