CVS commit: src/usr.sbin/installboot/arch

2019-05-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue May  7 04:35:32 UTC 2019

Modified Files:
src/usr.sbin/installboot/arch: alpha.c amiga.c emips.c ews4800mips.c
hp300.c hppa.c i386.c landisk.c macppc.c news.c next68k.c pmax.c
sparc.c sparc64.c sun68k.c vax.c x68k.c

Log Message:
Use designated initializers for struct ib_mach.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/installboot/arch/alpha.c \
src/usr.sbin/installboot/arch/sun68k.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/installboot/arch/amiga.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/installboot/arch/emips.c \
src/usr.sbin/installboot/arch/hppa.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/installboot/arch/ews4800mips.c
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/installboot/arch/hp300.c \
src/usr.sbin/installboot/arch/pmax.c
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/installboot/arch/i386.c
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/installboot/arch/landisk.c \
src/usr.sbin/installboot/arch/news.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/installboot/arch/macppc.c \
src/usr.sbin/installboot/arch/sparc.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/installboot/arch/next68k.c
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/installboot/arch/sparc64.c \
src/usr.sbin/installboot/arch/vax.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/installboot/arch/x68k.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/alpha.c
diff -u src/usr.sbin/installboot/arch/alpha.c:1.21 src/usr.sbin/installboot/arch/alpha.c:1.22
--- src/usr.sbin/installboot/arch/alpha.c:1.21	Sun Aug 14 17:50:17 2011
+++ src/usr.sbin/installboot/arch/alpha.c	Tue May  7 04:35:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: alpha.c,v 1.21 2011/08/14 17:50:17 christos Exp $	*/
+/*	$NetBSD: alpha.c,v 1.22 2019/05/07 04:35:31 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
 
 #include 
 #if !defined(__lint)
-__RCSID("$NetBSD: alpha.c,v 1.21 2011/08/14 17:50:17 christos Exp $");
+__RCSID("$NetBSD: alpha.c,v 1.22 2019/05/07 04:35:31 thorpej Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -121,9 +121,14 @@ static void	check_sparc(const struct alp
 static int alpha_clearboot(ib_params *);
 static int alpha_setboot(ib_params *);
 
-struct ib_mach ib_mach_alpha =
-	{ "alpha", alpha_setboot, alpha_clearboot, no_editboot,
-		IB_STAGE1START | IB_ALPHASUM | IB_APPEND | IB_SUNSUM };
+struct ib_mach ib_mach_alpha = {
+	.name		=	"alpha",
+	.setboot	=	alpha_setboot,
+	.clearboot	=	alpha_clearboot,
+	.editboot	=	no_editboot,
+	.valid_flags	=	IB_STAGE1START | IB_ALPHASUM | IB_APPEND |
+IB_SUNSUM,
+};
 
 static int
 alpha_clearboot(ib_params *params)
Index: src/usr.sbin/installboot/arch/sun68k.c
diff -u src/usr.sbin/installboot/arch/sun68k.c:1.21 src/usr.sbin/installboot/arch/sun68k.c:1.22
--- src/usr.sbin/installboot/arch/sun68k.c:1.21	Mon Apr 28 20:24:16 2008
+++ src/usr.sbin/installboot/arch/sun68k.c	Tue May  7 04:35:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun68k.c,v 1.21 2008/04/28 20:24:16 martin Exp $ */
+/*	$NetBSD: sun68k.c,v 1.22 2019/05/07 04:35:31 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if !defined(__lint)
-__RCSID("$NetBSD: sun68k.c,v 1.21 2008/04/28 20:24:16 martin Exp $");
+__RCSID("$NetBSD: sun68k.c,v 1.22 2019/05/07 04:35:31 thorpej Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -49,13 +49,21 @@ __RCSID("$NetBSD: sun68k.c,v 1.21 2008/0
 static int sun68k_clearboot(ib_params *);
 static int sun68k_setboot(ib_params *);
 
-struct ib_mach ib_mach_sun2 =
-	{ "sun2", sun68k_setboot, sun68k_clearboot, no_editboot,
-		IB_STAGE2START };
-
-struct ib_mach ib_mach_sun3 =
-	{ "sun3", sun68k_setboot, sun68k_clearboot, no_editboot,
-		IB_STAGE2START };
+struct ib_mach ib_mach_sun2 = {
+	.name		=	"sun2",
+	.setboot	=	sun68k_setboot,
+	.clearboot	=	sun68k_clearboot,
+	.editboot	=	no_editboot,
+	.valid_flags	=	IB_STAGE2START,
+};
+
+struct ib_mach ib_mach_sun3 = {
+	.name		=	"sun3",
+	.setboot	=	sun68k_setboot,
+	.clearboot	=	sun68k_clearboot,
+	.editboot	=	no_editboot,
+	.valid_flags	=	IB_STAGE2START,
+};
 
 static struct bbinfo_params bbparams = {
 	SUN68K_BBINFO_MAGIC,

Index: src/usr.sbin/installboot/arch/amiga.c
diff -u src/usr.sbin/installboot/arch/amiga.c:1.9 src/usr.sbin/installboot/arch/amiga.c:1.10
--- src/usr.sbin/installboot/arch/amiga.c:1.9	Fri Jun  5 05:02:48 2015
+++ src/usr.sbin/installboot/arch/amiga.c	Tue May  7 04:35:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: amiga.c,v 1.9 2015/06/05 05:02:48 mlelstv Exp $	*/
+/*	$NetBSD: amiga.c,v 1.10 2019/05/07 04:35:31 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include 
 #if !defined(__lint)
-__RCSID("$NetBSD: amiga.c,v 1.9 2015/06/05 05:02:48 mlelstv Exp $");
+__RCSID("$NetBSD: amiga.c,v 1.10 2019/05/07 04:35:31 thorpej Exp $");
 

CVS commit: src/usr.sbin/installboot/arch

2018-06-23 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 23 14:15:57 UTC 2018

Modified Files:
src/usr.sbin/installboot/arch: i386.c

Log Message:
Fix integer overflow in installboot(8)

Add a sanity check of the disk_buf first three bytes. The original code on
a disk with nul bytes was causing integer overflow and thus calling the
memcmp(3) functin in is_zero() with enormous length.

Verity that the 0th byte is JMP, 1th a signed byte >=9 to prevent overflow
and 2th byte NOP.

Add a comment explaining the check.

Detected with MKSANITIZER and ASan.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/installboot/arch/i386.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/i386.c
diff -u src/usr.sbin/installboot/arch/i386.c:1.40 src/usr.sbin/installboot/arch/i386.c:1.41
--- src/usr.sbin/installboot/arch/i386.c:1.40	Fri Jun 14 03:54:43 2013
+++ src/usr.sbin/installboot/arch/i386.c	Sat Jun 23 14:15:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: i386.c,v 1.40 2013/06/14 03:54:43 msaitoh Exp $ */
+/* $NetBSD: i386.c,v 1.41 2018/06/23 14:15:57 kamil Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if !defined(__lint)
-__RCSID("$NetBSD: i386.c,v 1.40 2013/06/14 03:54:43 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.41 2018/06/23 14:15:57 kamil Exp $");
 #endif /* !__lint */
 
 #include 
@@ -418,8 +418,19 @@ i386_setboot(ib_params *params)
 			return 0;
 		}
 
-		/* Find size of old BPB, and copy into new bootcode */
-		if (!is_zero(disk_buf.b + 3 + 8, disk_buf.b[1] - 1 - 8)) {
+		/*
+		 * Find size of old BPB, and copy into new bootcode
+		 *
+		 * The 2nd byte (b[1]) contains jmp short relative offset.
+		 * If it is zero or some invalid input that is smaller than 9,
+		 * it will cause overflow and call is_zero() with enormous size.
+		 * Add a paranoid check to prevent this scenario.
+		 *
+		 * Verify that b[0] contains JMP (0xeb) and b[2] NOP (0x90).
+		 */
+		if (disk_buf.b[0] == 0xeb && disk_buf.b[1] >= 9 &&
+		disk_buf.b[2] == 0x90 &&
+		!is_zero(disk_buf.b + 3 + 8, disk_buf.b[1] - 1 - 8)) {
 			struct mbr_bpbFAT16 *bpb = (void *)(disk_buf.b + 3 + 8);
 			/* Check enough space before the FAT for the bootcode */
 			u = le16toh(bpb->bpbBytesPerSec)



CVS commit: src/usr.sbin/installboot/arch

2017-07-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul 17 18:43:45 UTC 2017

Modified Files:
src/usr.sbin/installboot/arch: landisk.c

Log Message:
don't complain if the mbr was all 0's.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/installboot/arch/landisk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/landisk.c
diff -u src/usr.sbin/installboot/arch/landisk.c:1.6 src/usr.sbin/installboot/arch/landisk.c:1.7
--- src/usr.sbin/installboot/arch/landisk.c:1.6	Sat Oct 19 13:08:15 2013
+++ src/usr.sbin/installboot/arch/landisk.c	Mon Jul 17 14:43:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: landisk.c,v 1.6 2013/10/19 17:08:15 christos Exp $	*/
+/*	$NetBSD: landisk.c,v 1.7 2017/07/17 18:43:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if !defined(__lint)
-__RCSID("$NetBSD: landisk.c,v 1.6 2013/10/19 17:08:15 christos Exp $");
+__RCSID("$NetBSD: landisk.c,v 1.7 2017/07/17 18:43:45 christos Exp $");
 #endif /* !__lint */
 
 #include 
@@ -100,12 +100,18 @@ landisk_setboot(ib_params *params)
 		goto done;
 	}
 	if (mbr.mbr_magic != le16toh(MBR_MAGIC)) {
-		if (params->flags & IB_VERBOSE) {
-			printf(
-		"Ignoring MBR with invalid magic in sector 0 of `%s'\n",
-			params->filesystem);
+		const char *p = (const char *)
+		const char *e = p + sizeof(mbr);
+		while (p < e && !*p)
+			p++;
+		if (p != e) {
+			if (params->flags & IB_VERBOSE) {
+printf(
+			"Ignoring MBR with invalid magic in sector 0 of `%s'\n",
+params->filesystem);
+			}
+			memset(, 0, sizeof(mbr));
 		}
-		memset(, 0, sizeof(mbr));
 	}
 
 	/*



CVS commit: src/usr.sbin/installboot/arch

2015-06-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jun  5 05:02:48 UTC 2015

Modified Files:
src/usr.sbin/installboot/arch: amiga.c

Log Message:
Compute bootloader checksum correctly also on little endian systems.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/installboot/arch/amiga.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/amiga.c
diff -u src/usr.sbin/installboot/arch/amiga.c:1.8 src/usr.sbin/installboot/arch/amiga.c:1.9
--- src/usr.sbin/installboot/arch/amiga.c:1.8	Fri Jun 14 03:54:43 2013
+++ src/usr.sbin/installboot/arch/amiga.c	Fri Jun  5 05:02:48 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: amiga.c,v 1.8 2013/06/14 03:54:43 msaitoh Exp $	*/
+/*	$NetBSD: amiga.c,v 1.9 2015/06/05 05:02:48 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: amiga.c,v 1.8 2013/06/14 03:54:43 msaitoh Exp $);
+__RCSID($NetBSD: amiga.c,v 1.9 2015/06/05 05:02:48 mlelstv Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -126,8 +126,8 @@ amiga_setboot(ib_params *params)
 		}
 		(void)strncpy(dline, params-command, CMDLN_LEN-1);
 
-		block[1] = 0;
-		block[1] = 0x - chksum(block, sumlen);
+		block[1] = htobe32(0);
+		block[1] = htobe32(0x - chksum(block, sumlen));
 	}
 
 	if (params-flags  IB_NOWRITE) {
@@ -164,7 +164,7 @@ chksum(block, size)
 
 	for (i=0; isize; i++) {
 		lastsum = sum;
-		sum += htobe32(block[i]);
+		sum += be32toh(block[i]);
 		if (sum  lastsum)
 			++sum;
 	}



CVS commit: src/usr.sbin/installboot/arch

2014-11-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 13 16:02:25 UTC 2014

Modified Files:
src/usr.sbin/installboot/arch: vax.c

Log Message:
Use VAX_LABELOFFSET here; It needs to be the machine-specific one. Thanks
to gcc-4.8 for discovering the bug and to Atari for having a LABELOFFSET of
516  512 :-)
XXX: Perhaps we should put all those constants in sys/bootblock.h instead
of spreading them around.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/installboot/arch/vax.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/vax.c
diff -u src/usr.sbin/installboot/arch/vax.c:1.17 src/usr.sbin/installboot/arch/vax.c:1.18
--- src/usr.sbin/installboot/arch/vax.c:1.17	Sun Jun 16 15:05:00 2013
+++ src/usr.sbin/installboot/arch/vax.c	Thu Nov 13 11:02:25 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vax.c,v 1.17 2013/06/16 19:05:00 martin Exp $	*/
+/*	$NetBSD: vax.c,v 1.18 2014/11/13 16:02:25 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: vax.c,v 1.17 2013/06/16 19:05:00 martin Exp $);
+__RCSID($NetBSD: vax.c,v 1.18 2014/11/13 16:02:25 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -88,6 +88,8 @@ __RCSID($NetBSD: vax.c,v 1.17 2013/06/1
 
 #include installboot.h
 
+#define	VAX_LABELOFFSET		64
+
 #ifndef __CTASSERT
 #define	__CTASSERT(X)
 #endif
@@ -210,12 +212,12 @@ vax_setboot(ib_params *params)
 
 	/*
 	 * Copy disklabel from old boot block to new.
-	 * Assume everything between LABELOFFSET and the start of
+	 * Assume everything between VAX_LABELOFFSET and the start of
 	 * the param block is scratch area and can be copied over.
 	 */
-	memcpy(bootstrapbuf+LABELOFFSET,
-	oldbb+LABELOFFSET,
-	offsetof(struct vax_boot_block,bb_magic1)-LABELOFFSET);
+	memcpy(bootstrapbuf + VAX_LABELOFFSET,
+	oldbb + VAX_LABELOFFSET,
+	offsetof(struct vax_boot_block,bb_magic1) - VAX_LABELOFFSET);
 
 	/* point to bootblock at begining of bootstrap */
 	bb = (struct vax_boot_block*)bootstrapbuf;



CVS commit: src/usr.sbin/installboot/arch

2013-10-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Oct 21 15:37:46 UTC 2013

Modified Files:
src/usr.sbin/installboot/arch: pmax.c

Log Message:
XXX: gcc initialize a variable


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/installboot/arch/pmax.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/pmax.c
diff -u src/usr.sbin/installboot/arch/pmax.c:1.14 src/usr.sbin/installboot/arch/pmax.c:1.15
--- src/usr.sbin/installboot/arch/pmax.c:1.14	Sun Apr  5 07:55:39 2009
+++ src/usr.sbin/installboot/arch/pmax.c	Mon Oct 21 11:37:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmax.c,v 1.14 2009/04/05 11:55:39 lukem Exp $	*/
+/*	$NetBSD: pmax.c,v 1.15 2013/10/21 15:37:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: pmax.c,v 1.14 2009/04/05 11:55:39 lukem Exp $);
+__RCSID($NetBSD: pmax.c,v 1.15 2013/10/21 15:37:46 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -188,7 +188,7 @@ pmax_setboot(ib_params *params)
 	uint32_t		startblock;
 	int			retval;
 	char			*bootstrapbuf;
-	size_t			bootstrapsize;
+	size_t			bootstrapsize = 0;	/* XXX: gcc */
 	uint32_t		bootstrapload, bootstrapexec;
 	ssize_t			rv;
 



CVS commit: src/usr.sbin/installboot/arch

2013-10-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 19 17:08:15 UTC 2013

Modified Files:
src/usr.sbin/installboot/arch: landisk.c

Log Message:
move all the unused code inside #if 0


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/installboot/arch/landisk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/landisk.c
diff -u src/usr.sbin/installboot/arch/landisk.c:1.5 src/usr.sbin/installboot/arch/landisk.c:1.6
--- src/usr.sbin/installboot/arch/landisk.c:1.5	Thu May  7 03:03:39 2009
+++ src/usr.sbin/installboot/arch/landisk.c	Sat Oct 19 13:08:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: landisk.c,v 1.5 2009/05/07 07:03:39 lukem Exp $	*/
+/*	$NetBSD: landisk.c,v 1.6 2013/10/19 17:08:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: landisk.c,v 1.5 2009/05/07 07:03:39 lukem Exp $);
+__RCSID($NetBSD: landisk.c,v 1.6 2013/10/19 17:08:15 christos Exp $);
 #endif /* !__lint */
 
 #include sys/param.h
@@ -68,7 +68,6 @@ landisk_setboot(ib_params *params)
 	size_t bootstrapsize;
 	int retval, i;
 	uint32_t bplen;
-	int bpbsize;
 
 	assert(params != NULL);
 	assert(params-fsfd != -1);
@@ -149,11 +148,11 @@ landisk_setboot(ib_params *params)
 	 *	2b a0 11	jmp ENDOF(mbr_bpbFAT32)+1, nop
 	 *  (anything else)	; don't preserve
 	 */
-	bpbsize = 0;
 #if 0
+	int bpbsize;
 	if (bootstrapbuf[1] == 0xa0  bootstrapbuf[2] == 0x11 
 	(bootstrapbuf[0] == 0x2b /*|| bootstrapbuf[0] == 0x1d*/)) {
-		bpbsize = bootstrapbuf[0] + 2 - MBR_BPB_OFFSET;
+		 bpbsize = bootstrapbuf[0] + 2 - MBR_BPB_OFFSET;
 	}
 #endif
 



CVS commit: src/usr.sbin/installboot/arch

2013-06-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun 16 19:05:00 UTC 2013

Modified Files:
src/usr.sbin/installboot/arch: vax.c

Log Message:
In the tool build nbinclude/vax/disklabel.h is enough.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/installboot/arch/vax.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/vax.c
diff -u src/usr.sbin/installboot/arch/vax.c:1.16 src/usr.sbin/installboot/arch/vax.c:1.17
--- src/usr.sbin/installboot/arch/vax.c:1.16	Fri May  3 21:32:04 2013
+++ src/usr.sbin/installboot/arch/vax.c	Sun Jun 16 19:05:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vax.c,v 1.16 2013/05/03 21:32:04 matt Exp $	*/
+/*	$NetBSD: vax.c,v 1.17 2013/06/16 19:05:00 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -68,13 +68,12 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: vax.c,v 1.16 2013/05/03 21:32:04 matt Exp $);
+__RCSID($NetBSD: vax.c,v 1.17 2013/06/16 19:05:00 martin Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
 #ifdef HAVE_NBTOOL_CONFIG_H
 #include nbinclude/vax/disklabel.h
-#include nbinclude/sys/disklabel.h
 #else
 #include sys/disklabel.h
 #endif



CVS commit: src/usr.sbin/installboot/arch

2013-06-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jun 14 03:54:43 UTC 2013

Modified Files:
src/usr.sbin/installboot/arch: amiga.c hp300.c hp700.c i386.c next68k.c

Log Message:
Remove trailng whitespaces.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/installboot/arch/amiga.c \
src/usr.sbin/installboot/arch/next68k.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/installboot/arch/hp300.c
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/installboot/arch/hp700.c
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/installboot/arch/i386.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/amiga.c
diff -u src/usr.sbin/installboot/arch/amiga.c:1.7 src/usr.sbin/installboot/arch/amiga.c:1.8
--- src/usr.sbin/installboot/arch/amiga.c:1.7	Thu Jan 14 16:27:49 2010
+++ src/usr.sbin/installboot/arch/amiga.c	Fri Jun 14 03:54:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: amiga.c,v 1.7 2010/01/14 16:27:49 tsutsui Exp $	*/
+/*	$NetBSD: amiga.c,v 1.8 2013/06/14 03:54:43 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: amiga.c,v 1.7 2010/01/14 16:27:49 tsutsui Exp $);
+__RCSID($NetBSD: amiga.c,v 1.8 2013/06/14 03:54:43 msaitoh Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -76,7 +76,7 @@ amiga_setboot(ib_params *params)
 	char *dline;
 	int sumlen;
 	u_int32_t sum2, sum16;
-	
+
 	struct stat		bootstrapsb;
 
 	u_int32_t block[128*16];
Index: src/usr.sbin/installboot/arch/next68k.c
diff -u src/usr.sbin/installboot/arch/next68k.c:1.7 src/usr.sbin/installboot/arch/next68k.c:1.8
--- src/usr.sbin/installboot/arch/next68k.c:1.7	Thu Jan  7 13:26:00 2010
+++ src/usr.sbin/installboot/arch/next68k.c	Fri Jun 14 03:54:43 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: next68k.c,v 1.7 2010/01/07 13:26:00 tsutsui Exp $ */
+/* $NetBSD: next68k.c,v 1.8 2013/06/14 03:54:43 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: next68k.c,v 1.7 2010/01/07 13:26:00 tsutsui Exp $);
+__RCSID($NetBSD: next68k.c,v 1.8 2013/06/14 03:54:43 msaitoh Exp $);
 #endif /* !__lint */
 
 #include sys/param.h
@@ -154,7 +154,7 @@ next68k_setboot(ib_params *params)
 		goto done;
 	}
 
-	if (bootsize  be16toh(next68klabel-cd_front) * cd_secsize - 
+	if (bootsize  be16toh(next68klabel-cd_front) * cd_secsize -
 	NEXT68K_LABEL_SIZE) {
 		warnx(Boot program is larger than front porch space);
 		goto done;
@@ -174,7 +174,7 @@ next68k_setboot(ib_params *params)
 			/* can only fit one copy */
 			b0 = b1 = NEXT68K_LABEL_SIZE / cd_secsize;
 		else {
-			if (2 * bootsize  (fp * cd_secsize - 
+			if (2 * bootsize  (fp * cd_secsize -
 NEXT68K_LABEL_DEFAULTBOOT0_1 *
 params-sectorsize))
 /* can fit two copies starting after label */
@@ -230,7 +230,7 @@ next68k_setboot(ib_params *params)
 			goto done;
 		}
 	}
-	
+
 	b0 *= sec_netonb_mult;
 	b1 *= sec_netonb_mult;
 
@@ -247,7 +247,7 @@ next68k_setboot(ib_params *params)
 			goto done;
 		}
 		if ((size_t)rv != bootsize) {
-			warnx(Writing `%s' at %d: short write, 
+			warnx(Writing `%s' at %d: short write,
 			params-filesystem, b0);
 			goto done;
 		}

Index: src/usr.sbin/installboot/arch/hp300.c
diff -u src/usr.sbin/installboot/arch/hp300.c:1.14 src/usr.sbin/installboot/arch/hp300.c:1.15
--- src/usr.sbin/installboot/arch/hp300.c:1.14	Fri May  3 21:32:04 2013
+++ src/usr.sbin/installboot/arch/hp300.c	Fri Jun 14 03:54:43 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: hp300.c,v 1.14 2013/05/03 21:32:04 matt Exp $ */
+/* $NetBSD: hp300.c,v 1.15 2013/06/14 03:54:43 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: hp300.c,v 1.14 2013/05/03 21:32:04 matt Exp $);
+__RCSID($NetBSD: hp300.c,v 1.15 2013/06/14 03:54:43 msaitoh Exp $);
 #endif /* !__lint */
 
 /* We need the target disklabel.h, not the hosts one. */
@@ -43,7 +43,7 @@ __RCSID($NetBSD: hp300.c,v 1.14 2013/05
 #include nbtool_config.h
 #include nbinclude/hp300/disklabel.h
 #include nbinclude/sys/disklabel.h
-#else  
+#else
 #include sys/disklabel.h
 #endif
 #include sys/fcntl.h

Index: src/usr.sbin/installboot/arch/hp700.c
diff -u src/usr.sbin/installboot/arch/hp700.c:1.5 src/usr.sbin/installboot/arch/hp700.c:1.6
--- src/usr.sbin/installboot/arch/hp700.c:1.5	Mon Jan  9 11:44:53 2012
+++ src/usr.sbin/installboot/arch/hp700.c	Fri Jun 14 03:54:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: hp700.c,v 1.5 2012/01/09 11:44:53 skrll Exp $	*/
+/*	$NetBSD: hp700.c,v 1.6 2013/06/14 03:54:43 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -35,14 +35,14 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: hp700.c,v 1.5 

CVS commit: src/usr.sbin/installboot/arch

2013-05-03 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri May  3 21:32:05 UTC 2013

Modified Files:
src/usr.sbin/installboot/arch: hp300.c vax.c

Log Message:
Make this build with the disk label change.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/installboot/arch/hp300.c
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/installboot/arch/vax.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/hp300.c
diff -u src/usr.sbin/installboot/arch/hp300.c:1.13 src/usr.sbin/installboot/arch/hp300.c:1.14
--- src/usr.sbin/installboot/arch/hp300.c:1.13	Thu Feb 10 23:25:11 2011
+++ src/usr.sbin/installboot/arch/hp300.c	Fri May  3 21:32:04 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: hp300.c,v 1.13 2011/02/10 23:25:11 tsutsui Exp $ */
+/* $NetBSD: hp300.c,v 1.14 2013/05/03 21:32:04 matt Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,12 +35,13 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: hp300.c,v 1.13 2011/02/10 23:25:11 tsutsui Exp $);
+__RCSID($NetBSD: hp300.c,v 1.14 2013/05/03 21:32:04 matt Exp $);
 #endif /* !__lint */
 
 /* We need the target disklabel.h, not the hosts one. */
 #ifdef HAVE_NBTOOL_CONFIG_H
 #include nbtool_config.h
+#include nbinclude/hp300/disklabel.h
 #include nbinclude/sys/disklabel.h
 #else  
 #include sys/disklabel.h

Index: src/usr.sbin/installboot/arch/vax.c
diff -u src/usr.sbin/installboot/arch/vax.c:1.15 src/usr.sbin/installboot/arch/vax.c:1.16
--- src/usr.sbin/installboot/arch/vax.c:1.15	Thu Apr  4 16:11:12 2013
+++ src/usr.sbin/installboot/arch/vax.c	Fri May  3 21:32:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vax.c,v 1.15 2013/04/04 16:11:12 martin Exp $	*/
+/*	$NetBSD: vax.c,v 1.16 2013/05/03 21:32:04 matt Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -68,11 +68,16 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: vax.c,v 1.15 2013/04/04 16:11:12 martin Exp $);
+__RCSID($NetBSD: vax.c,v 1.16 2013/05/03 21:32:04 matt Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
+#ifdef HAVE_NBTOOL_CONFIG_H
+#include nbinclude/vax/disklabel.h
+#include nbinclude/sys/disklabel.h
+#else
 #include sys/disklabel.h
+#endif
 
 #include assert.h
 #include err.h



CVS commit: src/usr.sbin/installboot/arch

2013-04-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr  4 12:55:31 UTC 2013

Modified Files:
src/usr.sbin/installboot/arch: vax.c

Log Message:
Fix installboot for VAX, as discussed on port-vax. Problem pointed out
by Jonny Billquist, thanks to Marl Pizzolato for patiently explaining
the various ways of booting a vax to me.
Now VAX 780 can boot directly from VMB.EXE again.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/installboot/arch/vax.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/vax.c
diff -u src/usr.sbin/installboot/arch/vax.c:1.13 src/usr.sbin/installboot/arch/vax.c:1.14
--- src/usr.sbin/installboot/arch/vax.c:1.13	Sun Apr  5 11:55:39 2009
+++ src/usr.sbin/installboot/arch/vax.c	Thu Apr  4 12:55:30 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vax.c,v 1.13 2009/04/05 11:55:39 lukem Exp $	*/
+/*	$NetBSD: vax.c,v 1.14 2013/04/04 12:55:30 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -68,16 +68,18 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: vax.c,v 1.13 2009/04/05 11:55:39 lukem Exp $);
+__RCSID($NetBSD: vax.c,v 1.14 2013/04/04 12:55:30 martin Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
+#include sys/disklabel.h
 
 #include assert.h
 #include err.h
 #include stddef.h
 #include stdio.h
 #include stdlib.h
+#include string.h
 #include unistd.h
 
 #include installboot.h
@@ -101,7 +103,7 @@ vax_clearboot(ib_params *params)
 	assert(params != NULL);
 	assert(params-fsfd != -1);
 	assert(params-filesystem != NULL);
-	assert(sizeof(struct vax_boot_block) == VAX_BOOT_BLOCK_BLOCKSIZE);
+	__CTASSERT(sizeof(bb)==VAX_BOOT_BLOCK_BLOCKSIZE);
 
 	rv = pread(params-fsfd, bb, sizeof(bb), VAX_BOOT_BLOCK_OFFSET);
 	if (rv == -1) {
@@ -112,7 +114,7 @@ vax_clearboot(ib_params *params)
 		return (0);
 	}
 
-	if (bb.bb_id_offset * 2 != offsetof(struct vax_boot_block, bb_magic1)
+	if (bb.bb_id_offset*2 = VAX_BOOT_BLOCK_BLOCKSIZE
 	|| bb.bb_magic1 != VAX_BOOT_MAGIC1) {
 		warnx(
 		Old boot block magic number invalid; boot block invalid);
@@ -154,10 +156,10 @@ static int
 vax_setboot(ib_params *params)
 {
 	struct stat		bootstrapsb;
-	struct vax_boot_block	bb;
+	struct vax_boot_block	*bb;
 	uint32_t		startblock;
 	int			retval;
-	char			*bootstrapbuf;
+	char			*bootstrapbuf, oldbb[VAX_BOOT_BLOCK_BLOCKSIZE];
 	size_t			bootstrapsize;
 	uint32_t		bootstrapload, bootstrapexec;
 	ssize_t			rv;
@@ -167,8 +169,12 @@ vax_setboot(ib_params *params)
 	assert(params-filesystem != NULL);
 	assert(params-s1fd != -1);
 	assert(params-stage1 != NULL);
-	assert(sizeof(struct vax_boot_block) == VAX_BOOT_BLOCK_BLOCKSIZE);
 
+	/* see sys/arch/vax/boot/xxboot/start.S for explanation */
+	__CTASSERT(offsetof(struct vax_boot_block,bb_magic1) == 0x19e);
+	__CTASSERT(sizeof(struct vax_boot_block) == VAX_BOOT_BLOCK_BLOCKSIZE);
+
+	startblock = 0;
 	retval = 0;
 	bootstrapbuf = NULL;
 
@@ -184,16 +190,29 @@ vax_setboot(ib_params *params)
 	bootstrapexec, bootstrapsize))
 		goto done;
 
-	rv = pread(params-fsfd, bb, sizeof(bb), VAX_BOOT_BLOCK_OFFSET);
+	/* read old boot block */
+	rv = pread(params-fsfd, oldbb, sizeof(oldbb), VAX_BOOT_BLOCK_OFFSET);
 	if (rv == -1) {
 		warn(Reading `%s', params-filesystem);
 		goto done;
-	} else if (rv != sizeof(bb)) {
+	} else if (rv != sizeof(oldbb)) {
 		warnx(Reading `%s': short read, params-filesystem);
 		goto done;
 	}
 
-		/* fill in the updated boot block fields */
+	/*
+	 * Copy disklabel from old boot block to new.
+	 * Assume everything between LABELOFFSET and the start of
+	 * the param block is scratch area and can be copied over.
+	 */
+	memcpy(bootstrapbuf+LABELOFFSET,
+	oldbb+LABELOFFSET,
+	offsetof(struct vax_boot_block,bb_magic1)-LABELOFFSET);
+
+	/* point to bootblock at begining of bootstrap */
+	bb = (struct vax_boot_block*)bootstrapbuf;
+
+	/* fill in the updated boot block fields */
 	if (params-flags  IB_APPEND) {
 		struct stat	filesyssb;
 
@@ -209,46 +228,21 @@ vax_setboot(ib_params *params)
 		}
 		startblock = howmany(filesyssb.st_size,
 		VAX_BOOT_BLOCK_BLOCKSIZE);
-	} else if (params-flags  IB_STAGE1START) {
-		startblock = params-s1start;
-	} else {
-		startblock = VAX_BOOT_BLOCK_OFFSET / VAX_BOOT_BLOCK_BLOCKSIZE
-		+ 1;
+		bb-bb_lbn_hi = htole16((uint16_t) (startblock  16));
+		bb-bb_lbn_low = htole16((uint16_t) (startblock   0));
 	}
 
-	bb.bb_id_offset = offsetof(struct vax_boot_block, bb_magic1) / 2;
-	bb.bb_mbone = 1;
-	bb.bb_lbn_hi = htole16((uint16_t) (startblock  16));
-	bb.bb_lbn_low = htole16((uint16_t) (startblock   0));
-	/*
-	 * Now the identification block
-	 */
-	bb.bb_magic1 = VAX_BOOT_MAGIC1;
-	bb.bb_mbz1 = 0;
-	bb.bb_sum1 = ~(bb.bb_magic1 + bb.bb_mbz1 + bb.bb_pad1);
-
-	bb.bb_mbz2 = 0;
-	bb.bb_volinfo = VAX_BOOT_VOLINFO_NONE;
-	bb.bb_pad2a = 0;
-	bb.bb_pad2b = 0;
-
-	bb.bb_size = htole32(bootstrapsize / 

CVS commit: src/usr.sbin/installboot/arch

2013-04-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr  4 16:11:13 UTC 2013

Modified Files:
src/usr.sbin/installboot/arch: vax.c

Log Message:
Provide an empty __CTASSERT() for toolbuilds


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/installboot/arch/vax.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/vax.c
diff -u src/usr.sbin/installboot/arch/vax.c:1.14 src/usr.sbin/installboot/arch/vax.c:1.15
--- src/usr.sbin/installboot/arch/vax.c:1.14	Thu Apr  4 12:55:30 2013
+++ src/usr.sbin/installboot/arch/vax.c	Thu Apr  4 16:11:12 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vax.c,v 1.14 2013/04/04 12:55:30 martin Exp $	*/
+/*	$NetBSD: vax.c,v 1.15 2013/04/04 16:11:12 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: vax.c,v 1.14 2013/04/04 12:55:30 martin Exp $);
+__RCSID($NetBSD: vax.c,v 1.15 2013/04/04 16:11:12 martin Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -84,6 +84,10 @@ __RCSID($NetBSD: vax.c,v 1.14 2013/04/0
 
 #include installboot.h
 
+#ifndef __CTASSERT
+#define	__CTASSERT(X)
+#endif
+
 static int	load_bootstrap(ib_params *, char **,
 		uint32_t *, uint32_t *, size_t *);
 



CVS commit: src/usr.sbin/installboot/arch

2012-01-09 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan  9 11:44:54 UTC 2012

Modified Files:
src/usr.sbin/installboot/arch: hp700.c

Log Message:
Make it an error for the partition to exceed the PDC limit.

Inspired by PR/45742


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/installboot/arch/hp700.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/hp700.c
diff -u src/usr.sbin/installboot/arch/hp700.c:1.4 src/usr.sbin/installboot/arch/hp700.c:1.5
--- src/usr.sbin/installboot/arch/hp700.c:1.4	Mon Apr 28 20:24:16 2008
+++ src/usr.sbin/installboot/arch/hp700.c	Mon Jan  9 11:44:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: hp700.c,v 1.4 2008/04/28 20:24:16 martin Exp $	*/
+/*	$NetBSD: hp700.c,v 1.5 2012/01/09 11:44:53 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: hp700.c,v 1.4 2008/04/28 20:24:16 martin Exp $);
+__RCSID($NetBSD: hp700.c,v 1.5 2012/01/09 11:44:53 skrll Exp $);
 #endif	/* !__lint */
 
 /* We need the target disklabel.h, not the hosts one. */
@@ -178,9 +178,10 @@ hp700_setboot(ib_params *params)
 	} else if (be32toh(label.l.d_partitions[0].p_offset) +
 	be32toh(label.l.d_partitions[0].p_size) 
 	((unsigned)2*1024*1024*1024) / secsize) {
-		warnx(WARNING: Partition `a' of `%s' exceeds 2GB boundary.,
+		warnx(Partition `a' of `%s' exceeds 2GB boundary.,
 		params-filesystem);
-		warnx(WARNING: It won't boot since hp700 PDC can handle only 2GB.);
+		warnx(It won't boot since hp700 PDC can handle only 2GB.);
+		goto done;
 	}
 
 	/* read boot loader */



CVS commit: src/usr.sbin/installboot/arch

2011-02-10 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Feb 10 23:25:11 UTC 2011

Modified Files:
src/usr.sbin/installboot/arch: hp300.c

Log Message:
Fix botch in previous revision. Sorry for a stupid change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/installboot/arch/hp300.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/hp300.c
diff -u src/usr.sbin/installboot/arch/hp300.c:1.12 src/usr.sbin/installboot/arch/hp300.c:1.13
--- src/usr.sbin/installboot/arch/hp300.c:1.12	Thu Jan  7 13:26:00 2010
+++ src/usr.sbin/installboot/arch/hp300.c	Thu Feb 10 23:25:11 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hp300.c,v 1.12 2010/01/07 13:26:00 tsutsui Exp $ */
+/* $NetBSD: hp300.c,v 1.13 2011/02/10 23:25:11 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: hp300.c,v 1.12 2010/01/07 13:26:00 tsutsui Exp $);
+__RCSID($NetBSD: hp300.c,v 1.13 2011/02/10 23:25:11 tsutsui Exp $);
 #endif /* !__lint */
 
 /* We need the target disklabel.h, not the hosts one. */
@@ -108,7 +108,8 @@
 		 * The bootstrap can be well over 8k, and must go into a BOOT
 		 * partition. Read NetBSD label to locate BOOT partition.
 		 */
-		if (pread(params-fsfd, label, params-sectorsize, LABELSECTOR)
+		if (pread(params-fsfd, label, params-sectorsize,
+		LABELSECTOR * params-sectorsize)
 		!= (ssize_t)params-sectorsize) {
 			warn(reading disklabel);
 			goto done;



CVS commit: src/usr.sbin/installboot/arch

2009-10-26 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Oct 26 14:26:25 UTC 2009

Modified Files:
src/usr.sbin/installboot/arch: alpha.c

Log Message:
A checksum value in alpha boot block is stored in little endian,
so use le64toh() to print it on the host tool.
While here, use consistent (unsignd long long) casts on printing it.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/installboot/arch/alpha.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/arch/alpha.c
diff -u src/usr.sbin/installboot/arch/alpha.c:1.19 src/usr.sbin/installboot/arch/alpha.c:1.20
--- src/usr.sbin/installboot/arch/alpha.c:1.19	Sun Apr  5 11:55:39 2009
+++ src/usr.sbin/installboot/arch/alpha.c	Mon Oct 26 14:26:25 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: alpha.c,v 1.19 2009/04/05 11:55:39 lukem Exp $	*/
+/*	$NetBSD: alpha.c,v 1.20 2009/10/26 14:26:25 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: alpha.c,v 1.19 2009/04/05 11:55:39 lukem Exp $);
+__RCSID($NetBSD: alpha.c,v 1.20 2009/10/26 14:26:25 tsutsui Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -154,8 +154,8 @@
 	if (cksum != bb.bb_cksum) {		// XXX check bb_cksum endian?
 		warnx(
 	Old boot block checksum invalid (was %#llx, calculated %#llx),
-		(unsigned long long)bb.bb_cksum,
-		(unsigned long long)cksum);
+		(unsigned long long)le64toh(bb.bb_cksum),
+		(unsigned long long)le64toh(cksum));
 		warnx(Boot block invalid);
 		return (0);
 	}
@@ -166,7 +166,7 @@
 		printf(Old bootstrap size: %llu\n,
 		(unsigned long long)le64toh(bb.bb_secsize));
 		printf(Old bootstrap checksum: %#llx\n,
-		(unsigned long long)bb.bb_cksum);
+		(unsigned long long)le64toh(bb.bb_cksum));
 	}
 
 	bb.bb_secstart = bb.bb_secsize = bb.bb_flags = 0;
@@ -180,7 +180,7 @@
 	printf(New bootstrap size: %llu\n,
 	(unsigned long long)le64toh(bb.bb_secsize));
 	printf(New bootstrap checksum: %#llx\n,
-	(unsigned long long)bb.bb_cksum);
+	(unsigned long long)le64toh(bb.bb_cksum));
 
 	if (params-flags  IB_VERBOSE)
 		printf(%slearing boot block\n,
@@ -296,7 +296,7 @@
 		printf(Bootstrap sector count:  %llu\n,
 		(unsigned long long)le64toh(bb.bb_secsize));
 		printf(New boot block checksum: %#llx\n,
-		(unsigned long long)bb.bb_cksum);
+		(unsigned long long)le64toh(bb.bb_cksum));
 		printf(%sriting bootstrap\n,
 		(params-flags  IB_NOWRITE) ? Not w : W);
 	}
@@ -368,7 +368,8 @@
 	if (bb16 != NULL)
 		memcpy(bb16, bb, sizeof(*bb));
 	if ((params-flags  IB_VERBOSE)  lastsum != bb-bb_cksum)
-		printf(alpha checksum now %016llx\n, (long long)bb-bb_cksum);
+		printf(alpha checksum now %016llx\n,
+		(unsigned long long)le64toh(bb-bb_cksum));
 	lastsum = bb-bb_cksum;
 }
 
@@ -431,7 +432,7 @@
 	resum(params, bb, bb16);
 	if (params-flags  IB_VERBOSE)
 		printf(final harmonized checksum: %016llx\n,
-		(long long)bb-bb_cksum);
+		(unsigned long long)le64toh(bb-bb_cksum));
 	check_sparc(bb, Final);
 }