This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: ofstream, fsync and data loss bugs
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Pavel Sanda <ps at twin dot jikos dot cz>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Wed, 17 Mar 2010 18:19:41 +0100
- Subject: Re: ofstream, fsync and data loss bugs
- References: <20100317165853.GA3905@atrey.karlin.mff.cuni.cz>
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.