]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Introduce grub_util_file_sync and use it instead of fsync(fileno(f)).
authorVladimir Serbinenko <phcoder@gmail.com>
Wed, 27 Nov 2013 13:13:50 +0000 (14:13 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Wed, 27 Nov 2013 13:13:50 +0000 (14:13 +0100)
Fixes build for windows.

ChangeLog
grub-core/osdep/aros/hostdisk.c
grub-core/osdep/unix/hostdisk.c
grub-core/osdep/windows/hostdisk.c
include/grub/emu/misc.h
include/grub/osdep/hostfile_windows.h
util/editenv.c
util/grub-editenv.c
util/grub-install-common.c
util/grub-mkimage.c

index d06f3e7bad7f13f673f320ad785a02700fdb85cb..b4708df7f9ff71ec7e110ee6b1b59ee0e44b5da4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-27  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Introduce grub_util_file_sync and use it instead of fsync(fileno(f)).
+       Fixes build for windows.
+
 2013-11-27  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * gentpl.py: Don't generate platform-dependent conditionals for
index b1539076683ad24758364669511930951768d74e..c7efb9608999795cb7551323bd04b0715272ac55 100644 (file)
@@ -485,6 +485,15 @@ grub_util_fd_sync (grub_util_fd_t fd)
     }
 }
 
+void
+grub_util_file_sync (FILE *f)
+{
+  fflush (f);
+  if (!allow_fd_syncs)
+    return;
+  fsync (fileno (f));
+}
+
 void
 grub_util_disable_fd_syncs (void)
 {
index fc88ed4cc2a53f2012d40b4945a9d40852358244..309562af4237d346afe59c6cfac713a290d58b4f 100644 (file)
@@ -200,6 +200,15 @@ grub_util_fd_sync (grub_util_fd_t fd)
     fsync (fd);
 }
 
+void
+grub_util_file_sync (FILE *f)
+{
+  fflush (f);
+  if (!allow_fd_syncs)
+    return;
+  fsync (fileno (f));
+}
+
 void
 grub_util_disable_fd_syncs (void)
 {
index 4748a616fe0464b362e09411becd3bc949dd7d80..41ab318c0ba54ab0d5325b9109fb91961f524436 100644 (file)
@@ -584,12 +584,16 @@ grub_util_fopen (const char *path, const char *mode)
   return ret;
 }
 
-int fsync (int fno)
+void
+grub_util_file_sync (FILE *f)
 {
   HANDLE hnd;
-  hnd = (HANDLE) _get_osfhandle (fno);
+
+  fflush (f);
+  if (!allow_fd_syncs)
+    return;
+  hnd = (HANDLE) _get_osfhandle (fileno (f));
   FlushFileBuffers (hnd);
-  return 0;
 }
 
 int
index c4e579b0bafe5066600bd02f9b3d026340239184..4f708cf104fcbdbfbc4a92b23d7e489d1b12109d 100644 (file)
@@ -66,4 +66,6 @@ FILE *
 grub_util_fopen (const char *path, const char *mode);
 #endif
 
+void grub_util_file_sync (FILE *f);
+
 #endif /* GRUB_EMU_MISC_H */
index e928b3f96415eae91188d58a330a7838714e81b3..36615b2c451bc60fcab1458842f6f69abb84189f 100644 (file)
@@ -79,10 +79,4 @@ grub_util_utf8_to_tchar (const char *in);
 char *
 grub_util_tchar_to_utf8 (LPCTSTR in);
 
-#ifdef __MINGW32__
-
-int fsync (int fno);
-
-#endif
-
 #endif
index 264531345f07714d85c9cd0fbf866f3889fa4a5e..f79e405d7073694d027f501bce206c91210d316e 100644 (file)
@@ -53,7 +53,8 @@ grub_util_create_envblk_file (const char *name)
     grub_util_error (_("cannot write to `%s': %s"), namenew,
                     strerror (errno));
 
-  fsync (fileno (fp));
+
+  grub_util_file_sync (fp);
   free (buf);
   fclose (fp);
 
index cffcf9e0db09de82d70f822833ba040d3384866c..540495b452bbdf16315e2f5de5136f963d736a80 100644 (file)
@@ -188,7 +188,7 @@ write_envblk (const char *name, grub_envblk_t envblk)
     grub_util_error (_("cannot write to `%s': %s"), name,
                     strerror (errno));
 
-  fsync (fileno (fp));
+  grub_util_file_sync (fp);
   fclose (fp);
 }
 
index fcf994d5b5be311359ea1c6b1828fe31e1893524..91b558e1ee29aea60e3d753b22f283ef033c1319 100644 (file)
@@ -491,8 +491,7 @@ grub_install_make_image_wrap (const char *dir, const char *prefix,
   grub_install_make_image_wrap_file (dir, prefix, fp, outname,
                                     memdisk_path, config_path,
                                     mkimage_target, note, comp);
-  fflush (fp);
-  grub_util_fd_sync (fileno (fp));
+  grub_util_file_sync (fp);
   fclose (fp);
 }
 
index 33cce36ad3ff71deaf0f5f6e8d13e4541972454b..02437417d9f386e0fbca4216174847ff6fceb838 100644 (file)
@@ -285,8 +285,7 @@ main (int argc, char *argv[])
                               arguments.image_target, arguments.note,
                               arguments.comp);
 
-  fflush (fp);
-  fsync (fileno (fp));
+  grub_util_file_sync  (fp);
   fclose (fp);
 
   if (arguments.dir)