It still needs to be enhanced to be fully portable and working even if fsync() implementation is insane (e.g., on OSX). --- Notes: Although ideally gnulib would provide us with a sane fsync() and fdatasync() replacements (it already does so for fsync on Win32) so this could probably be dropped in favor of a possible future extension of gnulib (we do not provide any better solution anyway). src/libvirt_private.syms | 1 + src/util/virfile.c | 16 ++++++++++++++++ src/util/virfile.h | 2 ++ 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index dedbd16..9666a0a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1172,6 +1172,7 @@ virFileDirectFdFree; virFileDirectFdNew; virFileFclose; virFileFdopen; +virFileSync; # virnetmessage.h diff --git a/src/util/virfile.c b/src/util/virfile.c index 1158998..50b8aab 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -334,3 +334,19 @@ int virFileUnlock(int fd ATTRIBUTE_UNUSED, return -ENOSYS; } #endif + +int +virFileSync(int fd, bool metadata) +{ + int ret; + + /* XXX This needs to be enhanced to properly sync even on OSX which + * lacks sane fsync() */ + + if (metadata) + ret = fsync(fd); + else + ret = fdatasync(fd); + + return ret; +} diff --git a/src/util/virfile.h b/src/util/virfile.h index e025614..0b14e1d 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -68,4 +68,6 @@ void virFileDirectFdFree(virFileDirectFdPtr dfd); int virFileLock(int fd, bool shared, off_t start, off_t len); int virFileUnlock(int fd, off_t start, off_t len); +int virFileSync(int fd, bool metadata); + #endif /* __VIR_FILES_H */ -- 1.7.7 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list