image-hd: allow partitions that are not listed in the partition table

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Michael Olbrich 2011-10-10 16:38:22 +02:00 committed by Sascha Hauer
parent fa915c7d19
commit 38eb8cf230
3 changed files with 8 additions and 2 deletions

View File

@ -83,6 +83,7 @@ static cfg_opt_t partition_opts[] = {
CFG_INT("partition-type", 0, CFGF_NONE),
CFG_STR("image", NULL, CFGF_NONE),
CFG_BOOL("autoresize", 0, CFGF_NONE),
CFG_BOOL("in-partition-table", cfg_true, CFGF_NONE),
CFG_END()
};
@ -230,6 +231,7 @@ static int parse_partitions(struct image *image, cfg_t *imagesec)
part->partition_type = cfg_getint(partsec, "partition-type");
part->image = cfg_getstr(partsec, "image");
part->autoresize = cfg_getbool(partsec, "autoresize");
part->in_partition_table = cfg_getbool(partsec, "in-partition-table");
}
return 0;

View File

@ -32,6 +32,7 @@ struct partition {
const char *image;
struct list_head list;
int autoresize;
int in_partition_table;
const char *name;
};

View File

@ -64,6 +64,9 @@ static int hdimage_setup_mbr(struct image *image, char *part_table)
list_for_each_entry(part, &image->partitions, list) {
struct partition_entry *entry;
if (!part->in_partition_table)
continue;
if (i > 3) {
image_error(image, "cannot handle more than 4 partitions");
return -EINVAL;
@ -162,13 +165,13 @@ static int hdimage_setup(struct image *image, cfg_t *cfg)
part->name, part->size);
return -EINVAL;
}
if (part->offset % align) {
if (part->in_partition_table && (part->offset % align)) {
image_error(image, "part %s offset (%lld) must be a"
"multiple of %lld bytes\n",
part->name, part->offset, align);
return -EINVAL;
}
if (part->offset) {
if (part->offset || !part->in_partition_table) {
if (now > part->offset) {
image_error(image, "part %s overlaps with previous partition\n",
part->name);