Commit Graph

144 Commits

Author SHA1 Message Date
Eugene Grosbein
7f0dc6e2cd mkimg(1): process non-seekable output gracefully
mkimg may make severe load only to fail in the end
if output is non-seekable pipe, socket or FIFO
unless output format is raw disk image.

Check it out and fail early. Make it clear in the manual.

MFC after:	1 week
2024-03-12 23:00:21 +07:00
Eugene Grosbein
d1797fb5bb mkimg.1: add new PARTITION SPECIFICATION section
The specification follows a commentary to the function parse_part()
in the source code and the code itself.

MFC after:	3 days
2024-02-28 02:56:26 +07:00
Yu-Hsun Chen
1a35ead682
mkimg(1): Fix typo
This is from the Advanced UNIX Programming Course (Fall’23) at NTHU.

MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/930
2023-12-17 18:49:28 +08:00
Warner Losh
5e3934b15a usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Jose Luis Duran
3b5c984572 Remove $FreeBSD$: one line sh-pattern
Remove the $FreeBSD$ pattern added to the tests, as well as fixing the
mkimg_test.sh script to stop adding it when we rebase the tests.

Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/870
2023-10-18 09:15:18 -06:00
Warner Losh
d2abbfede5 mkimg: Regenerate all the tests for gpt
Recent changes to mkimg has changed the generated GPT images to be more
correct. Use make rebase to regenerate the baseline.

Sponsored by:		Netflix
2023-10-17 15:56:19 -06:00
Warner Losh
83bd5a833c mkimg_test: remove vtoc8 images, they aren't needed
vtoc8 support expired with sparc64 removal, so remove them all.

Sponsored by:		Netflix
2023-10-17 15:56:19 -06:00
Warner Losh
9b42d3e12f mkimg: Ensure GPT Entry Array is at least 16k
UEFI v2.10 Section 5.3 documentes that the minimum reserved space after
the GPT header be at least 16kB. Enforce this minimum. Before, we'd only
set the number of entries to be the unpadded size. gpart's selective
enforcement of aspects of the GPT standard meant that these images would
work, but couldn't be changed (to add a partition or grow the size of a
partition). This ensures that gpart's overly picky standards don't cause
problems for people wishing to, for example, resize release images.

MFC after:		1 day (we want this in 14.0)
PR:			274312
Sponsored by:		Netflix
Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D42245
2023-10-17 11:14:23 -06:00
Warner Losh
fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Marius Strobl
4ef1c6f75d base: Remove support for the VTOC8 partitioning scheme
The removal of the sparc64 support in February 2020 obsoleted the
VTOC8 partitioning scheme as no other FreeBSD platform makes use
of it. Moreover, the code is bitrotting as nothing defines e. g.
LOADER_VTOC8_SUPPORT any more and, thus, should go now, too. With
this change, the following commits are reverted as far as VTOC8
is concerned and parts haven't already previously been deleted
along with prior sparc64 removals:
094fcb157d
a7d366e958
ba8d50d08b

The alignment example d9711c28ef
added to the VTOC8 section of gpart.8 is folded into the MBR one.

This should finally conclude the deorbit of sparc64-specific bits.

        We had joy, we had fun
        we ran Unix on a Sun.
        But that source and the song
        of FreeBSD have all gone.

Credits to Michael Bueker for the original "Unix on a Sun" and Rod
McKuen for the "Seasons in the Sun" lyrics.
2023-07-26 13:16:12 +02:00
Simon J. Gerraty
188bf8876f Build host tools on non-FreeBSD host with DIRDEPS_BUILD
Add Makefile.depend.options to libnetbsd, mkimg and makefs
to ensure libegacy is build if needed.

targets/pseudo/stage/Makefile avoid the need for mtree
the staging process creates target dirs as needed anyway.

Reviewed by:	stevek
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D39757
2023-04-22 13:13:22 -07:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Ed Maste
036af1053a mkimg: zero entry in vhdx_write_metadata
Otherwise _reserved might contain uninitialized data.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-11-20 19:37:25 -05:00
Gordon Bergling
6bddade611 mkimg(1): Correct a typo in the usage output
- s/partion/partition/

MFC after:  5 days
2021-08-09 13:53:30 +02:00
Jose Luis Duran
d98a4eb807 mkimg: Add fat32lba partition type
Syntactic sugar for a `gpart add -t '!12' ...` equivalent.

Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/484
2021-06-21 21:04:58 -04:00
Emmanuel Vadot
8f3c71c85e mkimg: Add support for offset if the source is an image
This allow us to create image with the following format:
mkimg -v -o sdcard -s gpt -p efi:=esp_aarch64.img:1M -p freebsd-ufs::1G

Which will add a efi partition at a 1M offset on the image with its content
coming from the esp_aarch64.img file.

MFC after:	3 days
2021-02-25 18:11:50 +01:00
Emmanuel Vadot
3b6268bb9e mkimg: We always want the last block of the last inserted partition
Even with an absolute offset we want to know the last block the partition
otherwise we endup with an image the size of the metadata.
This allow to create image with the ESP placed at a specific position which
is useful on arm/arm64 where u-boot have always a hard time to read the ESP
if it's not aligned on 512k.
mkimg -v -o sdcard -s gpt -p efi::54M:1M -p freebsd-ufs::1G
now works.

MFC after:	3 days
2021-02-25 16:34:28 +01:00
Nathan Whitehorn
f7aebfbe5c Add GPT PREP-boot type to mkimg(1) from geom_gpt.
This partition type can be used to boot some PowerKVM VMs. We don't
support it well because of some limitations in SLOF, but it's worth at
least have feature parity in geom and mkimg.
2021-02-24 10:31:44 -05:00
Alex Richardson
fe41c64b57 Fix -Wpointer-sign warnings in makefs and mkimg
Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D27175
2021-01-07 09:26:21 +00:00
Alex Richardson
3ac62888fc Significantly speed up mkimg_test
It turns out that the majority of the test time for the mkimg tests isn't
mkimg itself but rather the use of jot and hexdump which can be quite slow
on emulated platforms such as QEMU.

On QEMU-RISC-V this reduces the time for `kyua test mkimg_test` from 655
seconds to 200. And for CheriBSD on QEMU-CHERI this saves 4-5 hours (25%
of the time for the entire testsuite!) since jot ends up triggering slow
functions inside the QEMU emulation a lot.

Reviewed By:	lwhsu
Differential Revision: https://reviews.freebsd.org/D26796
2020-10-18 18:35:23 +00:00
Gordon Bergling
3d265fce43 Fix a few mandoc issues
- skipping paragraph macro: Pp after Sh
- sections out of conventional order: Sh EXAMPLES
- whitespace at end of input line
- normalizing date format
2020-10-09 19:12:44 +00:00
Kyle Evans
7cc42f6d25 Do a sweep and remove most WARNS=6 settings
Repeating the default WARNS here makes it slightly more difficult to
experiment with default WARNS changes, e.g. if we did something absolutely
bananas and introduced a WARNS=7 and wanted to try lifting the default to
that.

Drop most of them; there is one in the blake2 kernel module, but I suspect
it should be dropped -- the default WARNS in the rest of the build doesn't
currently apply to kernel modules, and I haven't put too much thought into
whether it makes sense to make it so.
2020-10-01 01:10:51 +00:00
Oleksandr Tymoshenko
e331252340 Fix invalid VHDX generation for image larger than 4Gb
- Part of BAT payload location was lost due to invalid
    BAT entry encoding type (32 bits instead of 64 bits)
- The sequence of PB/SB entries in BAT was broken due to
    off-by-one index check. It worked for smaller than
    4Gb because there were no SB entries in BAT.

MFC after:	1 day
2020-07-13 02:24:31 +00:00
Baptiste Daroussin
5b990a9463 Revert r362466
Such change should not have happen without prior discussion and review.

With hat:	transitioning core
2020-06-22 07:46:24 +00:00
Hans Petter Selasky
7747001b12 Improve wording to be more precise and clear.
No functional change intended.

s/Master Boot/Main Boot/ (also called MBR)

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-06-21 13:34:08 +00:00
Mateusz Piotrowski
19870105e1 Use Fl instead of Ar for long flags
Also, bump date after r361935.

MFC after:	1 week
2020-06-08 21:11:34 +00:00
Oleksandr Tymoshenko
c78cd98b8a Add VHDX support to mkimg(1)
VHDX is the successor of Microsoft's VHD file format. It increases
maximum capacity of the virtual drive to 64TB and introduces features
to better handle power/system failures.

VHDX is the required format for 2nd generation Hyper-V VMs.

Reviewed by:	marcel
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D25184
2020-06-08 20:28:32 +00:00
Alex Richardson
a963845304 Allow bootstrapping mkimg on macOS/Linux
On these systems the (u)int64_t typedefs will not be implicitly defined by the
previous includes, so include <stdint.h> in the header that uses uint64_t.

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D23202
2020-01-16 14:14:55 +00:00
Marcel Moolenaar
370d612f5e Don't compress and uuencode the "hexdump -C" output files. Just
save them with the $FreeBSD$ tag prepended.  Changes to these
files are now a lot easier to comprehend, which makes diffs also
reviewable.
2019-03-09 02:03:07 +00:00
Marcel Moolenaar
835adc6898 Round # partitions up to fill the last GPT table sector
Set the number of partitions entries in the GPT header to a
multiple of the number of entries that fit in a sector.

PR:		236238
Reviewed by:	imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19465
2019-03-05 22:55:33 +00:00
Xin LI
4dbd43cd05 Remove unneeded headers.
MFC after:	1 month
2019-01-06 20:39:23 +00:00
Benno Rice
10e155c08a Fix a conditional that got mucked up.
Sponsored by:	iXsystems, Inc.
2018-04-12 17:16:13 +00:00
Benno Rice
459a61fd2d Add the ability to specify absolute and relative offsets to size partitions.
To create hybrid boot media we want to specify a partition at a known location.
This extends the syntax of size partitions to include an optional offset that
can be absolute or relative. It also introduces validation to make sure that
this hasn't resulted in overlapping partitions. I haven't added this to the
file and process partition specifications yet but the mechanics are designed
such that if someone comes up with a good way of specifying the offset it
will be fairly easy to add in.

Reviewed by:	imp
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D14916
2018-04-12 15:47:47 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Enji Cooper
d511b20a69 Add HAS_TESTS to all Makefiles that are currently using the
`SUBDIR.${MK_TESTS}+= tests` idiom.

This is a follow up to r321912.
2017-08-02 08:50:42 +00:00
Enji Cooper
4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +00:00
Enji Cooper
c0c5c2f45a Update the usr.bin/mkimg golden test output files after ^/head@r319125
^/head@r319125 changed the location of the backup pmbr, requiring the
output files to be regenerated, since they're binary disk dumps.

The output files were regenerated with "make rebase"--fixed in
^/head@r319294.

MFC with:	r319125, r319294
PR:		219673
Sponsored by:	Dell EMC Isilon
2017-05-31 08:01:12 +00:00
Enji Cooper
301441dcd8 Fix "make rebase" after ^/head@r315776
"make rebase" can be used for rebasing the output files from mkimg
after making a change to mkimg. This will come in handy soon, per
bug 219673.

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-05-31 07:49:49 +00:00
Enji Cooper
605b213ee1 Formalize the dependent/dependency relationship for <foo>.gz.uu vs <foo>
This helps ensure that the output files are regenerated if the input files
change, after the output files have been created.

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-05-31 07:42:14 +00:00
Emmanuel Vadot
6b14aecae7 mkimg: Correct an off by one error in the PMBR size
The PMBR last sector should be number of sector - 1 (As stated in UEFI Spec
2.6 page 118 table 17).
This fixes warning printed by linux tools like parted or fdisk.

Sponsored by:	Gandi.net
2017-05-29 12:51:02 +00:00
Emmanuel Vadot
2dcfca637d mkimg: Add -C argument to specify maximum capacity
Add a -C option to specify a maximum capacity for the final image file.
It is useful to control the size of the generated image for sdcard or
when we will add dynamic size partition.

Add --capacity which is a shorthand to define min and max capacity at
the same time.

Reviewed by:	bapt, marcel, wblock (manpages)
Sponsored by:	Gandi.net
Differential Revision:	https://reviews.freebsd.org/D10509
2017-05-10 09:36:34 +00:00
Enji Cooper
458cbf0ae6 Rename tests from <foo> to <foo>_test to match the FreeBSD test suite
naming scheme

usr.bin/diff/diff_test was renamed to usr.bin/diff/netbsd_diff_test
to avoid collisions with the renamed FreeBSD test.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-23 03:28:24 +00:00
Pedro F. Giffuni
6613eaa42b mkimg(1): let calloc(3) do the multiplication.
Reviewed by:	marcel
MFC after:	1 week
2017-03-13 20:14:07 +00:00
Simon J. Gerraty
baf4abfc39 Allow building mkimg as cross-tool
For linux the mmap offset must also be page aligned, and we
need to disable macros like __FBSDID()

Change the linux osdep_uuidgen() to use more portable gettimeofday().

Reviewed by: marcel
2017-03-03 01:56:55 +00:00
Baptiste Daroussin
0e630e32be Add missing section in manpage reference
Reported by:	make manlint
MFC after:	2 days
2017-02-11 23:41:38 +00:00
Yoshihiro Takahashi
2b375b4edd Remove pc98 support completely.
I thank all developers and contributors for pc98.

Relnotes:	yes
2017-01-28 02:22:15 +00:00
Warner Losh
c30dcf40ba Add a new flag to mkimg (-a num) to specify the active partition for
those partitioning schemes that have this concept. Implement it as an
override for mbr's setting 0x80 in the flags for the first partition
when we have boot code.

Differential Revision: https://reviews.freebsd.org/D4403
2016-10-18 05:43:12 +00:00