UBIFS Question

Corentin Chary corentin.chary at gmail.com
Fri Jul 10 16:01:22 EDT 2009

On Fri, Jul 10, 2009 at 8:43 PM, Laurent .<sid6582 at msn.com> wrote:
> In /mnt/alphaflight I generate a small new.txt file with vi, which contains a few lines of characters.
> After saving, I immediately power-off brutally.
> I power-on again, mount, and the new.txt file is not there...
> I recreate the file, I wait 20 seconds or so and power-off brutally.
> I power-on again, mount and now I have:
> -rw-r--r--    1 1000     1000          397 Dec 31  2002 indexOnline.html
> -rw-r--r--    1 root     root            0 Jan  1 00:00 new.txt
> -rw-r--r--    1 1000     1000          104 Dec 31  2002 obfuscAFL.bat
> Size 0 ... I can understand that since I did not have time to sync.
> It’s funny though that the file is present in the directory but the contents are not there ?
> If I do this programmatically, I presume I can force a sync after I close the file ?
> Is it safe to do so ? Would you know the C API to use to do a sync programmatically ?

I think you should read
An use fsync() on your file.
Quotting "close(2) manual"

       A  successful close does not guarantee that the data has been
       saved to disk, as the kernel defers writes.  It is not common
for a file system to flush the buffers
       when the stream is closed.  If you need to be sure that the
data is physically stored use fsync(2).
       (It will depend on the disk hardware at this point.)

Corentin Chary
http://xf.iksaif.net - http://uffs.org

More information about the linux-mtd mailing list