* grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_flush):

New function.
	(grub_util_biosdisk_close): Use grub_util_biosdisk_flush.
	* include/grub/emu/hostdisk.h (grub_util_biosdisk_flush): New proto.
	* util/grub-setup.c (setup): Use grub_util_biosdisk_flush.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-04-19 22:39:14 +02:00
parent bba79a1502
commit e8f28d4c0e
4 changed files with 35 additions and 13 deletions

View file

@ -1,3 +1,11 @@
2011-04-19 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_flush):
New function.
(grub_util_biosdisk_close): Use grub_util_biosdisk_flush.
* include/grub/emu/hostdisk.h (grub_util_biosdisk_flush): New proto.
* util/grub-setup.c (setup): Use grub_util_biosdisk_flush.
2011-04-19 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/gfxterm.c (grub_gfxterm_fullscreen): Preserve previous

View file

@ -945,6 +945,27 @@ grub_util_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
return grub_errno;
}
grub_err_t
grub_util_biosdisk_flush (struct grub_disk *disk)
{
struct grub_util_biosdisk_data *data = disk->data;
if (disk->dev->id != GRUB_DISK_DEVICE_BIOSDISK_ID)
return GRUB_ERR_NONE;
if (data->fd == -1)
{
data->fd = open_device (disk, 0, O_RDONLY);
if (data->fd < 0)
return grub_errno;
}
fsync (data->fd);
#ifdef __linux__
if (data->is_disk)
ioctl (data->fd, BLKFLSBUF, 0);
#endif
return GRUB_ERR_NONE;
}
static void
grub_util_biosdisk_close (struct grub_disk *disk)
{
@ -954,13 +975,7 @@ grub_util_biosdisk_close (struct grub_disk *disk)
if (data->fd != -1)
{
if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY)
{
fsync (data->fd);
#ifdef __linux__
if (data->is_disk)
ioctl (data->fd, BLKFLSBUF, 0);
#endif
}
grub_util_biosdisk_flush (disk);
close (data->fd);
}
free (data);

View file

@ -28,5 +28,6 @@ char *grub_util_biosdisk_get_grub_dev (const char *os_dev);
const char *grub_util_biosdisk_get_osdev (grub_disk_t disk);
int grub_util_biosdisk_is_present (const char *name);
int grub_util_biosdisk_is_floppy (grub_disk_t disk);
grub_err_t grub_util_biosdisk_flush (struct grub_disk *disk);
#endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */

View file

@ -520,9 +520,7 @@ unable_to_embed:
core_path_dev = grub_make_system_path_relative_to_its_root (core_path_dev_full);
free (core_path_dev_full);
/* It is a Good Thing to sync two times. */
sync ();
sync ();
grub_util_biosdisk_flush (root_dev->disk);
#define MAX_TRIES 5
@ -583,7 +581,7 @@ unable_to_embed:
grub_util_info ("error message = %s", grub_errmsg);
grub_errno = GRUB_ERR_NONE;
sync ();
grub_util_biosdisk_flush (root_dev->disk);
sleep (1);
}
@ -674,8 +672,8 @@ unable_to_embed:
grub_util_error ("%s", grub_errmsg);
/* Sync is a Good Thing. */
sync ();
grub_util_biosdisk_flush (root_dev->disk);
grub_util_biosdisk_flush (dest_dev->disk);
free (core_path);
free (core_img);