History log of /freebsd-11.0-release/usr.bin/mkimg/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
303975 11-Aug-2016 gjb

Copy stable/11@r303970 to releng/11.0 as part of the 11.0-RELEASE
cycle.

Prune svn:mergeinfo from the new branch, and rename it to RC1.

Update __FreeBSD_version.

Use the quarterly branch for the default FreeBSD.conf pkg(8) repo and
the dvd1.iso packages population.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

302408 08-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


301999 17-Jun-2016 emaste

mkimg: bump version to 20151211 after r292082

mkimg has had a number of functional additions after the last time the
version was incremented. Do so now, to r292082's commit date, so that
users can determine what is supported.

Reviewed by: marcel
Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D6882


301090 01-Jun-2016 markj

mkimg: Indicate that input file pages are unlikely to be reused.

mkimg(1) uses a swap file to back input file chunks. When the output file
is being written out, blocks of the swap file are mapped and their contents
copied. This causes the backing VM pages to enter the active queue, and when
the output file is large relative to system memory (as is generally the
case), can result in a shortfall of inactive memory. This causes the
pagedaemon to aggressively scan the active queue and swap out process
memory in an attempt to meet the shortfall. Because mkimg's input files
are typically the intermediate result of some build process, there's no
need to push them all through the active queue. Use madvise(2) to indicate
that the backing pages may be reclaimed in preference to active pages. In
the case of the swap file, these pages will be freed as soon as mkimg
exits anyway.

When using mkimg on a desktop-class system with large amounts of dirty
process memory, this change substantially improves mkimg runtime and
reduces swap usage.

Reviewed by: marcel
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D6654


299094 04-May-2016 ngie

Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
namespacing is kept with FILES appropriately, and that this shouldn't need
to be repeated if the namespace changes -- only the definition of PACKAGE
needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
`tests`. In the event we get to the point where things can be split up
enough in the base system, it would make more sense to group the tests
with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division


298107 16-Apr-2016 gjb

Merge the projects/release-pkg branch to head.

This allows packaging the base system with pkg(8), including
but not limited to providing the ability to provide upstream
binary update possibilities for non-tier-1 architectures.

This merge is a requirement of the 11.0-RELEASE, and as such,
thank you to everyone that has tested the project branch.

Documentation in build(7) etc. is still somewhat sparse, but
updates to those parts will follow.

Sponsored by: The FreeBSD Foundation


298098 16-Apr-2016 gjb

Final pass through bogus svn:mergeinfo removal.

Note, paths part of 'contrib' were left alone for now.

Sponsored by: The FreeBSD Foundation


296587 09-Mar-2016 bdrewery

DIRDEPS_BUILD: Connect MK_TESTS.

Sponsored by: EMC / Isilon Storage Division


292082 11-Dec-2015 imp

Add ppcboot FAT type. Needed to create a bootable powerpc image.

Differential Review: https://reviews.freebsd.org/D4407


291563 01-Dec-2015 bdrewery

META MODE: Update dependencies with 'the-lot' and add missing directories.

This is not properly respecting WITHOUT or ARCH dependencies in target/.
Doing so requires a massive effort to rework targets/ to do so. A
better approach will be to either include the SUBDIR Makefiles directly
and map to DIRDEPS or just dynamically lookup the SUBDIR. These lose
the benefit of having a userland/lib, userland/libexec, etc, though and
results in a massive package. The current implementation of targets/ is
very unmaintainable.

Currently rescue/rescue and sys/modules are still not connected.

Sponsored by: EMC / Isilon Storage Division


290494 07-Nov-2015 bapt

Improve collation string and locales support

Merge collation support from Illumos and DragonflyBSD.

Locales are now generated with the new localedef(1) tool from CLDR POSIX files.
The generated files are now identified as "BSD 1.0" format.

The libc now only read "BSD 1.0" locales definitions, all other version will be
set to "C"
The localedef(1) tool has been imported from Illumos and modified to use tree(3)
instead of the CDDL avl(3)
A set of tool created by edwin@ and extended by marino@ for dragonfly has been
added to be able to generate locales and the Makefiles from the vanilla CLDR
unicode databases + a universal UTF-8 charmap (by marino@)
Update the locales to unicode v27
Given our regex(3) does not support multibyte (yet) it has been forced to always
use locale C
Remove now unused colldef(1) and mklocale(1)
Finish implementing the numeric BSD extension for ctypes
The number of supported locales has grown from 175 to 250 locales. Among the new
locales: 6 Arabic locales (AE EG JO MA QA SA), Different variations of spanish
locales.
Added new 3 components locales for mn_Cyrl_MN, sr_Cyrl_RS sr_Latn_RS,
zh_Hans_CN, zh_Hant_HK and zh_Hant_TW. Some aliases has been for 2 components
version when possible.

Thanks: Garrett D'Amore (Illumos) who made sure all his work was done under
BSD license!, Edwin Groothuis (edwin@) for the work he made on tools to be able
to generate locales definition usable in freebsd sources out of vanilla CLDR
definitions, John Marino (DragonflyBSD) who first merge the Illumos work into
Dragonfly and spent hours tracking down bugs.


290102 28-Oct-2015 bapt

Merge mpsutil(8) branch

mpsutil(8)/mprutil(8) are new utilities for managing LSI Fusion-MPT
2/3 controllers (mps(4) and mpr(4))

For now only informational commands have been implemented.

This utility has been written by scottl@ [1] and polished by myself[2]

Submitted by: scottl
Discussed with: scottl
Relnotes: yes
Sponsored by: Netflix [1]
Sponsored by: Gandi.net [2]


289677 21-Oct-2015 eadler

Fix a ton of speelling errors

arc lint is helpful

Reviewed By: allanjude, wblock, #manpages, chris@bsdjunk.com
Differential Revision: https://reviews.freebsd.org/D3337


289349 15-Oct-2015 emaste

mkimg: support fat16b partitions (MBR type 06h)

Reviewed by: marcel
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3894


289172 12-Oct-2015 ngie

Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and
netbsd-tests.test.mk (r289151)

- Eliminate explicit OBJTOP/SRCTOP setting
- Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk
- Remove unnecessary TESTSDIR setting
- Use SRCTOP where possible for clarity

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Divison


288943 06-Oct-2015 dim

Upgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.7.0
release.

Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.

Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.7.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.7.0/tools/clang/docs/ReleaseNotes.html>

Thanks to Ed Maste, Andrew Turner and Antoine Brodin for their help.

Exp-run: antoine
Relnotes: yes


286660 12-Aug-2015 brueffer

Fix a few mandoc warnings.

MFC after: 1 week


286419 07-Aug-2015 marcel

Fix typo introduced in previous commit.

Pointed out by: Nikolai Lifanov <lifanov at mail.lifanov.com>


286417 07-Aug-2015 marcel

o Fix a typo.
o Describe the file formats mkimg can create.


286398 07-Aug-2015 marcel

Rebase after r286395: rounding fix for dynamic VHD


286395 07-Aug-2015 marcel

Fix the dynamic VHD format to work with qemu. The size of the disk
is taken to match the geometry and only when the geometry is max'd
out, is the actual recorded size taken.

Note that qemu has the same logic for the fixed VHD format. However
that is known to conflict with Microsoft Azure, where the recorded
size of the image is what counts.

Pointed out by: gjb@


286215 03-Aug-2015 marcel

Make image_copyout_zeroes() an interface function.


284883 27-Jun-2015 marcel

Add the ntfs alias and support it with the MBR and GPT schemes
as DOSPTYP_NTFS and GPT_ENT_TYPE_MS_BASIC_DATA (resp).


284659 21-Jun-2015 marcel

Rebase after r284658:
1. Change creator OS to "wi2k"
2. Bump tool version to 2.0


284658 21-Jun-2015 marcel

Microsoft Azure expects the creator OS to be "Wi2k" and not "FBSD".
The image is not accepted for provisioning otherwise. Bump the
VHD creator tool version and the version of mkimg to signify our
success in provisioning.

Note that this also imapcts the dynamic VHD images.

Tested by: gjb@


284657 21-Jun-2015 marcel

Rebase the fixed VHD images after the rounding fix.


284656 21-Jun-2015 marcel

Microsoft Azure demands that fixed VHD images are a whole number
of megabytes. This is on top of having the image rounded to the
matching geometry of the image size.
By rounding up to the next MB after rounding to the geometry, we
lost idempotency. Subsequent calls to resize the image will keep
increasing the image size.

Tested by: gjb@


284655 21-Jun-2015 marcel

Don't resize again prior to writing. Resizing may not be idempotent
and no scheme adjusts the size after the format resized the image
the first time.


284271 11-Jun-2015 marcel

Update tests after sizing changes to the fixed VHD format.


284270 11-Jun-2015 marcel

Handle the case in which ncyls is 0.
While here, update copyright.


284269 11-Jun-2015 marcel

For the fixed VHD format, round the raw image size to the next
multiple of the cylinder size. This is what qemu-img seems to
be doing. Make sure to handle boundary cases where increasing
the image size by 1 cyclinder's worth would also result in a
change of geometry.


280031 15-Mar-2015 dim

Upgrade our copy of clang, llvm and lldb to 3.6.0 release.

Please note that from 3.5.0 onwards, clang/llvm/lldb require C++11
support to build; see UPDATING for more information.

Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.6.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.6.0/tools/clang/docs/ReleaseNotes.html>

Thanks to Ed Maste for the lldb part of this upgrade.

Exp-run: antoine


279139 22-Feb-2015 marcel

Add the -c option for specifying the capacity of the disk image. When
a capcity is given, no partitions are required. When no partitions are
given, no scheme needs to be specified either. This makes it possible
to create an entirely empty disk image. To add an empty partitioning
table, specify the scheme.

Bump the version to 20150222.


279128 22-Feb-2015 marcel

Don't require a scheme if no partitions are given. Change the code
to handle that case. Note that we still require partitions, so the
change is effectively a no-op.


279126 22-Feb-2015 marcel

In scheme_write(), don't overwrite the end parameter with the
return value of image_get_size(). As it so happens, the only
caller of scheme_write() passes exactly that.


279125 22-Feb-2015 marcel

Remove extraneous parenthesis in assignment.


276893 09-Jan-2015 emaste

mkimg: Add MBR EFI partition type

Sponsored by: The FreeBSD Foundation


276479 31-Dec-2014 dim

Upgrade our copy of clang, llvm and lldb to 3.5.0 release.

Please note that this version now requires C++11 support to build; see
UPDATING for more information.

Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.5.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.5.0/tools/clang/docs/ReleaseNotes.html>

Thanks to Ed Maste, Roman Divacky, Andrew Turner, Justin Hibbits and
Antoine Brodin for their invaluable help with this import.

Approved by: portmgr (antoine)
MFC after: 1 month


275721 12-Dec-2014 marcel

The size of the first level reference count table is given in terms of the
number of clusters it occupies. It's not the number of entries in the table,
as it is for the L1 cluster table.

For small images, the two are the same. With the unit tests based on small
images, this change has therefore no effect on the unit test. For larger
images (like the FreeBSD 10.1-RELEASE image), this gives a discrepancy that
actually shows up when running "qemu-img check".

Bump the version number of mkimg.

While here, fix a white-space bug.

MFC after: 1 week


275042 25-Nov-2014 bapt

Convert to usr.bin/ to LIBADD
Reduce overlinking


274495 14-Nov-2014 trasz

Add missing commas to .Xr.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation


274410 12-Nov-2014 marcel

SEEK_DATA has interesting behaviour for sparse files on ZFS. A sparse file
with 128K of random data and truncated to 800K can have SEEK_DATA return -1
when given an offset of 128K. On UFS, the SEEK_DATA returns 800K (the size
of the file). SEEK_HOLE on ZFS seems to behave the same as UFS.

To handle this, map -1 to the size of the file (`end') when lseek returns
this for either SEEK_HOLE or SEEK_DATA. When sparse files are not supported
by the file system both `hole' and `data' will now be equal to `end' and we
will treat the entire file as data. This way, the -1 return for SEEK_DATA
on ZFS will end up doing the right thing.

Reported by: gjb@

MFC after: 3 days


272486 03-Oct-2014 marcel

Update baseline files for EBR, MBR and PC98 now that mkimg fills in
the CHS fields appropriately when -T and -H are given on the command
line.


272485 03-Oct-2014 marcel

Add mkimg_chs() for those schemes that need the LBA broken down into
cylinder, head and track numbers. Return ~0U for these values when
mkimg wasn't given both -T and -H (i.e. no geometry) or the cylinder
would be larger than the provided maximum.

Use mkimgs_chs() for the EBR, MBR and PC98 schemes to fill in the
appropriate fields. Make sure to use a "rounded" size so that the
partition is always a multiple of the track size. We reserved the
room for it in the metadata callback so that's a valid thing to
do.

Bump the mkimg version number.
While doing that again: have mkimg.o depend on the Makefile so that
a version change triggers a rebuild as needed.


272384 01-Oct-2014 marcel

Improve performance of mking(1) by keeping a list of "chunks" in memory,
that keeps track of a particular region of the image. In particular the
image_data() function needs to return to the caller whether a region
contains data or is all zeroes. This required reading the region from
the temporary file and comparing the bytes. When image_data() is used
multiple times for the same region, this will get painful fast.

With a chunk describing a region of the image, we now also have a way
to refer to the image provided on the command line. This means we don't
need to copy the image into a temporary file. We just keep track of the
file descriptor and offset within the source file on a per-chunk basis.

For streams (pipes, sockets, fifos, etc) we now use the temporary file
as a swap file. We read from the input file and create a chunk of type
"zeroes" for each sequence of zeroes that's a multiple of the sector
size. Otherwise, we allocte from the swap file, mmap(2) it, read into
the mmap(2)'d memory and create a chunk representing data.

For regular files, we use SEEK_HOLE and SEEK_DATA to handle sparse files
eficiently and create a chunk of type zeroes for holes and a chunk of
type data for data regions. For data regions, we still compare the bytes
we read to handle differences between a file system's block size and our
sector size.

After reading all files, image_write() is used by schemes to scribble in
the reserved sectors. Since this never amounts to much, keep this data
in memory in chunks of exactly 1 sector.

The output image is created by looking using the chunk list to find the
data and write it out to the output file. For chunks of type "zeroes"
we prefer to seek, but fall back to writing zeroes to handle pipes.
For chunks of type "file" and "memoty" we simply write.

The net effect of this is that for reasonably large images the execution
time drops from 1-2 minutes to 10-20 seconds. A typical speedup is about
5 to 8 times, depending on partition sizes, output format whether in
input files are sparse or not.

Bump version to 20141001.


272382 01-Oct-2014 marcel

Suffix the cookie constants with ULL to silence warnings from compilers
that try to treat them as 32-bit values.


272217 27-Sep-2014 marcel

Update the usage message and the man page to account for the new long
options. Bump the version number to 20140927.
While here, use explicit fputc() calls to skip a line in the output.
This to avoid having to hunt for extra '\n' characters in the printf
format strings.

MFC after: 1 week
Relnotes: yes


272198 27-Sep-2014 marcel

Add 3 long options for getting information about mkimg itself:
--version print the version of mkimg and also whether it's
64- or 32-bit.
--formats list the supported output formats separated by space.
--schemes list the supported partitioning schemes separated by
space.

Inspired by a patch from: gjb@

MFC after: 1 week
Relnotes: yes


272088 24-Sep-2014 marcel

Add baseline files for QCOW2.


272086 24-Sep-2014 marcel

Finish QCOW version 2 and stop making it conditional.

We have a different ordering for the RC block(s) and L2 tables.
This is expected to be a non-issue, because everything is found
through file offsets in the corresponding RC table and L1 table.
Files that grow organically have RC blocks and L2 tables scattered
all over the place anyway.

The reason for the difference is that mkimg needs to be able to
write to a pipe. We can't seek forward and backward to fill in
the bits in non-sequential order.


272073 24-Sep-2014 marcel

Update the baseline for QCOW version 1. A bug was found that rendered
the baseline invalid.


272072 24-Sep-2014 marcel

Fix the creation of the L2 cluster table for version 1. The blkofs
variable was assigned the image offset in bytes and not in blocks
(i.e. sectors). This had image_data() return FALSE, which meant that
we didn't assign a cluster when we needed and also meant that we
didn't write parts of the L2 table when we should have. The result
being that the actual data clusters were written at the wrong offset.

Improve support for QCOW version 2. We're having the right layout
and even know how many refcnt blocks we need. All we need to do is
populate the refcnt blocks for every cluster we write and allocate
a cluster when we need a new refcnt block. The allocation part is
tricky in that it'll interleave with the assignment of clusters to
L2 tables and data. Since version 2 is not quite done, keep it
compiled out for now.


272054 24-Sep-2014 marcel

Clean the generated baseline files by adding them to CLEANFILES.


271981 22-Sep-2014 marcel

Rename the tests to something more meaningful. I spent way too long
trying to get the test name right, failed, gave up and used a sequence
number instead. When I realized it wasn't because of the number of
underscores in the name that I really started to think. I didn't have
braces around the variable names ...

Thus: test_1 is now called apm_1x1_512_qcow, which gives you all you
need to run mkimg by hand.

Dumb-ass: marcel


271979 22-Sep-2014 marcel

Don't update the baseline file when the result of the test is identical
to the baseline. Since we don't run gzip with the -n option, the output
of gzip varies for identical result files if and when they are created
at different time. Ouch...

Rather than add -n and commit a 600K+ diff for the changes to all the .uu
files, it's less of a churn to uudecode and gunzip the baseline file and
compare that to the new result file to determine if the baseline file
needs to be updated.

This way, "atf-sh mkimg.sh rebase" can be run as many times as people like
and a subsequent "svn status" will not show unnecessary diffs.


271968 22-Sep-2014 marcel

Don't echo '# $FreeBSD$' as the first line into the .uu file. Keyword
substitution applies to this file, including the echo command. Avoid
the match (and substitution) by breaking the string up into 3 parts.


271966 22-Sep-2014 marcel

Update the unit tests to include the QCOW (version 1) format.
This is a good safety net for when V2 is added.


271965 22-Sep-2014 marcel

Add support for QCOW version 1. Version 2 is partially implemented.
And because of that, it's entirely disabled for now. Both versions
are similar enough that a single header definition works for both
of them. The only "diverting" side-effect is that the union of the
two is larger than the official V1 header.

What this means for our V1 support is that we can't put the L1 table
adjacent to the V1 header (i.e. at offset 0x30 in the file), unless
we revert to hackery and klugery. Let's not. Instead, we align the L1
table at the cluster boundary. This is in line with the V2 layout and
perfectly ok for V1 anyway (ok -- as far as I've seen so far).
Due to the alignment, our V1 image seems to be 1 cluster larger than
the V1 image created by qemu-img (on average).

Compression of the clusters is not supported at this time.

MFC after: 2 months


271911 20-Sep-2014 marcel

Add unit tests for mkimg(1):


271881 19-Sep-2014 marcel

Fix partition alignment and image rounding when any of -P (block size),
-T (track size) or -H (number of heads) is given:
o scheme_metadata() always rounded to the block size. This is not
always valid (e.g. vtoc8 that must have partitions start at cylinder
boundaries).
o The bsd and vtoc8 schemes "resized" the image to make it match the
geometry, but since the geometry is an approximation and the size
of the image computed from cylinders * heads * sectors is always
smaller than the original image size, the partition information ran
out of bounds.

The fix is to have scheme_metadata() simply pass it's arguments to the
per-scheme metadata callback, so that schemes not only know where the
metadata is to go, but also what the current block address is. It's now
up to the per-scheme callback to reserve room for metadata and to make
sure alignment and rounding is applied.

The BSD scheme now has the most elaborate alignment and rounding. Just
to make the point: partitions are aligned on block boundaries, but the
image is rounded to the next cyclinder boundary.

vtoc8 now properly has all partitions aligned (and rounded) to the
cyclinder boundary.

Obtained from: Juniper Networks, Inc.
MFC after: 3 days


271482 12-Sep-2014 marcel

Add support for adding empty partition entries. I.e. skip partition
numbers or names. This gives more control over the actual layout and
helps to construct BSD disklabels with /usr or /var at dedicated
partitions.

Obtained from: Juniper Networks, Inc.
MFC after: 3 days
Relnotes: yes


271449 12-Sep-2014 marcel

Be compatible with boot code that starts right after the disk label in
the second sector by only clearing the amount of bytes needed for the
disklabel in the second sector. Previously we were clearing exactly 1
sector worth of bytes and as such writing over boot code that may have
been there.
Since we do support more than 8 partitions, make sure to set all fields
in d_partitions. For the first 8 partitions this is unneeded, but for
partitioons 9 and up this compensates for the fact that we don't clear
an entire sector anymore.
Obviously, one cannot use more than 8 partitions when using boot code
that starts right after the disk label.

Relevant GRNs:
107879 - Employ unused bytes after the disklabel in the second sector.
189500 - Revert the part of change 107879 that employs the unused bytes
after the disklabel in the 2nd sector for boot code.

Obtained from: Juniper Networks, Inc.
MFC after: 3 days


271448 12-Sep-2014 marcel

Fix checksum calculation:
1. Iterate over all partitions counted in the label, which can be more
than the number of partitions given to mkimg(1).
2. Start the checksum from the beginning of the label; not the beginning
of the bootarea.

Tested with bsdlabel(8).

MFC after: 3 days


269745 09-Aug-2014 marcel

Create a redundant grain directory and table. Previously we were
cheating by assigning the same sector offset to both directories,
but it seems that VirtualBox doesn't like that. Neither does
qemu from the looks of it. We now actually write the directory
and table twice.

MFC after: 3 days


269021 23-Jul-2014 marcel

Fix builds on older FreeBSD versions and/or non-FreeBSD machines:
don't use _Static_assert unconditionally.


268802 17-Jul-2014 marcel

Add support for the fixed image type. The fixed image is effectively
a raw image with a VHD footer appended. There's little value that I
can see to use the fixed image type, but in order to make VHD images
for use by Microsoft's Azure platform, they must be fixed VHD images.

Support has been added by refactoring the code to re-use common code
and by adding a second output format structure. To created fixed VHD
images, specify "vhdf" as the output format.


268727 15-Jul-2014 delphij

Add a bandaid to fix GCC build (on sparc64 et al).


268646 15-Jul-2014 marcel

Add image_data() for checking whether a sequence of blocks has data.
Use this for VHD and VMDK to avoid allocating space in the image
for empty sectors.

Note that this negatively affects performance because mkimg uses a
temporary file for the intermediate storage. When mkimg has better
internal book keeping, performance can be significantly improved.


268524 11-Jul-2014 marcel

Make this compile on older FreeBSD versions that don't have
APM_ENT_TYPE_APPLE_BOOT.


268264 04-Jul-2014 marcel

Document the -y option as a unit test option.
Add missing -v (and -y) to the usage message.

Requested by: eadler@


268236 03-Jul-2014 marcel

Add VHD support to mkimg(1). VHD is used by Xen and Microsoft's Hyper-V
among others.

Add an undocumented option for unit testing (-y). When given, the image
will have UUIDs and timestamps synthesized in a way that gives identical
results across runs. As such, UUIDs stop being unique, globally or
otherwise.

VHD support requested by: gjb@


268159 02-Jul-2014 marcel

Add a ful stop after FreeBSD's version in the history section.

Pointed out by: brueffer@ (thanks!)


268134 02-Jul-2014 marcel

Prepare for merging to stable/10: update the history section.


267182 06-Jun-2014 joel

Minor mdoc improvements.


266556 22-May-2014 marcel

Create our temporary file in $TMPDIR, if the environment variable
is set. /tmp otherwise.

Submitted by: Dan McGregor <danismostlikely@gmail.com>


266514 21-May-2014 marcel

Fix CID 1204379 (vtoc8.c) & CID 1204380 (bsd.c): Cast ncyls to lba_t
before multiplying the 32-bit integrals to avoid any possibility of
truncation before widening. Not a likely scenario to begin with...


266513 21-May-2014 marcel

Fix CID 1204394: Use strncpy(3) instead of strcpy(3). Note that it's
ok to not have the name and type strings terminated.


266512 21-May-2014 marcel

Fix CID 1215124: Handle errors properly.


266511 21-May-2014 marcel

Fix CID 1215125: fstat(2) returns -1 on error and sets errno. It does
not return the error (oops).


266510 21-May-2014 marcel

Fix CID 1215128: Free the allocated buf when image_set_size()
returns and error and we return from bsd_write().


266509 21-May-2014 marcel

Fix CID 1215129: move the call to lseek(2) before the call to malloc(3)
so that the error path (taken due to lseek(2) failing) isn't leaking
memory.


266176 15-May-2014 marcel

MFuser/marcel/mkimg:
Add support for different output formats:
1. The output file that was previously written is now called the raw format.
2. Add the vmdk output format to create VMDK images.

When the format is not given, the raw output format is assumed.


265468 06-May-2014 marcel

Add mkimg_write() which combines lseek(2) and write(2) and uses
sector granularity for both offset and length. Have all schemes
use mkimg_write() instead of mkimg_seek() followed by write(2).

Now that schemes don't use lseek(2) nor write(2) directly, it's
easier to support output formats other than raw disks.


265467 06-May-2014 marcel

Add missing svn:keywords property.


265462 06-May-2014 marcel

In apm_write(), both fd and imgsz are referenced, so don't mark the
arguments as unused.


265170 01-May-2014 nwhitehorn

Add freebsd-boot to recognized partition types.


263926 29-Mar-2014 marcel

Fix build on FreeBSD 7 where:
1. DOSPTYP_FAT32 is not defined in <sys/diskmbr.h>
2. uuid_enc_le() does not exist in libc.


263924 29-Mar-2014 marcel

Fix build on FreeBSD 8 where partition types for nandfs do not exist.


263923 29-Mar-2014 marcel

Fix build on FreeBSD 9 where <sys/pc98.h> has the same defines as
<sys/diskmbr.h> and not the unique defines introduced later.


263918 29-Mar-2014 marcel

Add mkimg, a utility for making disk images from raw partition contents.
The partitioning scheme can be one of the schemes supported by gpart.

Reviewed by: sjg
Obtained from: Juniper Networks, Inc.


263898 29-Mar-2014 marcel

Build this on sparc64, where we don't have LABELSECTOR nor LABELOFFSET
defined. Improve portability by eliminating their use.


263897 29-Mar-2014 marcel

Make this build on ia64 w/ gcc.


263896 29-Mar-2014 marcel

Fix build on i386 w/ clang.


263895 29-Mar-2014 marcel

Add a paragraph about running mkimg without arguments to get a list
of supported schemes and/or a detailed description of how to specify
partitions.


263894 29-Mar-2014 marcel

Document how labels can be given to partitions.


263893 29-Mar-2014 marcel

Handle the raw partition of the BSD and VTOC schemes.


263867 28-Mar-2014 marcel

Make mkimg a general command and not a maintenance command.


263866 28-Mar-2014 marcel

Define SPARSE_WRITE to enable writing sparse files. Output compares ok...


263865 28-Mar-2014 marcel

Flesh-out manpage.


263864 28-Mar-2014 marcel

Use :- and not :! for pipes. ! needs to be escaped, which adds to the
hassle.


263862 28-Mar-2014 marcel

Write verbosity to stderr. The image may be written to stdout.
While here, fix writing to stderr, by not calling errc()
unconditionally, but only when there's an error.


263857 28-Mar-2014 marcel

Write sparse files by default (when SPARSE_FILE is defined).
While here, detect errors when writing to stdout.


263856 28-Mar-2014 marcel

Partitions start on cylinder boundaries.


263855 28-Mar-2014 marcel

Partitions start on track boundaries.


263854 28-Mar-2014 marcel

Partitions start on track boundaries.


263850 27-Mar-2014 marcel

Remove the -z flag. Let's just write a sparse file whenever we can.


263849 27-Mar-2014 marcel

Properly fill in d_nsectors, d_ntracks, d_ncylinders & d_secpercyl.
Round the image size to a multiple of the cyclinder size.


263848 27-Mar-2014 marcel

Remember operator precedence?


263845 27-Mar-2014 marcel

Give vtoc8 a change to work: when setting the physical block size to 4K,
sectors/track to 8 and number or heads to 1, partitions that are block
aligned are also cyclinder aligned. With that trick, fix the vtoc8:
1. Set physcyls, ncyls, altcyls, nheads and nsecs appropriately.
2. Truncate the image size to exactly ncyls * nheads * nsecs * secsz.
3. Properly write the cylinder number as the start of the partition.
4. Oh, and actually calculate the checksum of the label...


263844 27-Mar-2014 marcel

1. When calculating block addresses, round to the physical block
size.
2. Replace scheme_first_block() & scheme_next_block() with
scheme_metadata(). When we round to block sizes, we can't
reliably fixup any miscalculations.
3. In scheme_write, calculate ncyls (number of cyclinders), based
on the total size, sectors/track and number of heads.
4. Add verbosity when constructing the partitions. This includes
the starting block address and size in bytes and blocks.
5. Add verbosity about the sectors/track and number of heads.


263843 27-Mar-2014 marcel

Remove trksz, which was hardcoded to 1, and replace it by secs, which
can be set on the command line.


263841 27-Mar-2014 marcel

Fix writing the start and size fields.


263831 27-Mar-2014 marcel

1. Add -v option to increase vebosity levels
2. Fix copy-paste bug -- acrually check secsz for being a power of 2
3. Check secsz and blksz parameters
4. Print the sector and block size when -v is given


263829 27-Mar-2014 marcel

Add scheme_max_secsz() for returning the maximum sector size supported
by the partitioning scheme.


263709 25-Mar-2014 marcel

First batch of media control:
1. Change -h to -H and change -t to -T. Use -H to specify the number of
heads and -T to specify the track size (number of sectors per track).
2. Add -S and -P. Use -S to specify the logical sector size and -P to
specify the physical sector size.

Default to 512 for both the logical and physical sector size.
Set nheads and nsecs to 1 by default.


263706 25-Mar-2014 marcel

Move setting CHS fields to mbr_chs() in preparation of ...


263700 25-Mar-2014 marcel

Allow schemes to specify a maximum sector size. The minimum is fixed
at 512. This allows checking of the sector size up-front when given
on the command line.


263699 25-Mar-2014 marcel

Mostly implement the vtoc8 scheme. The vtoc8 scheme uses cylinders for
the beginning of partitions, which makes it sensitive to geometry.
Again, we'll need to revisit this.


263697 25-Mar-2014 marcel

Mostly implement the pc98 scheme. The partition table has no LBA
fields at all, so we're entirely dependent upon CHS addressing.
And CHS addressing is what needs more work.


263674 23-Mar-2014 marcel

Implement the EBR scheme. Use a function for filling in the CHS fields.
For now, put 0xff in each field. This needs to be revisited when we
have proper geometry. Note that even without proper CHS values, it's
already accepted by the kernel.


263673 23-Mar-2014 marcel

Add support for the fat32 and ebr aliases.


263672 23-Mar-2014 marcel

Add the fat32 and ebr aliases. The ebr alias is needed to support
the EBR scheme, as it can only live inside a MBR partition of type
5 (= DOSPTYP_EXT).


263669 23-Mar-2014 marcel

Implement the BSD scheme. This doesn't quite work as geom_part_bsd
finds an invalid label. I'm not going to worry about that right now,
because there's more to worry about: the BSD disk label has the 'c'
partition for the entire disk and we don't handle this at all.
Note also that the BSD disk label wants a geometry, so this will
have to be revisited anyway once a good solution is in place.


263656 23-Mar-2014 marcel

Implement the APM scheme.


263654 23-Mar-2014 marcel

And the magic number is... necessary.


263653 23-Mar-2014 marcel

Revamp:
1. Make secsz globally visible.
2. Have all code use the global secsz and nparts, rather than passing
them around.
3. Introduce lba_t as the type to use when talking about block addresses.
4. Work on LBAs instead of offsets. There's just too much division with
the sector size and there's really no value to use by offsets other
than that is what lseek() wants. For that we now have mkimg_seek().

The bigger picture is that geometry (cylinders, heads, sectors/track) and
also a possible physical sector size are to be globals that can be used
from anyway. We really don't want to pass all that stuff as arguments to
functions and then add __unused for most of them...


263652 22-Mar-2014 marcel

Flesh-out MBR support. The CHS fields need more thought/work...


263537 21-Mar-2014 marcel

Handle the -b option for specifying boot code that lives in the
partitioning scheme's meta data. Implement it for GPT.


263487 21-Mar-2014 marcel

Add more partition types (mostly just the FreeBSD ones) to GPT.
Avoid having schemes use literal strings by introducing an enum
as the intermediate representation (see geom_part).


263467 21-Mar-2014 marcel

Update usage for label support.


263466 21-Mar-2014 marcel

Add support for partition labels and write them for GPT.


263465 21-Mar-2014 marcel

Make this work on big-endian architectures by adding encoding.


263462 21-Mar-2014 marcel

Fix writing GPT:
1. Fix copy-paste bug that resulted in not sizing the image correctly
for the secondary header and table.
2. The hdr_lba_end field in the header is the LBA of the last usable
sector, not the one after it.

While here, fix a white-space nit.


263461 21-Mar-2014 marcel

Dump my WIP of write support for GPT. This compiles, appears to be
complete, but isn't accepted by g_part_gpt. Time to debug and fix.


263442 20-Mar-2014 marcel

Add a scheme-specific write callback to write the metadata.
While here:
1. Move FreeBSD-specific headers to a more centralized place, so that
it's easier to port mkimg.
2. Remove inclusion of <uuid.h> where we don't need it (copy-pasted).
3. Check the partition data given on the command line before we do any
I/O.
4. Add scheme_round() for rounding the partition size.
5. Have scheme_write call the scheme-specific write callback and have
it propagate errors back to the caller.


263440 20-Mar-2014 marcel

Replace *_get_leader() and *_get_trailer() with a single *_metadata().
This single function takes a where argument to indicate the kind of
metadata to "size". This way we can also get rid of the "padding"
field in the scheme structure.
This should make it a little more understandable what's going on.


263414 20-Mar-2014 marcel

Check the partition type alias as defined by the scheme.


263409 20-Mar-2014 marcel

Use linker sets to provide build-time selection of the schemes
that need to be supported. Each scheme provides data and callbacks
for handling the scheme-specifics.
To this end, put each scheme in its own source file.


263383 19-Mar-2014 marcel

Expand usage(). This serves even now as a good reminder.


263382 19-Mar-2014 marcel

Add mkimg.h. It contains the 'part' structure definition and the linked
list (STAILQ) so that it can be shared and re-used in all source files.
Replace the now unneeded scheme_add_part() with scheme_check_part() for
posterity.

Also (should have been a separate commit), remove the enforcement of
creating a GPT table with at least 128 entries. While this is generally
advised as the default or minimum, it's not actually a hard requirement.
We now recreate a table that's precisely enough (rounded of course).

WHile


263381 19-Mar-2014 marcel

Set BINDIR & WARNS while we're outside the source tree.


254156 09-Aug-2013 marcel

Now that we can include <sys/diskpc98.h> and <sys/diskmbr.h> at
the same time withiut conflict, use the constants defined in them.


253923 04-Aug-2013 marcel

Safe WIP: mkimg is a user-space utility for creating disk images.
In its current form and shape, it creates images with the correct
partition contents and overall image layout. What it doesn't do
yet is actually scribble the metadata, such as partition tables
and boot code. This is where I'd like to leverage code from other
places, such as geom_part, and if possible/feasible.
Also, the utility should be a little bit smarter about files and
pipes so that we create temporary files only when needed (e.g.
when we don't know the size of a partition's contents in advance
while wrting the image to stdout).