Introduce grub_util_file_sync and use it instead of fsync(fileno(f)).
Fixes build for windows.
This commit is contained in:
parent
b1f742c103
commit
4f9541226c
10 changed files with 37 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue