+2013-11-27 Colin Watson <cjwatson@ubuntu.com>
+
+ Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls
+ into no-ops, and use it in programs that copy files but do not need
+ to take special care to sync writes (grub-mknetdir, grub-rescue,
+ grub-mkstandalone).
+
2013-11-26 Colin Watson <cjwatson@ubuntu.com>
* tests/util/grub-fs-tester.in: Execute xorriso from $PATH rather
}
}
+static int allow_fd_syncs = 1;
+
static void
grub_util_fd_sync_volume (grub_util_fd_t fd)
{
void
grub_util_fd_sync (grub_util_fd_t fd)
{
- switch (fd->type)
+ if (allow_fd_syncs)
{
- case GRUB_UTIL_FD_FILE:
- fsync (fd->fd);
- return;
- case GRUB_UTIL_FD_DISK:
- grub_util_fd_sync_volume (fd);
- return;
+ switch (fd->type)
+ {
+ case GRUB_UTIL_FD_FILE:
+ fsync (fd->fd);
+ return;
+ case GRUB_UTIL_FD_DISK:
+ grub_util_fd_sync_volume (fd);
+ return;
+ }
}
}
+void
+grub_util_disable_fd_syncs (void)
+{
+ allow_fd_syncs = 0;
+}
+
void
grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
{
return strerror (errno);
}
+static int allow_fd_syncs = 1;
+
void
grub_util_fd_sync (grub_util_fd_t fd)
{
- fsync (fd);
+ if (allow_fd_syncs)
+ fsync (fd);
+}
+
+void
+grub_util_disable_fd_syncs (void)
+{
+ allow_fd_syncs = 0;
}
void
return real_read;
}
+static int allow_fd_syncs = 1;
+
void
grub_util_fd_sync (grub_util_fd_t fd)
{
- FlushFileBuffers (fd);
+ if (allow_fd_syncs)
+ FlushFileBuffers (fd);
+}
+
+void
+grub_util_disable_fd_syncs (void)
+{
+ allow_fd_syncs = 0;
}
void
void
grub_util_fd_sync (grub_util_fd_t fd);
void
+grub_util_disable_fd_syncs (void);
+void
EXPORT_FUNC(grub_util_fd_close) (grub_util_fd_t fd);
grub_uint64_t
memdisk_path, config_path,
mkimage_target, note, comp);
fflush (fp);
- fsync (fileno (fp));
+ grub_util_fd_sync (fileno (fp));
fclose (fp);
}
const char *pkglibdir;
grub_util_host_init (&argc, &argv);
+ grub_util_disable_fd_syncs ();
rootdir = xstrdup ("/srv/tftp");
pkglibdir = grub_util_get_pkglibdir ();
const char *pkgdatadir;
grub_util_host_init (&argc, &argv);
+ grub_util_disable_fd_syncs ();
pkgdatadir = grub_util_get_pkgdatadir ();
GRUB_COMPRESSION_AUTO);
sz = ftello (sa);
fflush (sa);
- fsync (fileno (sa));
+ grub_util_fd_sync (fileno (sa));
fclose (sa);
if (sz > 32768)
int i;
grub_util_host_init (&argc, &argv);
+ grub_util_disable_fd_syncs ();
files = xmalloc ((argc + 1) * sizeof (files[0]));