ofstream, fsync and data loss bugs
Paolo Carlini
paolo.carlini@oracle.com
Wed Mar 17 17:19:00 GMT 2010
Hi,
> There is no fsync() call for the stream, there is no direct access
> to file descriptor, flush() is reported not to mimic fsync().
>
> 1. Is there some way how to force fsync()?
> 2. If not should be this considered as bug/enh request for libstdc++?
>
My first reaction to this issue, is that in general the C++ fstreams, as
specified in the ISO C++ Standard which we are implementing, don't do
anything special beyond the C way of opening and closing files. Thus, if
in C you have to call fsync by hand, I don't think there is anything to
fix in the C++ library. About fsync itself, then, there is the rather
well known problem with the C++ fstreams not exporting the underlying
FILE*: for that issue, we are providing a thin wrapper, called
stdio_filebuf, <ext/stdio_filebuf.h>, which you may find useful, or look
on the net for more complete solutions. There are many.
I don't think there is something new in C++1x about this specific
issue... but I may be wrong, in case just let me know, and I'll see if
we can raise the priority for implementing those bits.
Paolo.
More information about the Libstdc++
mailing list