safe flash filesystem
Russ Dill
Russ.Dill at asu.edu
Thu Jun 21 17:26:39 EDT 2001
If its just a config file, why make all this so complicated?
struct node {
u32 magic;
char valid;
u32 version;
u32 data_crc;
u32 hdr_crc;
char data[DATA_SIZE];
};
set aside 2-4 eraseblocks (preferably paramater blocks) and on mount,
find the valid config, walk though the flash and find the valid node
with the matching crc's and highest version (watch wraparound).
on writing a new config, if there is space left in the current erase
block, put it after the last one, after finishing writing it, set the
previos config's valid field to zero (flash lets you do this). If the
eraseblock is full, write in the next eraseblock, and when you are done,
erase the previous eraseblock.
All of this can be done in userspace or with a userspace library, just
mmap an mtd, and then use the erase ioctls.
databases and logs...thats another story
More information about the linux-mtd
mailing list