+2012-05-10 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Flush block cache on adding disk to device map.
+
+ * grub-core/kern/emu/hostdisk.c (flush_initial_buffer): New function.
+ (grub_hostdisk_os_dev_to_grub_drive): Call flush_initial_buffer on
+ adding.
+ (read_device_map): Likewise.
+ (open_device): Flush on opening.
+
2012-05-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/cpio.c (grub_cpio_find_file): Handle prefix.
}
#endif
+static void
+flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+#ifdef __linux__
+ int fd;
+ struct stat st;
+
+ fd = open (os_dev, O_RDONLY);
+ if (fd >= 0 && fstat (fd, &st) >= 0 && S_ISBLK (st.st_mode))
+ ioctl (fd, BLKFLSBUF, 0);
+ if (fd >= 0)
+ close (fd);
+#endif
+}
+
const char *
grub_hostdisk_os_dev_to_grub_drive (const char *os_disk, int add)
{
strcpy (map[i].drive + sizeof ("hostdisk/") - 1, os_disk);
map[i].device_map = 0;
+ flush_initial_buffer (os_disk);
+
return map[i].drive;
}
data->dev = xstrdup (dev);
data->access_mode = (flags & O_ACCMODE);
data->fd = fd;
+
+#ifdef __linux__
+ if (data->is_disk)
+ ioctl (data->fd, BLKFLSBUF, 0);
+#endif
}
if (is_partition)
drive_e, map[drive].drive);
*drive_p = c;
}
+
+ flush_initial_buffer (map[drive].device);
}
fclose (fp);