History log of /freebsd-current/usr.sbin/boot0cfg/boot0cfg.c
Revision Date Author Comments
# 4d65a7c6 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.sbin: 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


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 72e1ea2f 07-Jul-2023 Alfonso Gregory <gfunni234@gmail.com>

Mark usage function as __dead2 in programs where it does not return

In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 5b990a94 22-Jun-2020 Baptiste Daroussin <bapt@FreeBSD.org>

Revert r362466

Such change should not have happen without prior discussion and review.

With hat: transitioning core


# 7747001b 21-Jun-2020 Hans Petter Selasky <hselasky@FreeBSD.org>

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


# ac8e5d02 13-Aug-2019 Conrad Meyer <cem@FreeBSD.org>

Remove deprecated GEOM classes

Follow-up on r322318 and r322319 and remove the deprecated modules.

Shift some now-unused kernel files into userspace utilities that incorporate
them. Remove references to removed GEOM classes in userspace utilities.

Reviewed by: imp (earlier version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D21249


# cdd2df88 27-Nov-2018 Dag-Erling Smørgrav <des@FreeBSD.org>

Add a “skip_dsn” option to g_part's bootcode verb to prevent g_part_mbr
from setting the volume serial number. This unbreaks older boot blocks
that don't support serial numbers, and allows boot0cfg to set the serial
number itself if requested by the user.

Submitted by: lev@, yuripv@
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D17386


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 793128cc 10-Mar-2017 Marcelo Araujo <araujo@FreeBSD.org>

Use nitems() from sys/param.h

Reviewed by: jhb
MFC after: 3 weeks.
Differential Revision: https://reviews.freebsd.org/D9941


# a6c9d35c 14-Jan-2016 John Baldwin <jhb@FreeBSD.org>

Adjust previous fix to conform to the existing style in this file.


# 32960dd1 18-Dec-2015 John Baldwin <jhb@FreeBSD.org>

Fix the precious change to check the pointer returned by malloc().

Submitted by: luke <luke.tw@gmail.com>
Pointy hat to: jhb


# b128c3c3 17-Dec-2015 John Baldwin <jhb@FreeBSD.org>

Exit cleanly if malloc() fails to allocate a buffer for a copy of the
current MBR.

PR: 205322
Submitted by: Alexander Kuleshov <kuleshovmail@gmail.com>
MFC after: 1 week


# f9a01458 20-Dec-2011 John Baldwin <jhb@FreeBSD.org>

Allow boot0cfg to force a PXE boot via boot0 on the next boot.
- Fix boot0 to check for PXE when using the pre-set setting for the
preferred slice.
- Update boot0cfg to use slice 6 to select PXE. Accept a 'pxe' argument
instead of a number for the 's' option as a way to select PXE as well.

Submitted by: Andrew Boyer aboyer averesystems
MFC after: 2 weeks


# de028133 23-Nov-2011 Kevin Lo <kevlo@FreeBSD.org>

Plug fd leaks


# 7411f128 07-Nov-2011 Andrey V. Elsukov <ae@FreeBSD.org>

Reorganize write_mbr() function to be able write bootcode with different
ways. Improve error reporting and also fix indenting.
Now we are trying to write bootcode:
1. Directly to provider (if we can open it for writing);
2. Via GEOM_PART (if it is available);
3. Via GEOM_MBR.

MFC after: 2 weeks


# e052b60b 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Mark global functions and/or variables in boot0cfg(8) static where possible.

This allows compilers and static analyzers to do more thorough analysis.


# 9f772ce2 24-Oct-2011 Andrey V. Elsukov <ae@FreeBSD.org>

Fix argument name. This fixes EINVAL when boot0cfg uses GEOM_PART'
control interface.

MFC after: 3 days


# 20016815 06-Dec-2010 Rebecca Cran <brucec@FreeBSD.org>

Revert r209469: it causes the rest of the function to be bypassed.

Reported by: ae


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fdf78c22 23-Jun-2010 Rebecca Cran <brucec@FreeBSD.org>

If a device can't be opened, don't keep going but display the error
returned from open() and quit.

PR: bin/81035
Submitted by: Peter Schuller <peter.schuller at infidyne.com>
Approved by: rrs (mentor)


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# a565cc28 01-Mar-2009 Marcel Moolenaar <marcel@FreeBSD.org>

Write the MBR by using the bootcode verb of the gpart class.
The "write MBR" verb is kept for backward compatibility, but
the DIOCSMBR ioctl has been removed.


# ae309670 03-Dec-2008 Luigi Rizzo <luigi@FreeBSD.org>

Another, hopefully final set of changes to boot0 and boot0cfg.

boot0.S changes:

+ import a patch from Christoph Mallon to rearrange the various
print functions and save another couple of bytes;

+ implement the suggestion in PR 70531 to enable booting from
any valid partition because even the extended partitions that
were previously in our kill list may contain a valid boot loader.
This simplifies the code and saves some bytes;

+ followwing up PR 127764, implement conditional code to preserve
the 'Volume ID' which might be used by other OS (NT, XP, Vista)
and is located at offset 0x1b8. This requires a relocation of the
parameter block within the boot sector -- there is no other
possible workaround.
To address this, boot0cfg has been updated to handle both
versions of the boot code;

+ slightly rearrange the strings printed in the menus to make
the code buildable with all options. Given the tight memory
budget, this means that with certain options we need to
shrink or remove certain labels.

and especially:

make -DVOLUME_LABEL -DPXE the default options.

This means that the newly built boot0 block will preserve the
Volume ID, and has the (hidden) option F6 to boot from INT18/PXE.
I think the extra functionality is well worth the change.

The most visible difference here is that the 'Default: ' string
now becomes 'Boot: ' (it can be reverted to the old value
but then we need to nuke 1/2 partition name or entries to
make up for the extra room).

boot0cfg changes:

+ modify the code to recognise the new boot0 structure (with the
relocated options block to make room for the Volume id).

+ add two options, '-i xxxx-xxxx' to set the volume ID, -e c
to modify the character printed in case of bad input

PR: 127764 70531
Submitted by: Christoph Mallon (portions)
MFC after: 4 weeks


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# bd5add58 30-Sep-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Improve error message given on g_providername call failure.
- While there, make error messages consistent with the rest.

Approved by: kib (mentor)


# b31e5ae2 07-Sep-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Make use of the new and g_device_path utility function in libgeom to avoid
duplication of code in fdisk and boot0cfg. Also make use of g_providername to
fix an issue with fdisk and boot0cfg not using the correct provider when
writing the MBR.

Reviewed by: phk
Approved by: pjd (mentor)


# dfa5ad94 15-Jul-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Attempt gctl verb "write MBR" when updating.

This should solve the problem of modifying the MBR while running.


# 5679e1ac 18-Dec-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Open device R/W for ioctl modifications.


# 03234cab 14-Sep-2004 Tor Egge <tegge@FreeBSD.org>

Correct polarity of packet mode bit.

Problem discovered when 'boot0cfg -B -v -o packet -s 2 ad4' turned off
packet mode while reporting it as being enabled.


# 3d862ddd 03-Aug-2004 David E. O'Brien <obrien@FreeBSD.org>

Enable packet mode by default. Disk drives have gotten so large now,
it is often the case the partition one wants to boot is above cylinder 1023.


# a7526044 16-May-2004 Stefan Farfeleder <stefanf@FreeBSD.org>

Remove spurious semicolons. Outside of functions they are actually errors but
GCC doesn't warn about them without -pedantic.

Approved by: das (mentor)
PR: 56649
Reviewed by: md5


# b728350e 03-May-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID over rcsid[]. Protect copyright[] where needed.


# 23db6b29 29-Dec-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Use the new sector0 munging ioctls to make boot0cfg work under GEOM.


# 3bb24c35 01-Oct-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Split MBR and PC98 on-disk sliceformats out from disklabel.h, step 1:

Peter had repocopied sys/disklabel.h to sys/diskpc98.h and sys/diskmbr.h.

These two new copies are still intact copies of disklabel.h and
therefore protected by #ifndef _SYS_DISKLABEL_H_ so #including them
in programs which already include <sys.disklabel.h> is currently a
no-op.

This commit adds a number of such #includes.

Once I have verified that I have fixed all the places which need fixing,
I will commit the updated versions of the three #include files.

Sponsored by: DARPA & NAI Labs.


# 50483cb4 10-Dec-2001 Mike Heffner <mikeh@FreeBSD.org>

WARNS=2 cleanup.

Submitted by: Maxime Henrion <mux@qualys.com>
MFC after: 2 weeks


# bae528ba 22-Mar-2001 Ian Dowse <iedowse@FreeBSD.org>

Add missing specification of the `-s' option to the usage line.

PR: bin/26004
Submitted by: ushida@msa.biglobe.ne.jp
Reviewed by: rnordier


# 81e309b7 17-Aug-2000 David Malone <dwmalone@FreeBSD.org>

Allow people to set the default boot slice with boot0cfg.

PR: 18923
Submitted by: Ian Dowse <iedowse@maths.tcd.ie>
Reviewed by: jhb
Approved by: rnordier


# c5dc421f 13-Jul-2000 John Baldwin <jhb@FreeBSD.org>

- When we save the existing MBR to a file, check to see if the MBR we are
saving is boot0. If it is, use its version number so that we can grab
all of boot0 (1024 bytes with version 1.1 for example) when we save it
to a file via the 'f' option. Otherwise, we just save the first sector.
- Cleanup this code a bit by splitting some functionality out into separate
functions.

Suggested by: Patrick Bihan-Faou <patrick@mindstep.com> (1)


# 226ae6ff 12-Jul-2000 John Baldwin <jhb@FreeBSD.org>

Update boot0cfg to handle the new boot0:
- Allow for boot0 to be more than one sector long. However, ensure that it
its length is a multiple of the sector length.
- Change the signatures used to determine a valid boot0 as some of the
signature code changed.
- Use the old signature to detect version 1.0 of boot0, otherwise read the
version number from boot0 itself.


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# d1306cd8 22-Jun-1999 Robert Nordier <rnordier@FreeBSD.org>

Check that we really have a boot0 mbr before treating it as one.

Suggested by: peter

Also add a few comments.


# 0fdf16a3 21-Jun-1999 Robert Nordier <rnordier@FreeBSD.org>

Ensure that an update takes place when the -m option is used.


# 5868a099 19-Jun-1999 Robert Nordier <rnordier@FreeBSD.org>

Implement -m option to enable/disable slices.


# ee6fb785 26-Feb-1999 Robert Nordier <rnordier@FreeBSD.org>

Finish implementing "setdrv" option. This is intended to be used
(with care) in those instances where boot0 is not passed the
correct drive number by the PC BIOS. (The symptoms are a
"F5 Drive 0" line, even though the current drive is drive 0.)


# ed720ec3 22-Feb-1999 Robert Nordier <rnordier@FreeBSD.org>

Make various minor corrections.


# 0b654f60 21-Feb-1999 Robert Nordier <rnordier@FreeBSD.org>

Add boot0cfg: this installs/configures the `boot0' boot manager. A
CLI utility to do this has been requested by a few people.