[PATCH v2 1/3] mtdpart: Allow adding a partition of a partition

Daniel Ehrenberg dehrenberg at google.com
Wed Mar 4 17:50:25 PST 2015


On Wed, Mar 4, 2015 at 11:23 AM, Brian Norris
<computersforpeace at gmail.com> wrote:
> One of the problems here is the semantics. Do we really want to do this
> offset computation when using the partition instead of the master? That
> means if the original partitioning does not cover the early part of the
> master MTD, then that piece is lost forever. e.g.,
>
>  master, size 0x1000000, with a single partition
>  /dev/mtd0, 1st partition 0x20000 - 0x40000
>
> Then, ioctl(BLKPG, /dev/mtd0) can never create any partitions before
> 0x20000. But it CAN create partitions after 0x4000! We'd have to support
> negative offsets for this to work consistently. (Now that I mention it,
> does MTD's BLKPG even do sanity checking on the arguments? I think it
> might actually accept negative offsets...).
>
> Also, it's a bit odd that you can use one partition to delete either
> another partition, or itself. e.g.,
>
>         flash_part del /dev/mtd1 0  # deletes mtd0
>         flash_part del /dev/mtd1 1  # deletes mtd1
>
> This might be acceptable, if awkward. But the first problem looks like
> it needs more thought.
>
> Brian

OK, how would you feel if I just added some stronger bounds checking
for add? I'm not sure what to do about the delete case.

For my use case, I have one partition set up as mtd0 which spans over
the whole device. I'll always be using this as my master. It'd suit my
purposes if we restricted these special add and removes to that sort
of case, but I generalized it like this because I thought it would be
cleaner. I'm open to more suggestions. It'd also work for me to make
some sort of option (kernel commandline param?) to give a number to
the master device and just refer to that directly (I haven't really
thought this option through).

Dan



More information about the linux-mtd mailing list