]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_flush):
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 19 Apr 2011 20:39:14 +0000 (22:39 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 19 Apr 2011 20:39:14 +0000 (22:39 +0200)
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.

ChangeLog
grub-core/kern/emu/hostdisk.c
include/grub/emu/hostdisk.h
util/grub-setup.c

index 2eade534dc90e72a3395549d94f4396f047a47c3..1eff73ca349c31e8c2b239e514bd0baa206e1873 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index f01e21aa07f9c41da49287428654f33a3bf2abc5..63bca37ee76f84a638ccf40576c97e00a05e3473 100644 (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);
index d8cc02e145d667bb3516bb0c166c3f1cede06eb5..842dff496f8c4462694c70ffa6f5084d38d0b523 100644 (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 */
index ed2d63fdd24f3eb62670290f51a34c3785a4159b..7d47fa6544baa041fd0454eed73e3f6c18567b50 100644 (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);