• Home
  • Raw
  • Download

Lines Matching +full:partitions +full:- +full:table +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Read flash partition table from command line
5 * Copyright © 2002 SYSGO Real-Time Solutions GmbH
6 * Copyright © 2002-2010 David Woodhouse <dwmw2@infradead.org>
11 * <mtddef> := <mtd-id>:<partdef>[,<partdef>]
12 * <partdef> := <size>[@<offset>][<name>][ro][lk][slc]
13 * <mtd-id> := unique name used in mapping driver/device (mtd->name)
14 * <size> := standard linux memsize OR "-" to denote all remaining space
17 * <offset> := standard linux memsize
23 * <size> and <offset> can be specified such that the parts are out of order
32 * edb7312-nor:-
34 * 1 NOR Flash with 2 partitions, 1 NAND with one
35 * edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
43 #include <linux/mtd/partitions.h>
49 #define dbg(x) do { printk("DEBUG-CMDLINE-PART: "); printk x; } while(0)
67 static struct cmdline_mtd_partition *partitions; variable
90 unsigned long long size, offset = OFFSET_CONTINUOUS; in newpart() local
98 if (*s == '-') { in newpart()
106 return ERR_PTR(-EINVAL); in newpart()
115 /* check for offset */ in newpart()
118 offset = memparse(s, &s); in newpart()
132 return ERR_PTR(-EINVAL); in newpart()
134 name_len = p - name; in newpart()
162 /* test if more partitions are following */ in newpart()
165 pr_err("no partitions allowed after a fill-up partition\n"); in newpart()
166 return ERR_PTR(-EINVAL); in newpart()
168 /* more partitions follow, parse them */ in newpart()
183 return ERR_PTR(-ENOMEM); in newpart()
188 * enter this partition (offset will be calculated later if it is in newpart()
192 parts[this_part].offset = offset; in newpart()
202 dbg(("partition %d: name <%s>, offset %llx, size %llx, mask flags %x\n", in newpart()
203 this_part, parts[this_part].name, parts[this_part].offset, in newpart()
213 /* return partition table */ in newpart()
240 * make sure that part-names with ":" will not be handled as in mtdpart_setup_real()
241 * part of the mtd-id with an ":" in mtdpart_setup_real()
250 * fetch <mtd-id>. We use strrchr to ignore all ':' that could in mtdpart_setup_real()
252 * as an <mtd-id>/<part-definition> separator. in mtdpart_setup_real()
265 pr_err("no mtd-id\n"); in mtdpart_setup_real()
266 return -EINVAL; in mtdpart_setup_real()
268 mtd_id_len = p - mtd_id; in mtdpart_setup_real()
274 * struct cmdline_mtd_partition and the mtd-id string. in mtdpart_setup_real()
282 sizeof(void*)-1 /*alignment*/); in mtdpart_setup_real()
298 this_mtd->parts = parts; in mtdpart_setup_real()
299 this_mtd->num_parts = num_parts; in mtdpart_setup_real()
300 this_mtd->mtd_id = (char*)(this_mtd + 1); in mtdpart_setup_real()
301 strlcpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1); in mtdpart_setup_real()
304 this_mtd->next = partitions; in mtdpart_setup_real()
305 partitions = this_mtd; in mtdpart_setup_real()
308 this_mtd->mtd_id, this_mtd->num_parts)); in mtdpart_setup_real()
311 /* EOS - we're done */ in mtdpart_setup_real()
318 return -EINVAL; in mtdpart_setup_real()
330 * information. It returns partitions for the requested mtd device, or
337 unsigned long long offset; in parse_cmdline_partitions() local
340 const char *mtd_id = master->name; in parse_cmdline_partitions()
350 * Search for the partition definition matching master->name. in parse_cmdline_partitions()
351 * If master->name is not set, stop at first partition definition. in parse_cmdline_partitions()
353 for (part = partitions; part; part = part->next) { in parse_cmdline_partitions()
354 if ((!mtd_id) || (!strcmp(part->mtd_id, mtd_id))) in parse_cmdline_partitions()
361 for (i = 0, offset = 0; i < part->num_parts; i++) { in parse_cmdline_partitions()
362 if (part->parts[i].offset == OFFSET_CONTINUOUS) in parse_cmdline_partitions()
363 part->parts[i].offset = offset; in parse_cmdline_partitions()
365 offset = part->parts[i].offset; in parse_cmdline_partitions()
367 if (part->parts[i].size == SIZE_REMAINING) in parse_cmdline_partitions()
368 part->parts[i].size = master->size - offset; in parse_cmdline_partitions()
370 if (offset + part->parts[i].size > master->size) { in parse_cmdline_partitions()
372 part->mtd_id); in parse_cmdline_partitions()
373 part->parts[i].size = master->size - offset; in parse_cmdline_partitions()
375 offset += part->parts[i].size; in parse_cmdline_partitions()
377 if (part->parts[i].size == 0) { in parse_cmdline_partitions()
379 part->mtd_id); in parse_cmdline_partitions()
380 part->num_parts--; in parse_cmdline_partitions()
381 memmove(&part->parts[i], &part->parts[i + 1], in parse_cmdline_partitions()
382 sizeof(*part->parts) * (part->num_parts - i)); in parse_cmdline_partitions()
383 i--; in parse_cmdline_partitions()
387 *pparts = kmemdup(part->parts, sizeof(*part->parts) * part->num_parts, in parse_cmdline_partitions()
390 return -ENOMEM; in parse_cmdline_partitions()
392 return part->num_parts; in parse_cmdline_partitions()
437 MODULE_DESCRIPTION("Command line configuration of MTD partitions");