Repository navigation
Conversation
|
+1 for this. The patch works great for me (packs a vfat image from |
|
Hi @michaelolbrich Do you think this will be accepted? One particular build configuration we have packs a vfat boot disk from a mountpoint which can vary in size, but we only ever need it to be 100%. It would be great if this patch could be integrated into genimage. |
michaelolbrich
left a comment
There was a problem hiding this comment.
Could be simpler, and please rebase while at it.
michaelolbrich
left a comment
There was a problem hiding this comment.
Sorry for the late review. Some minor stuff, and please rebase instead of merging master into your branch.
| unsigned long long alignment = 1024ULL * 1024ULL; // align to the next MiB | ||
| unsigned long long size = image_mountpath_size(image) + image_file_size(image); | ||
| size = size * image->size / 100ULL; | ||
| image->size = ((size + alignment) / alignment) * alignment; |
There was a problem hiding this comment.
Please don't add an unconditional 1M alignment. That changes existing users.
4k should be save because that is probably what filesystems will do anyway. That should fix the failing test.
Anything else needs some kind of new option. I'm not sure what though. I think it would be nice to propagate the partition alignment back to the image, but that would change the size after setup is called for the image and that is not a good idea.
There was a problem hiding this comment.
The idea behind the image alignment was to avoid warnings from partitioning tools later. Since this can be handled with the partition.align option, such a feature might not be needed ...
| strerror(errno)); | ||
| return ret; | ||
| } | ||
| unsigned long long size = s.st_size; |
There was a problem hiding this comment.
The variable should be declared at the beginning of the function.
| mountpoint or by specifying file{} or files{} options, | ||
| '%' can be used as a suffix to indicate a percentage. | ||
| '200%' means the resulting filesystem should be about | ||
| 50% filled. Due to rounding, this value will not be exact. |
There was a problem hiding this comment.
Please don't reformat the existing test. That makes it hard to see what actually changed.
| if (image->empty) | ||
| return 0; | ||
| return dir_size(image, AT_FDCWD, mountpath(image), 4096); | ||
| const char *mnt = mountpath(image); |
There was a problem hiding this comment.
Again, move the variable declaration to the top.
There was a problem hiding this comment.
Also fixed. New version was pushed.
Commit 8d9c1a2 ("genimage: allow percentages for image sizes") introduced the option to specity image sizes as a percentage of the initial data. Size estimation for this option is based on the root path only, which makes this feature unusable for partitions populated mainly by files. Add calculation of file size to the size estimation before applying the percentage. Fixes: : pengutronix#227 ("Image size in % does not work") Signed-off-by: Andreas Ziegler <15275159+aeolio@users.noreply.github.com>
Commit 8d9c1a2 ("genimage: allow percentages for image sizes") introduced the option to specity image sizes as a percentage of the initial data. Size estimation for this option is based on the root path only, which makes this feature unusable for partitions populated mainly by files.
Add calculation of file size to the size estimation before applying the percentage.
Fixes: : #227 ("Image size in % does not work")