Commit Graph

9 Commits

Author SHA1 Message Date
Marcel Moolenaar
53fcdb2d1a 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
2014-09-19 23:16:02 +00:00
Marcel Moolenaar
5d4393ed1f Make this compile on older FreeBSD versions that don't have
APM_ENT_TYPE_APPLE_BOOT.
2014-07-11 01:49:25 +00:00
Marcel Moolenaar
adc991ea42 Fix CID 1204394: Use strncpy(3) instead of strcpy(3). Note that it's
ok to not have the name and type strings terminated.
2014-05-21 17:38:56 +00:00
Marcel Moolenaar
f0e9dced5c 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.
2014-05-15 19:19:57 +00:00
Marcel Moolenaar
789a10b106 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.
2014-05-06 21:54:05 +00:00
Marcel Moolenaar
c562fda42a In apm_write(), both fd and imgsz are referenced, so don't mark the
arguments as unused.
2014-05-06 20:34:21 +00:00
Nathan Whitehorn
2cbc36ab59 Add freebsd-boot to recognized partition types. 2014-05-01 03:24:20 +00:00
Marcel Moolenaar
f529e2e0a5 Fix build on FreeBSD 8 where partition types for nandfs do not exist. 2014-03-29 22:10:54 +00:00
Marcel Moolenaar
a5eb4ea3ee 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.
2014-03-29 19:03:10 +00:00