Page MenuHomeFreeBSD

boot0cfg: Also allow a file as a trailing argument
ClosedPublic

Authored by jlduran on May 28 2026, 6:40 PM.
Tags
None
Referenced Files
F164940056: D57310.id178844.diff
Wed, Aug 5, 12:44 AM
F164926690: D57310.id183037.diff
Tue, Aug 4, 9:54 PM
F164874871: D57310.id178867.diff
Tue, Aug 4, 10:16 AM
Unknown Object (File)
Mon, Aug 3, 4:55 PM
Unknown Object (File)
Sun, Aug 2, 1:03 PM
Unknown Object (File)
Sun, Aug 2, 1:13 AM
Unknown Object (File)
Sat, Aug 1, 5:26 AM
Unknown Object (File)
Sat, Aug 1, 3:15 AM
Subscribers

Details

Summary

Modify the disk check to allow arbitrary files as the trailing argument
instead of requiring a live GEOM disk provider.

This enables modifying a boot0 binary file in-place before flashing it
to a disk via gpart bootcode, or using it directly as an argument to
mkimg's partition specification, as these tools cannot directly adjust
the parameters of the boot0 boot manager.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I did this modification, mostly to allow using it in conjunction with mkimg (see the next review in the series). I cannot immediately see any downsides of also enabling a file for modification, I also didn't know whom to ask for a review, as boot0cfg's usage is slowly fading away.

Ah! This explains the other issue I had in a review I saw before this.

This revision is now accepted and ready to land.May 28 2026, 9:20 PM
This revision now requires review to proceed.May 29 2026, 1:10 AM
This revision is now accepted and ready to land.May 29 2026, 1:50 AM

LGTM in general, just some cosmetic suggestions.

usr.sbin/boot0cfg/boot0cfg.8
188

I wonder if we want to avoid modifying boot0 in place in examples, but instead suggest copying it to another pathname that is then passed to gpart bootcode? You could then do a combined example maybe:

Create a copy of
.Pa boot0
with only slices 1 and 3 enabled in the menu and install that onto a disk using
.Xr gpart 8 :
.Bd -literal -offset indent -compact
cp /boot/boot0 /boot/boot0.custom
boot0cfg -m 0x5 /boot/boot0.custom
gpart bootcode -b /boot/boot0.custom ada0
.Ed
usr.sbin/boot0cfg/boot0cfg.c
406

Pre-existing bug in the comment, but might as well fix it while you are here.

416

s/flash/write/?

Also, maybe "If name is a regular file, re-open it in write-only mode ..."

This revision was automatically updated to reflect the committed changes.
jlduran marked 3 inline comments as done.