Commit Graph

14 Commits

Author SHA1 Message Date
marcel
24cdcc8e3f Switch to the image API:
1.  Replace calls to mkimg_set_size() with calls to image_set_size()
2.  Remove the mkimg_set_size() function
3.  As above but for mkimg_write() and image_write()

Note that this breaks mkimg(1). The image API has no implementation.
Hence doing it on my branch :-)
2014-05-07 17:33:31 +00:00
marcel
e22d96c863 Merge ^/head/usr.bin/mkimg@265546 2014-05-07 14:20:58 +00:00
marcel
f017f60135 Make this build on ia64 w/ gcc. 2014-03-29 03:55:58 +00:00
marcel
cedbce4789 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.
2014-03-25 02:32:04 +00:00
marcel
3cd87458c0 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...
2014-03-23 01:10:05 +00:00
marcel
d449c3f144 Handle the -b option for specifying boot code that lives in the
partitioning scheme's meta data. Implement it for GPT.
2014-03-21 19:40:05 +00:00
marcel
ace52aef3d 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).
2014-03-21 16:11:49 +00:00
marcel
ee34aed1b5 Add support for partition labels and write them for GPT. 2014-03-21 05:30:27 +00:00
marcel
8e3f9b93d7 Make this work on big-endian architectures by adding encoding. 2014-03-21 04:52:46 +00:00
marcel
d8d97191a5 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.
2014-03-21 04:14:26 +00:00
marcel
edfa576ac7 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.
2014-03-21 03:27:42 +00:00
marcel
0dddaf6f49 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.
2014-03-20 20:14:26 +00:00
marcel
3f2295fee5 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.
2014-03-20 19:37:30 +00:00
marcel
7f983a3b38 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.
2014-03-20 00:38:17 +00:00