History log of /freebsd-11.0-release/usr.bin/mkimg/mkimg.c
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


# 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.


# 279125 22-Feb-2015 marcel

Remove extraneous parenthesis in assignment.


# 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.


# 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


# 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


# 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@


# 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.


# 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.


# 263897 29-Mar-2014 marcel

Make this build on ia64 w/ gcc.


# 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.


# 263850 27-Mar-2014 marcel

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


# 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.


# 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


# 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.


# 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...


# 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.


# 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.


# 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.


# 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


# 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).