OpenBSD CVS

CVS log for src/usr.sbin/installboot/i386_installboot.c


[BACK] Up to [local] / src / usr.sbin / installboot

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.46 / (download) - annotate - [select for diffs], Sun Jun 11 14:00:04 2023 UTC (12 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, HEAD
Changes since 1.45: +21 -14 lines
Diff to previous 1.45 (colored)

No need to check for DTYPE_FLOPPY. If there is neither a GPT nor
an MBR then install biosboot in sector 0.

Without the check for DTYPE_FLOPPY there is no need for
FSDISKTYPE=floppy3 and therefore flip the last two Makefiles to
the "echo '/ *' | disklabel -wAT-" idiom.

Feedback/fix from kn@

Revision 1.45 / (download) - annotate - [select for diffs], Wed Apr 26 18:04:21 2023 UTC (13 months, 2 weeks ago) by kn
Branch: MAIN
Changes since 1.44: +2 -2 lines
Diff to previous 1.44 (colored)

Fix confusing comments, no object change;  with caspar

Revision 1.44 / (download) - annotate - [select for diffs], Sun Nov 6 12:33:41 2022 UTC (19 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.43: +4 -1 lines
Diff to previous 1.43 (colored)

Don't leak args.fspec in create_filesystem().

ok kn@

Revision 1.43 / (download) - annotate - [select for diffs], Wed Sep 14 16:43:00 2022 UTC (20 months, 3 weeks ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.42: +2 -9 lines
Diff to previous 1.42 (colored)

Backout "Reflect script failure in exit code"

amd64 install using (G)PT seems busted as reported by tb

Revision 1.42 / (download) - annotate - [select for diffs], Fri Sep 9 15:53:16 2022 UTC (21 months ago) by kn
Branch: MAIN
Changes since 1.41: +10 -3 lines
Diff to previous 1.41 (colored)

Reflect script failure in exit code

installboot(8) runs newfs(8) and fsck(8) via system(3) but only checks
failures of the function itself, always returning zero no matter what the
programs/shell returned.

This is bad for regress tests relying on correct return codes.

create_filesystem() itself must not exit as write_filesystem() calls it and
cleans up temporary files upon failure.

Make it return -1 if the script returned non-zero so write_filesystem()
handles it as error, cleans up and makes installboot exit 1.

Stop ignoring create_filesystem()'s return code in md_prepareboot() and
exit the same way.

Here's the change in behaviour on arm64 (newfs fails because of the
vnd/disklabel race, see "Race in disk_attach_callback?" on tech@):

	# installboot -vp vnd0 ; echo $?
	newfsing 6694ae5b0d7596ed.i
	newfs_msdos: /dev/r6694ae5b0d7596ed.i: No such file or directory
	0
	# ./obj/installboot -vp vnd0 ; echo $?
	newfsing 6694ae5b0d7596ed.i
	newfs_msdos: /dev/r6694ae5b0d7596ed.i: No such file or directory
	1

Tested on amd64 arm64 macppc octeon powerpc64 sparc64
OK millert

Revision 1.41 / (download) - annotate - [select for diffs], Wed Aug 31 20:52:15 2022 UTC (21 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.40: +3 -3 lines
Diff to previous 1.40 (colored)

Replace "newfs_msdos" and "fsck_msdos" with "newfs -t msdos" and "fsck -t
msdos".

Add some missing spaces after "=".

Constify the static strings.

Prodded a while ago by deraadt@, tweaks from kn@, ok kn@

Revision 1.40 / (download) - annotate - [select for diffs], Tue Jul 20 14:51:56 2021 UTC (2 years, 10 months ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.39: +67 -13 lines
Diff to previous 1.39 (colored)

Add -p option to "prepare" (newfs) a filesystem that will be used for
the bootloader.  This is a no-op on architectures where such a filesystem
isn't needed.

ok krw@, deraadt@

Revision 1.39 / (download) - annotate - [select for diffs], Wed Jun 2 22:44:27 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.38: +5 -6 lines
Diff to previous 1.38 (colored)

Use the same logic in all copies of gpt_chk_mbr(), relaxing the
media length check to allow EFI GPT partitions to be smaller that
the entire disk.

Consistently use GPTSECTOR instead of randomly tossing in some
literal '1's.

ok kettenis@

Revision 1.38 / (download) - annotate - [select for diffs], Wed Jul 22 05:06:38 2020 UTC (3 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.37: +2 -1 lines
Diff to previous 1.37 (colored)

force long-names on msdos filenames, so that folk can see pretty names
later.
ok kettenis gkoehler

Revision 1.37 / (download) - annotate - [select for diffs], Sat Jun 27 15:35:29 2020 UTC (3 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.36: +3 -3 lines
Diff to previous 1.36 (colored)

convert macppc, octeon, and loongson to use MI installboot, removing
special case scripting in install.md.
(macppc still requires manual steps for HFS bootmode)
tested by krw, visa, gkoehler

Revision 1.36 / (download) - annotate - [select for diffs], Mon Mar 9 06:16:56 2020 UTC (4 years, 3 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.35: +99 -18 lines
Diff to previous 1.35 (colored)

Recommit, now that we found out how to fix the BIOS related issues: go
back to a 4 byte add instruction.
We do not know *why* though, so if somebody likes a challenge...
Lots of help from semarie@ who has a few systems showing the issue.
ok deraadt@

Revision 1.35 / (download) - annotate - [select for diffs], Sat Mar 7 15:11:50 2020 UTC (4 years, 3 months ago) by otto
Branch: MAIN
Changes since 1.34: +17 -98 lines
Diff to previous 1.34 (colored)

Revert previous, there are BIOS that do not like these changes.
Sorry for the inconvenience. With help from semarie@.

Revision 1.34 / (download) - annotate - [select for diffs], Fri Feb 28 12:26:30 2020 UTC (4 years, 3 months ago) by otto
Branch: MAIN
Changes since 1.33: +99 -18 lines
Diff to previous 1.33 (colored)

Adapt biosboot(8) so it can read boot(8) from an ffs2 filesystem.
To do this, installboot(8) patches an extra value into biosboot(8).
Code originally from Pedro Martelletto with a twist from myself and
kettenis@; ok jsing@ kettenis@

Revision 1.33 / (download) - annotate - [select for diffs], Mon Sep 2 16:36:12 2019 UTC (4 years, 9 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.32: +1 -2 lines
Diff to previous 1.32 (colored)

Fix copyright lines, the "one-inode file system" in i386_softraid.c is my
invention; and I have had little to do with the i386_installboot.[ch] files.
This was mixed up in the giant reshuffle a few years back. ok jsing@

Revision 1.32 / (download) - annotate - [select for diffs], Fri Jun 28 13:32:48 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.31: +6 -6 lines
Diff to previous 1.31 (colored)

When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.

Revision 1.31 / (download) - annotate - [select for diffs], Fri Oct 27 16:47:08 2017 UTC (6 years, 7 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.30: +2 -2 lines
Diff to previous 1.30 (colored)

Use <elf.h> instead of <elf_abi.h>

ok jasper@, jca@, deraadt@

Revision 1.30 / (download) - annotate - [select for diffs], Sun Jun 4 13:57:29 2017 UTC (7 years ago) by naddy
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.29: +6 -4 lines
Diff to previous 1.29 (colored)

Malloc the superblock buffer to make sure that it is properly aligned.
On i386, clang puts the char array at an odd address in .bss.
ok deraadt@

Revision 1.29 / (download) - annotate - [select for diffs], Tue May 31 18:35:58 2016 UTC (8 years ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1, OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored)

Add support for armv7.  Fix an error message in the i386 support before
creating more copies.

ok deraadt@, jsing@

Revision 1.28 / (download) - annotate - [select for diffs], Mon May 23 20:48:07 2016 UTC (8 years ago) by kettenis
Branch: MAIN
Changes since 1.27: +2 -2 lines
Diff to previous 1.27 (colored)

Use PATH_MAX instead of a hardcoded minimal value.  Stack space is cheap and
this isn't the kernel.

requested by deraadt@

Revision 1.27 / (download) - annotate - [select for diffs], Thu Apr 28 16:48:18 2016 UTC (8 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.26: +3 -1 lines
Diff to previous 1.26 (colored)

Plug a couple of leaks of input buffers.

Pointed out by David Carlier.

Revision 1.26 / (download) - annotate - [select for diffs], Mon Dec 28 23:00:29 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.25: +17 -24 lines
Diff to previous 1.25 (colored)

Replace lseek/[read|write] with pread|pwrite.

ok millert@ a while ago.

Revision 1.25 / (download) - annotate - [select for diffs], Thu Dec 24 20:14:07 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.24: +2 -2 lines
Diff to previous 1.24 (colored)

Make gpt_chk_mbr() instances even more identicaller by always
returning 0 or 1 since only boolean checks of the result are done.
No need for EINVAL as a return value.

Revision 1.24 / (download) - annotate - [select for diffs], Thu Dec 24 18:03:03 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.23: +4 -6 lines
Diff to previous 1.23 (colored)

Make all instances of gpt_chk_mbr() identical (bar static vs
non-static) by passing disk size as 2nd parameter instead of the
different structures holding the disk size info. The fifth copy of
gpt_chk_mbr() in fdisk is a little specialer. No functional change.

Revision 1.23 / (download) - annotate - [select for diffs], Thu Dec 24 14:12:43 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.22: +3 -2 lines
Diff to previous 1.22 (colored)

Add prototype for gpt_chk_mbr() to i386_installboot.c. Add 'static' to
declarations of gpt_chk_mbr() to match prototypes in efidev.c and
softraid.c.

Revision 1.22 / (download) - annotate - [select for diffs], Sun Dec 20 18:04:34 2015 UTC (8 years, 5 months ago) by rpe
Branch: MAIN
Changes since 1.21: +3 -3 lines
Diff to previous 1.21 (colored)

Remove unnecessary options:
- in fsck_msdos, '-f' option is a no-op
- newfs_msdos does not need '-t msdos'

OK krw@

Revision 1.21 / (download) - annotate - [select for diffs], Thu Dec 10 18:40:46 2015 UTC (8 years, 6 months ago) by mmcc
Branch: MAIN
Changes since 1.20: +2 -3 lines
Diff to previous 1.20 (colored)

Remove NULL-checks before free(). ok tb@

Revision 1.20 / (download) - annotate - [select for diffs], Tue Dec 1 19:10:16 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.19: +52 -1 lines
Diff to previous 1.19 (colored)

Steal code from kern/subr_disk.c to check for a protective MBR before
using GPT info. Otherwise GPT remnants might become revenants.

Revision 1.19 / (download) - annotate - [select for diffs], Tue Dec 1 06:39:52 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.18: +1 -2 lines
Diff to previous 1.18 (colored)

Don't need <sys/types.h> and <sys/param.h>. Nuke the former when DEV_BSIZE
is needed.

Revision 1.18 / (download) - annotate - [select for diffs], Mon Nov 30 17:34:57 2015 UTC (8 years, 6 months ago) by jsing
Branch: MAIN
Changes since 1.17: +5 -3 lines
Diff to previous 1.17 (colored)

Revert the sync -> fsync conversion (at least for the time being) - there
is a good chance that this is causing the 'No blocks to load' errors that
various people have encountered.

Revision 1.17 / (download) - annotate - [select for diffs], Thu Nov 26 19:03:10 2015 UTC (8 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.16: +3 -5 lines
Diff to previous 1.16 (colored)

Apply pledge.
The people I asked to review this did not get back to me, so
we will test this a different way.

Revision 1.16 / (download) - annotate - [select for diffs], Tue Nov 3 11:38:41 2015 UTC (8 years, 7 months ago) by jsg
Branch: MAIN
Changes since 1.15: +4 -2 lines
Diff to previous 1.15 (colored)

fix a memory leak in an error path

Revision 1.15 / (download) - annotate - [select for diffs], Sun Oct 25 21:21:15 2015 UTC (8 years, 7 months ago) by stsp
Branch: MAIN
Changes since 1.14: +2 -3 lines
Diff to previous 1.14 (colored)

Fix installboot(8) on i386/amd64 when softraid is on top of GPT.
ok krw deraadt

Revision 1.14 / (download) - annotate - [select for diffs], Sun Oct 18 17:24:25 2015 UTC (8 years, 7 months ago) by rpe
Branch: MAIN
Changes since 1.13: +3 -3 lines
Diff to previous 1.13 (colored)

Fix comments.

OK krw@

Revision 1.13 / (download) - annotate - [select for diffs], Wed Oct 14 14:13:12 2015 UTC (8 years, 7 months ago) by jsg
Branch: MAIN
Changes since 1.12: +2 -1 lines
Diff to previous 1.12 (colored)

add includes for crc32() and uuid_dec_be() missed in rev 1.11
ok krw@

Revision 1.12 / (download) - annotate - [select for diffs], Thu Oct 8 14:50:38 2015 UTC (8 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.11: +19 -8 lines
Diff to previous 1.11 (colored)

Refactor fileprefix() and filecopy() to use warn() instead of err()
to display error message, and to return error indications (NULL and
-1 respectively).  Use the error indications in write_efisystem()
to unwind in the face of more error conditions. In other cases just
exit(1) to emulation current behaviour.

ok deraadt@

Revision 1.11 / (download) - annotate - [select for diffs], Wed Oct 7 03:06:46 2015 UTC (8 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.10: +245 -1 lines
Diff to previous 1.10 (colored)

Add initial support for installing UEFI boot files to a GTP EFI System
Partition. Further work to be done in-tree.

ok deraadt@

Revision 1.10 / (download) - annotate - [select for diffs], Mon Oct 5 16:07:57 2015 UTC (8 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.9: +2 -2 lines
Diff to previous 1.9 (colored)

Out, damned whitespace!

Revision 1.9 / (download) - annotate - [select for diffs], Sat Oct 3 16:56:52 2015 UTC (8 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.8: +3 -3 lines
Diff to previous 1.8 (colored)

Nuke trailing whitespace to avoid cluttering possible upcoming diffs.

Revision 1.8 / (download) - annotate - [select for diffs], Tue Jan 20 18:22:21 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)

Adjust <sys/param.h> comments regarding use of use of MAXFRAG, or
delete <sys/param.h> if now possible
ok guenther

Revision 1.7 / (download) - annotate - [select for diffs], Fri Jan 16 00:05:12 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.6: +3 -2 lines
Diff to previous 1.6 (colored)

first batch of cleanup to programs based upon the namespace cleanups
in net/pfvar.h sys/proc.h sys/ucred.h arpa/nameser.h
change to PATH_MAX, reduce use of MIN() and MAX(), HOST_NAME_MAX+1,
LOGIN_NAME_MAX, etc etc
ok millert guenther, some review by doug

Revision 1.6 / (download) - annotate - [select for diffs], Wed Oct 8 04:26:54 2014 UTC (9 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.5: +3 -4 lines
Diff to previous 1.5 (colored)

use reallocarray() to detect int overflow; ok doug

Revision 1.5 / (download) - annotate - [select for diffs], Tue Jul 8 17:19:26 2014 UTC (9 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.4: +1 -3 lines
Diff to previous 1.4 (colored)

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis

Revision 1.4 / (download) - annotate - [select for diffs], Wed Jun 25 18:21:24 2014 UTC (9 years, 11 months ago) by tobias
Branch: MAIN
Changes since 1.3: +3 -2 lines
Diff to previous 1.3 (colored)

Check malloc return value for NULL.

ok jsing@

Revision 1.3 / (download) - annotate - [select for diffs], Mon Jun 9 15:50:08 2014 UTC (10 years ago) by jsing
Branch: MAIN
Changes since 1.2: +4 -1 lines
Diff to previous 1.2 (colored)

Change the installboot file copying process so that it carefully
overwrites the existing file, before truncating it to the final length.
This means that we will keep the same inode and potentially retain the
same disk data block allocation between runs.

This will aid users who multiboot since it makes it less likely that the
PBR will change, although as before, there is no guarantee. Obviously if
the second stage boot loader grows or shrinks then the PBR will change
regardless.

Revision 1.2 / (download) - annotate - [select for diffs], Sun Apr 27 13:41:50 2014 UTC (10 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.1: +6 -2 lines
Diff to previous 1.1 (colored)

Don't zap disklabel (and next 6 blocks) when installing boot block on
4k-sector disk drives.

Noted and fix tested by David Vasek via misc@

tweaks & ok jsing@

Revision 1.1 / (download) - annotate - [select for diffs], Sun Jan 19 02:58:50 2014 UTC (10 years, 4 months ago) by jsing
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5

Rework installboot and use a single directory with a single makefile. The
directory per machine model is arguably cleaner, however it does not play
well with distrib/special and instbin.

Discussed with deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.