+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>
* grub-core/kern/emu/getroot.c (grub_util_get_grub_dev): Add missing
{
free (data->dev);
if (data->fd != -1)
- close (data->fd);
+ {
+ 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);
+ }
/* Open the partition. */
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev);
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->access_mode = (flags & O_ACCMODE);
data->fd = fd;
{
free (data->dev);
if (data->fd != -1)
- close (data->fd);
+ {
+ 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);
+ }
fd = open (map[disk->id].device, flags);
if (fd >= 0)
free (data->dev);
if (data->fd != -1)
- close (data->fd);
+ {
+ 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);
+ }
free (data);
}