Index: posixmodule.c =================================================================== --- posixmodule.c (revision 65558) +++ posixmodule.c (working copy) @@ -1841,6 +1841,26 @@ } #endif +/* OS X and perhaps other OSes provide fullfsync to fully flush file data AND file metadata */ +#ifdef F_FULLFSYNC +static PyObject * +fullfsync(PyObject *self, PyObject *fdobj) +{ + int res; + int fd; + fd = PyObject_AsFileDescriptor(fdobj); + if (fd < 0) + return NULL; + Py_BEGIN_ALLOW_THREADS + res = fcntl(fd, F_FULLFSYNC, 0); + Py_END_ALLOW_THREADS + if (res < 0) + return posix_error(); + Py_INCREF(Py_None); + return Py_None; +} +#endif + #ifdef HAVE_FSYNC PyDoc_STRVAR(posix_fsync__doc__, "fsync(fildes)\n\n\ @@ -1849,7 +1869,11 @@ static PyObject * posix_fsync(PyObject *self, PyObject *fdobj) { - return posix_fildes(fdobj, fsync); + #ifdef F_FULLFSYNC + return fullfsync(self, fdobj); + #else + return posix_fildes(fdobj, fsync); + #endif } #endif /* HAVE_FSYNC */