temporary files on mtd file systems

Artem Bityutskiy dedekind1 at gmail.com
Tue Aug 20 09:51:01 EDT 2013


On Mon, 2013-08-19 at 15:55 +0200, Ricard Wanderlof wrote:
> Am I missing something here, or is there a "good" way to deal with this? 
> Of course there are several cleanup scenarios that could be imagened, such 
> as cleaning out all 'foo.*' files during boot for instance.
> 
> For applications that are not multi threaded, i.e. there may only be one 
> process updating foo, one way is to use the same temporary file name each 
> time, e.g. foo.temp. But things get awkward when using for instance glib, 
> which has a nice g_file_set_contents() call, complete with temporary file 
> handling and all, but which uses mkstemp as above to create the temporary 
> file, so there is no easy way of telling glib what filename to use, short 
> of rewriting a local function which indeed uses a constant temporary file 
> name.

Good question, the only thing which comes to my mind is that one could
try to use extended attributes or 'standard' (chattr(1)) attributes.

Something like having a special chattr which would indicate that the
file is up-to-date. When you need to update the file atomically, you
start with removing the attribute, syncing the file, then updating the
file, then syncing it, then creating the attribute, and probably syncing
too.

-- 
Best Regards,
Artem Bityutskiy




More information about the linux-mtd mailing list