any problem with changing mtdparts to a sysfs parameter?

Ken Cecka ceckak at alumni.washington.edu
Mon May 4 15:55:53 EDT 2009


I'm trying to modify the firmware update scripts on a board I'm working on 
to allow updates to change the partition layout.  One thing that would be 
extremely useful is a way to change the partition layout at runtime, so that 
I can read the existing partition data into RAM, change the layout, then 
write the data back to the rearranged partitions.

I've been experimenting with this by converting mtdparts to a sysfs 
parameter:
  static char mtdparts[COMMAND_LINE_SIZE];
  module_param_string(mtdparts, mtdparts, sizeof(mtdparts), S_IRUGO | 
S_IWUSR);
  MODULE_PARM_DESC(mtdparts, "MTD partitions");

After some other modifications to allow mtdpart_setup_real to be called more 
than once, things seem to be working well.  I can unbind the physmap_of 
driver, define a new layout in the mtdparts sysfs file, then rebind the 
physmap_of driver and see the new partition layout.

One point of concern I had - mtdpart_setup_real was protected so that it 
only runs once, but I don't really understand why.  It allocates an array of 
mtd_partition structures, but it looks like the caller is responsible for 
freeing this array.  Is there any problem with letting 
parse_cmdline_partitions call mtdpart_setup_real every time?

Thanks,
Ken





More information about the linux-mtd mailing list