Removable MTD device

Gavin Lambert gavinl at compacsort.com
Tue Nov 28 19:50:17 EST 2006


What's the best way to implement a removable MTD device?

Specifically, I've got a DataFlash card with an MMC footprint.  For
fault tolerance and graycoding I'd like to use JFFS2 on it, since that
seems like a good choice.  (Compatibility isn't an issue here since most
devices can't read DF cards anyway.)

However, the problem comes when the user inserts or removes the card
while the system is running.  I can do change detection readily enough
(through polling for the card's status periodically), but I'm not sure
how I should then pass that on to MTD and the rest of the system.  In
particular, what should I do if the filesystem is mounted?  Ideally I'd
like to auto-demount it, even if there is outstanding activity (since
there's no possible way it could succeed, since the card isn't there any
more).

I was also wondering how safe it is to change MTD device parameters
(such as type/size/etc) while the device is 'added'.  I don't really
want to remove and re-add the device on remove and insert events, since
that could change the device number.  So how safe is it to just flip the
type/size of an existing MTD device to MTD_ABSENT/0 on removal?





More information about the linux-mtd mailing list