[Baypiggies] File IO question

Rick Kwan kenobi at gmail.com
Tue Jul 25 15:56:19 CEST 2006


Is this on top of JFFS2 sitting on top of an MTD-style device?

I believe JFFS2 writes a new copy of the file somewhere, in many cases
the end of the file system, not on top of the previous incarnation.
But I would also like to hear a more authoritative answer.  (I'm also
doing embedded Linux and writing to flash, but building on someone
else's work.)

--Rick Kwan

On 7/25/06, Ken Seehart <ken at seehart.com> wrote:
> I am writing a linux embedded application that writes to a FLASH disk.
> It needs to reliably recover from a power down at any time.  So I have
> implemented a tandem file writing scheme to ensure that an uncorrupted
> version of the data file exists.  I am using shelve for my pair of
> tandem data files because it is sufficient for my needs.  I use a pair
> of single byte binary files to record the status of the data files.
>
> My question is this: If I write a single byte to a file that contains
> exactly one byte, can I be sure that a power outage during the write
> will not render the file unreadable?
>
> f = open("valid", "w")
> f.write('\1');
> f.close();
> ...
> f = open("valid", "w")
> f.write('\0');
> f.close();
>
> In other words, if the file initially contains a 0 or 1, and the above
> code is executed repeatedly, can I be sure that my file will contain a 0
> or 1 if the power is shut off at a random time during execution?
>
> - Ken
>
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> http://mail.python.org/mailman/listinfo/baypiggies
>


More information about the Baypiggies mailing list