40 #include <linux/kernel.h>
41 #include <linux/slab.h>
44 #include <linux/module.h>
52 #define dbg(x) do { printk("DEBUG-CMDLINE-PART: "); printk x; } while(0)
59 #define SIZE_REMAINING UINT_MAX
60 #define OFFSET_CONTINUOUS UINT_MAX
74 static int cmdline_parsed;
88 unsigned char **extra_mem_ptr,
95 unsigned char *extra_mem;
143 extra_mem_size += name_len + 1;
146 if (
strncmp(s,
"ro", 2) == 0) {
152 if (
strncmp(s,
"lk", 2) == 0) {
164 parts = newpart(s + 1, &s, num_parts, this_part + 1,
165 &extra_mem, extra_mem_size);
172 *num_parts = this_part + 1;
179 extra_mem = (
unsigned char *)(parts + *num_parts);
187 strlcpy(extra_mem, name, name_len + 1);
189 sprintf(extra_mem,
"Partition_%03d", this_part);
191 extra_mem += name_len + 1;
193 dbg((
"partition %d: name <%s>, offset %llx, size %llx, mask flags %x\n",
194 this_part, parts[this_part].name, parts[this_part].offset,
195 parts[this_part].size, parts[this_part].mask_flags));
199 *extra_mem_ptr = extra_mem;
211 static int mtdpart_setup_real(
char *s)
219 int mtd_id_len, num_parts;
230 mtd_id_len = p - mtd_id;
232 dbg((
"parsing <%s>\n", p+1));
238 parts = newpart(p + 1,
242 (
unsigned char**)&this_mtd,
243 mtd_id_len + 1 +
sizeof(*this_mtd) +
253 return PTR_ERR(parts);
258 ALIGN((
unsigned long)this_mtd,
sizeof(
void *));
262 this_mtd->
mtd_id = (
char*)(this_mtd + 1);
266 this_mtd->
next = partitions;
267 partitions = this_mtd;
269 dbg((
"mtdid=<%s> num_parts=<%d>\n",
295 static int parse_cmdline_partitions(
struct mtd_info *master,
302 const char *mtd_id = master->
name;
305 if (!cmdline_parsed) {
306 err = mtdpart_setup_real(
cmdline);
311 for (part = partitions;
part; part = part->
next) {
313 for (i = 0, offset = 0; i < part->
num_parts; i++) {
317 offset = part->
parts[
i].offset;
322 if (part->
parts[i].size == 0) {
324 "%s: skipping zero sized partition\n",
333 if (offset + part->
parts[i].size > master->
size) {
335 "%s: partitioning exceeds flash size, truncating\n",
339 offset += part->
parts[
i].size;
363 static int mtdpart_setup(
char *s)
369 __setup(
"mtdparts=", mtdpart_setup);
373 .parse_fn = parse_cmdline_partitions,
374 .name =
"cmdlinepart",
377 static int __init cmdline_parser_init(
void)