<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
fsync does not seem to be working as I think it should.<br>
<br>
I have a large file that already exists on the drive.<br>
<br>
I do the following:<br>
File* fp = fopen (filename, "w+b");<br>
<br>
if (fp)<br>
{<br>
char c = 'a';<br>
fwrite (&a, 1, 1, fp);<br>
fsync(fileno(fp));<br>
fclose (fp);<br>
restartRtems();<br>
}<br>
<br>
The file on disk remains unchanged<br>
<br>
Eugeny S. Mints wrote:<br>
<blockquote type="cite"
cite="midPine.LNX.4.33.0304161646540.3654-100000@mail.oktet.ru">
<pre wrap="">On Wed, 16 Apr 2003, Joel Sherrill wrote:
</pre>
<blockquote type="cite">
<pre wrap="">
"Eugeny S. Mints" wrote:
</pre>
<blockquote type="cite">
<pre wrap="">On Wed, 16 Apr 2003, Joel Sherrill wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Chris Caudle wrote:
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">I have found that listing the directory after closing the file
seems to do the trick. It must purge the buffers to the disk.
</pre>
</blockquote>
<pre wrap="">I haven't looked at the DOSFS code yet, does it have a sync() or fsync() function?
If the file system keeps the allocation table cached in memory, you may need to flush the allocation table to the storage device, especially if you are shutting down power on the RTEMS system and moving the storage device to a different machine (or just re-booting into Windows, Linux, MacOS etc. on the same machine).
</pre>
</blockquote>
<pre wrap="">Or at least a flush() on the file itself?
</pre>
</blockquote>
<pre wrap="">Sorry, that I was silent for a long time but I was away from
my mail box.
As to sync/fsync/flush - sync call is implemented in DOSFS.
I suppose that Angelo needs UNmount the volume to achieve
his goals. During 'unmount' a volume is automatically
syncronized.
</pre>
</blockquote>
<pre wrap="">I understand that it has to sync when unmounting but shouldn't
sync work even with it staying mounted? I think the issue here
was simply that he was surprised it wasn't written until he closed.
[NOTE: This is standard behavior for many systems so is not unexpected.]
So the question is.. if I have an open file and want to ensure its
contents are written to disk, is it sufficient to sync() or should
it flush() and sync() and what? I think unmounting is a bit too
heavy handed because it potentially impacts other tasks.
</pre>
</blockquote>
<pre wrap=""><!---->
If you have an open file and want to ensure its
contents are written to disk you shoul sync() it - and this
sync call is implemented in DOSFS.
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Not to get me started on a tangent but my disertation included some
thought on the idea
that different embedded systems needed different disk caching and
scheduling algorithms.
Ideally those should be selectable on a per-file basis but at a
partition level would be
acceptable. For example, a write-only log file should have data kept
only long enough to
get it to disk but a sequentially read file could use read-ahead and
discard as soon as
the application read the data. With some (intelligent) hints from the
application,
the algorithms could be better selected.
</pre>
<blockquote type="cite">
<pre wrap="">-- Chris Caudle
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<pre wrap="">--
Eugeny S. Mints
OKTET Ltd.
1 Ulianovskaya st., Petergof, St.Petersburg, 198904 Russia
Phone: +7(812)428-4384 Fax: +7(812)327-2246
<a class="moz-txt-link-freetext" href="mailto:Eugeny.Mints@oktet.ru">mailto:Eugeny.Mints@oktet.ru</a>
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="$mailwrapcol">--
Angelo Fraietta
PO Box 859
Hamilton NSW 2303
Home Page
<a class="moz-txt-link-freetext" href="http://www.users.bigpond.com/angelo_f/">http://www.users.bigpond.com/angelo_f/</a>
There are those who seek knowledge for the sake of knowledge - that is CURIOSITY
There are those who seek knowledge to be known by others - that is VANITY
There are those who seek knowledge in order to serve - that is LOVE
Bernard of Clairvaux (1090 - 1153)</pre>
<br>
</body>
</html>