Bug 253764 - mkimg does not allocate space for partitions when given an absolute offset
Summary: mkimg does not allocate space for partitions when given an absolute offset
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.4-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-22 14:58 UTC by Arrigo Marchiori
Modified: 2021-03-03 07:42 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arrigo Marchiori 2021-02-22 14:58:45 UTC
When mkimg(1) is asked to output a partition of a given size with a given absolute offset into a raw image, it does not size the output file properly.

When no offset is given, the file is sized correctly:
$ mkimg -f raw -o temp.img -s mbr -p freebsd::512000
creates a file that is 1001 blocks long.

Relative offsets work well:
$ mkimg -f raw -o temp.img -s mbr -p freebsd::512000:+512
creates a file that is 1002 blocks long.

But:
$ mkimg -f raw -o temp.img -s mbr -p freebsd::512000:512
creates a file that is only 1 block long, instead of 1001.

Looking at the code, in file mkimg.c the problem seems to be that the "block" variable is not updated with the partition size. But I could not understand the code well enough to propose a patch, unfortunately.

Additional info:

$ uname -a
FreeBSD myhost 11.4-STABLE FreeBSD 11.4-STABLE #1 r369279: Tue Feb 16 10:16:53 CET 2021     root@myhost:/usr/obj/usr/src/sys/GENERIC  amd64

$ svn info /usr/src/usr.bin/mkimg | grep Revision
Revision: 369279
Comment 1 Robert Wing freebsd_committer 2021-02-25 17:56:46 UTC
This was recently fixed (i.e., today) in commit by manu:

https://cgit.FreeBSD.org/src/commit/?id=3b6268bb9e4aea939c4ce7f37353174aa90e6751
Comment 2 Robert Wing freebsd_committer 2021-03-02 17:35:18 UTC
(In reply to Robert Wing from comment #1)

closed out by commit: 

https://cgit.freebsd.org/src/commit/?id=9c5f4f8e4ee8261a669ab99257bffd439bad6635
Comment 3 Arrigo Marchiori 2021-03-03 07:42:06 UTC
Thank you, Robert.

I see the commit was not merged into stable/11.
I trust this will happen soon.

Thank you and best regards.