Skip to content

Commit 6ab44d5

Browse files
genimage: allow non-sparse image-less partitions not in partition table
Previously, partitions not included in a partition table were required to always reference an image. However, it can be useful to define such partitions without an image, for example, for "barebox-env" or "barebox-state" regions at fixed offsets in legacy MBR setups. These partitions are typically populated at runtime and therefore do not need an image. To ensure that flashing a sparse image variant results in a well-defined state, these partitions should be explicitly filled with zeros to overwrite any existing data. So allow partitions not present in the partition table, without an image, to be filled with zeros, e.g.: partition barebox-environment { size = 128K in-partition-table = false sparse = false } Signed-off-by: Bastian Krause <[email protected]>
1 parent ff7da92 commit 6ab44d5

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ Partition options:
130130
:sparse: If true (the default) 'holes' in the input images are preserved
131131
and the remaining free space in the partition is also a 'hole'.
132132
If false, the 'holes' in the input image are explicitly
133-
filled with zeros when the image is copied. If ``fill``
134-
is specified as well then the remaining free space is
133+
filled with zeros when the image is copied.
134+
If the partition has no image, the whole partition content is a
135+
'hole'.
136+
If ``fill`` is specified as well then the remaining free space is
135137
also filled with zeros.
136138
:autoresize: Boolean specifying that the partition should be resized
137139
automatically. For UBI volumes this means that the

genimage.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,11 @@ int main(int argc, char *argv[])
831831
struct image *child;
832832

833833
if (!part->image) {
834-
if (part->in_partition_table)
834+
/* allow image-less partitions that are present
835+
* in the partition table and partitions that
836+
* should be filled with zeros (sparse = false)
837+
*/
838+
if (part->in_partition_table || !part->sparse)
835839
continue;
836840
image_error(image, "no input file given\n");
837841
ret = -EINVAL;

0 commit comments

Comments
 (0)