[Mono-list] Flush FileStream to disk (fsync before 4.0 API)?

Sandy Armstrong sanfordarmstrong at gmail.com
Mon Dec 27 19:47:08 EST 2010


Apparently Tomboy is one of those apps that suffers from delayed
allocation issues in ext4.  In certain shutdown scenarios this can
lead to zero-byte files for any note saved on exit.

I noticed that .NET 4 added FileStream.Flush(bool flushToDisk), which
according to the source does perform an fsync.  But given that, I must
assume that the pre-.NET 4 Flush methods do not call fsync, and I need
to maintain compatibility with older versions of Mono.  The new Flush
overload calls an internal API, MonoIO.Flush.

What is the accepted way to flush changes to disk such that an fsync
occurs?  Do I call FileStream.Flush() and then pass the handle to
Mono.Posix's fsync extern?  Am I missing something obvious that
already handles this for me?

Thanks in advance,

More information about the Mono-list mailing list