aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xandroid-configure.sh8
-rw-r--r--android/config/linux-x86/config-host.h1
-rw-r--r--cutils.c16
-rw-r--r--qemu-common.h2
4 files changed, 27 insertions, 0 deletions
diff --git a/android-configure.sh b/android-configure.sh
index 7a23954..0e95e04 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -419,6 +419,14 @@ echo "#define CONFIG_GDBSTUB 1" >> $config_h
echo "#define CONFIG_SLIRP 1" >> $config_h
echo "#define CONFIG_SKINS 1" >> $config_h
echo "#define CONFIG_TRACE 1" >> $config_h
+
+# only Linux has fdatasync()
+case "$OS" in
+ linux-*)
+ echo "#define CONFIG_FDATASYNC 1" >> $config_h
+ ;;
+esac
+
# the -nand-limits options can only work on non-windows systems
if [ "$OS" != "windows" ] ; then
echo "#define CONFIG_NAND_LIMITS 1" >> $config_h
diff --git a/android/config/linux-x86/config-host.h b/android/config/linux-x86/config-host.h
index a97d2c6..904dbfa 100644
--- a/android/config/linux-x86/config-host.h
+++ b/android/config/linux-x86/config-host.h
@@ -11,3 +11,4 @@
#define CONFIG_UNAME_RELEASE ""
#define CONFIG_IOTHREAD 1
#define CONFIG_IOVEC 1
+#define CONFIG_FDATASYNC 1
diff --git a/cutils.c b/cutils.c
index ffe5c71..2365e68 100644
--- a/cutils.c
+++ b/cutils.c
@@ -115,6 +115,22 @@ int qemu_fls(int i)
return 32 - clz32(i);
}
+/*
+ * Make sure data goes on disk, but if possible do not bother to
+ * write out the inode just for timestamp updates.
+ *
+ * Unfortunately even in 2009 many operating systems do not support
+ * fdatasync and have to fall back to fsync.
+ */
+int qemu_fdatasync(int fd)
+{
+#ifdef CONFIG_FDATASYNC
+ return fdatasync(fd);
+#else
+ return fsync(fd);
+#endif
+}
+
/* io vectors */
void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint)
diff --git a/qemu-common.h b/qemu-common.h
index 1416dfd..664e83f 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -110,8 +110,10 @@ void pstrcpy(char *buf, int buf_size, const char *str);
char *pstrcat(char *buf, int buf_size, const char *s);
int strstart(const char *str, const char *val, const char **ptr);
int stristart(const char *str, const char *val, const char **ptr);
+int qemu_strnlen(const char *s, int max_len);
time_t mktimegm(struct tm *tm);
int qemu_fls(int i);
+int qemu_fdatasync(int fd);
#define qemu_isalnum(c) isalnum((unsigned char)(c))
#define qemu_isalpha(c) isalpha((unsigned char)(c))