This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: ofstream, fsync and data loss bugs
> 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.
Thanks for pointers. So there is no way how to write safe streamlike open/
write/close routine by some portable code, not dependent on gcc.
The current situation looks like this:
* ext4 maintainer claims that he is fine with fulfilling POSIX standard.
* libstd is point is to adhere to ISO standard.
Both are correct in their sense.
In effect bunch of C++ apps will have dataloss problems and for the people
who care enough some ifdef hacks are neccessary if they want to write
portable code based on fstreams...
Is there some "bugzilla" for ISO C++ Standard? :)
Pavel