Page MenuHomeFreeBSD

D57310.id178844.diff
No OneTemporary

D57310.id178844.diff

diff --git a/usr.sbin/boot0cfg/boot0cfg.8 b/usr.sbin/boot0cfg/boot0cfg.8
--- a/usr.sbin/boot0cfg/boot0cfg.8
+++ b/usr.sbin/boot0cfg/boot0cfg.8
@@ -22,7 +22,7 @@
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd October 1, 2013
+.Dd May 28, 2026
.Dt BOOT0CFG 8
.Os
.Sh NAME
@@ -40,7 +40,7 @@
.Op Fl o Ar options
.Op Fl s Ar slice
.Op Fl t Ar ticks
-.Ar disk
+.Ar disk | file
.Sh DESCRIPTION
The
.Fx
@@ -62,9 +62,15 @@
utility optionally installs the
.Sq boot0
boot manager on the specified
-.Ar disk ;
+.Ar disk
+or
+.Ar file ;
and allows various operational parameters to be configured.
.Pp
+If a file is specified as the target argument, all operations are
+performed entirely in-place.
+This allows for offline payload preparation.
+.Pp
On PCs, a boot manager typically occupies sector 0 of a disk, which is
known as the Master Boot Record (MBR).
The MBR contains both code (to which control is passed by the PC BIOS)
@@ -104,8 +110,10 @@
This file is created if it does not exist, and replaced if it does.
.It Fl i Ar volume-id
Specifies a volume-id (in the form XXXX-XXXX) to be saved at location
-0x1b8 in the MBR. This information is sometimes used by NT, XP and Vista
-to identify the disk drive. The option is only compatible with version 2.00
+0x1b8 in the MBR.
+This information is sometimes used by NT, XP and Vista to identify the
+disk drive.
+The option is only compatible with version 2.00
of the 512-byte boot block.
.It Fl m Ar mask
Specify slices to be enabled/disabled, where
@@ -177,6 +185,13 @@
.Pp
.Dl "boot0cfg -m 0x5 ada0"
.Pp
+To enable just slices 1 and 3 in the menu, but using a file:
+.Dl "boot0cfg -m 0x5 /boot/boot0"
+.Pp
+Then embedding the bootcode file using
+.Xr gpart 8 :
+.Dl "gpart bootcode -b /boot/boot0 ada0"
+.Pp
To go back to non-interactive booting, use
.Xr gpart 8
to install the default MBR:
@@ -199,4 +214,5 @@
.Sq setdrv
option with an incorrect -d operand may cause the boot0 code
to write the MBR to the wrong disk, thus trashing its previous
-content. Be careful.
+content.
+Be careful.
diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c
--- a/usr.sbin/boot0cfg/boot0cfg.c
+++ b/usr.sbin/boot0cfg/boot0cfg.c
@@ -115,6 +115,7 @@
int
main(int argc, char *argv[])
{
+ struct stat sb;
u_int8_t *mbr, *boot0;
int boot0_size, mbr_size;
const char *bpath, *fpath;
@@ -183,9 +184,13 @@
argv += optind;
if (argc != 1)
usage();
- disk = g_device_path(*argv);
- if (disk == NULL)
- errx(1, "Unable to get providername for %s\n", *argv);
+ if (stat(*argv, &sb) == 0 && S_ISREG(sb.st_mode)) {
+ disk = strdup(*argv);
+ } else {
+ disk = g_device_path(*argv);
+ if (disk == NULL)
+ errx(1, "Unable to get providername for %s\n", *argv);
+ }
up = B_flag || d_arg != -1 || m_arg != -1 || o_flag || s_arg != -1
|| t_arg != -1;
@@ -403,7 +408,7 @@
pname = g_providername(fd);
if (pname == NULL) {
- warn("error getting providername for %s", fname);
+ warn("error getting file or providername for %s", fname);
return;
}
@@ -594,6 +599,6 @@
{
fprintf(stderr, "%s\n%s\n",
"usage: boot0cfg [-Bv] [-b boot0] [-d drive] [-f file] [-m mask]",
- " [-o options] [-s slice] [-t ticks] disk");
+ " [-o options] [-s slice] [-t ticks] disk | file");
exit(1);
}

File Metadata

Mime Type
text/plain
Expires
Thu, Aug 6, 12:44 AM (13 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36057002
Default Alt Text
D57310.id178844.diff (3 KB)

Event Timeline