CVS commit: src/etc/etc.dreamcast

2021-02-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 25 07:58:39 UTC 2021

Modified Files:
src/etc/etc.dreamcast: MAKEDEV.conf

Log Message:
For ramdisk image, generate only 2 pairs of pty devices, instead of 16,
in order to save space further.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/etc/etc.dreamcast/MAKEDEV.conf

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

Modified files:

Index: src/etc/etc.dreamcast/MAKEDEV.conf
diff -u src/etc/etc.dreamcast/MAKEDEV.conf:1.7 src/etc/etc.dreamcast/MAKEDEV.conf:1.8
--- src/etc/etc.dreamcast/MAKEDEV.conf:1.7	Wed Nov 25 15:14:03 2020
+++ src/etc/etc.dreamcast/MAKEDEV.conf	Thu Feb 25 07:58:39 2021
@@ -1,4 +1,4 @@
-# $NetBSD: MAKEDEV.conf,v 1.7 2020/11/25 15:14:03 tsutsui Exp $
+# $NetBSD: MAKEDEV.conf,v 1.8 2021/02/25 07:58:39 rin Exp $
 
 all_md)
 	makedev wscons gdrom0 maple
@@ -10,7 +10,7 @@ all_md)
 
 ramdisk)
 	makedev std bpf md0 gdrom0
-	makedev scif0 sci0 opty
+	makedev scif0 sci0 ipty
 	makedev ttyE0 ttyEcfg wsmouse0 wskbd0 tun0 tun1 ipl
 	makedev wd0 wd1
 	;;



CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd

2021-02-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 25 07:55:53 UTC 2021

Modified Files:
src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile

Log Message:
For SMALLPROG, do not compile in IPv6 support unless SMALLPROG_INET6 is
defined, as in the same manner as other utilities.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile

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

Modified files:

Index: src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile
diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.54 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.55
--- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.54	Mon Jun 15 17:02:58 2020
+++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile	Thu Feb 25 07:55:53 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.54 2020/06/15 17:02:58 roy Exp $
+# $NetBSD: Makefile,v 1.55 2021/02/25 07:55:53 rin Exp $
 #
 
 WARNS?=		6
@@ -54,7 +54,7 @@ SRCS+=		ipv4ll.c
 .endif
 .endif
 
-.if (${USE_INET6} != "no")
+.if (!defined(SMALLPROG) || defined(SMALLPROG_INET6)) && (${USE_INET6} != "no")
 CPPFLAGS+=	-DINET6
 SRCS+=		ipv6.c ipv6nd.c
 # -DSMALL already strips out prefix delegation



CVS commit: othersrc/usr.bin/sleepto

2021-02-24 Thread Simon Burge
Module Name:othersrc
Committed By:   simonb
Date:   Thu Feb 25 07:52:27 UTC 2021

Modified Files:
othersrc/usr.bin/sleepto: parsetime.c
Added Files:
othersrc/usr.bin/sleepto: stime.h

Log Message:
Catch up on usr.bin/at/parsetime.c revs 1.16 to 1.20.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/usr.bin/sleepto/parsetime.c
cvs rdiff -u -r0 -r1.1 othersrc/usr.bin/sleepto/stime.h

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

Modified files:

Index: othersrc/usr.bin/sleepto/parsetime.c
diff -u othersrc/usr.bin/sleepto/parsetime.c:1.1 othersrc/usr.bin/sleepto/parsetime.c:1.2
--- othersrc/usr.bin/sleepto/parsetime.c:1.1	Thu Feb 25 07:03:57 2021
+++ othersrc/usr.bin/sleepto/parsetime.c	Thu Feb 25 07:52:27 2021
@@ -1,6 +1,6 @@
-/*	$NetBSD: parsetime.c,v 1.1 2021/02/25 07:03:57 simonb Exp $	*/
+/*	$NetBSD: parsetime.c,v 1.2 2021/02/25 07:52:27 simonb Exp $	*/
 
-/* 
+/*
  * parsetime.c - parse time for at(1)
  * Copyright (C) 1993, 1994  Thomas Koenig
  *
@@ -38,8 +38,10 @@
 /* System Headers */
 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -48,76 +50,94 @@
 #include 
 
 #include "parsetime.h"
+#include "stime.h"
 
 /* Structures and unions */
 
-enum {	/* symbols */
+typedef enum { /* symbols */
 	MIDNIGHT, NOON, TEATIME,
 	PM, AM, TOMORROW, TODAY, NOW,
-	MINUTES, HOURS, DAYS, WEEKS,
+	MINUTES, HOURS, DAYS, WEEKS, MONTHS, YEARS,
 	NUMBER, PLUS, DOT, SLASH, ID, JUNK,
 	JAN, FEB, MAR, APR, MAY, JUN,
 	JUL, AUG, SEP, OCT, NOV, DEC,
-	SUN, MON, TUE, WED, THU, FRI, SAT
-};
+	SUN, MON, TUE, WED, THU, FRI, SAT,
+	TOKEOF	/* EOF marker */
+} tokid_t;
 
 /*
  * parse translation table - table driven parsers can be your FRIEND!
  */
-struct {
+static const struct {
 	const char *name;	/* token name */
-	int value;		/* token id */
-	int plural;		/* is this plural? */
+	tokid_t value;		/* token id */
+	bool plural;		/* is this plural? */
 } Specials[] = {
-	{ "midnight", MIDNIGHT, 0 },	/* 00:00:00 of today or tomorrow */
-	{ "noon", NOON, 0 },		/* 12:00:00 of today or tomorrow */
-	{ "teatime", TEATIME, 0 },	/* 16:00:00 of today or tomorrow */
-	{ "am", AM, 0 },		/* morning times for 0-12 clock */
-	{ "pm", PM, 0 },		/* evening times for 0-12 clock */
-	{ "tomorrow", TOMORROW, 0 },	/* execute 24 hours from time */
-	{ "today", TODAY, 0 },		/* execute today - don't advance time */
-	{ "now", NOW, 0 },		/* opt prefix for PLUS */
-
-	{ "minute", MINUTES, 0 },	/* minutes multiplier */
-	{ "min", MINUTES, 0 },
-	{ "m", MINUTES, 0 },
-	{ "minutes", MINUTES, 1 },	/* (pluralized) */
-	{ "hour", HOURS, 0 },		/* hours ... */
-	{ "hr", HOURS, 0 },		/* abbreviated */
-	{ "h", HOURS, 0 },
-	{ "hours", HOURS, 1 },		/* (pluralized) */
-	{ "day", DAYS, 0 },		/* days ... */
-	{ "d", DAYS, 0 },
-	{ "days", DAYS, 1 },		/* (pluralized) */
-	{ "week", WEEKS, 0 },		/* week ... */
-	{ "w", WEEKS, 0 },
-	{ "weeks", WEEKS, 1 },		/* (pluralized) */
-	{ "jan", JAN, 0 },
-	{ "feb", FEB, 0 },
-	{ "mar", MAR, 0 },
-	{ "apr", APR, 0 },
-	{ "may", MAY, 0 },
-	{ "jun", JUN, 0 },
-	{ "jul", JUL, 0 },
-	{ "aug", AUG, 0 },
-	{ "sep", SEP, 0 },
-	{ "oct", OCT, 0 },
-	{ "nov", NOV, 0 },
-	{ "dec", DEC, 0 },
-	{ "sunday", SUN, 0 },
-	{ "sun", SUN, 0 },
-	{ "monday", MON, 0 },
-	{ "mon", MON, 0 },
-	{ "tuesday", TUE, 0 },
-	{ "tue", TUE, 0 },
-	{ "wednesday", WED, 0 },
-	{ "wed", WED, 0 },
-	{ "thursday", THU, 0 },
-	{ "thu", THU, 0 },
-	{ "friday", FRI, 0 },
-	{ "fri", FRI, 0 },
-	{ "saturday", SAT, 0 },
-	{ "sat", SAT, 0 },
+	{"midnight", MIDNIGHT, false},	/* 00:00:00 of today or tomorrow */
+	{"noon", NOON, false},		/* 12:00:00 of today or tomorrow */
+	{"teatime", TEATIME, false},	/* 16:00:00 of today or tomorrow */
+	{"am", AM, false},		/* morning times for 0-12 clock */
+	{"pm", PM, false},		/* evening times for 0-12 clock */
+	{"tomorrow", TOMORROW, false},	/* execute 24 hours from time */
+	{"today", TODAY, false},		/* execute today - don't advance time */
+	{"now", NOW, false},		/* opt prefix for PLUS */
+
+	{"minute", MINUTES, false},	/* minutes multiplier */
+	{"min", MINUTES, false},
+	{"m", MINUTES, false},
+	{"minutes", MINUTES, true},	/* (pluralized) */
+	{"hour", HOURS, false},		/* hours ... */
+	{"hr", HOURS, false},		/* abbreviated */
+	{"h", HOURS, false},
+	{"hours", HOURS, true},		/* (pluralized) */
+	{"day", DAYS, false},		/* days ... */
+	{"d", DAYS, false},
+	{"days", DAYS, true},		/* (pluralized) */
+	{"week", WEEKS, false},		/* week ... */
+	{"w", WEEKS, false},
+	{"weeks", WEEKS, true},		/* (pluralized) */
+	{ "month", MONTHS, 0 },		/* month ... */
+	{ "months", MONTHS, 1 },	/* (pluralized) */
+	{ "year", YEARS, 0 },		/* year ... */
+	{ "years", YEARS, 1 },		/* (pluralized) */
+	{"jan", JAN, false},
+	{"feb", FEB, false},
+	{"mar", MAR, false},
+	{"apr", APR, false},
+	{"may", MAY, false},
+	{"jun", JUN, false},
+	{"jul", JUL, false},
+	{"aug", AUG, false},
+	{"sep", SEP, 

CVS commit: othersrc/usr.bin/sleepto

2021-02-24 Thread Simon Burge
Module Name:othersrc
Committed By:   simonb
Date:   Thu Feb 25 07:03:57 UTC 2021

Added Files:
othersrc/usr.bin/sleepto: Makefile parsetime.c parsetime.h sleepto.c
tzfile.h

Log Message:
Jared's sleepto command from Dec 2007 - sleep to an at(1) style time
specification.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/usr.bin/sleepto/Makefile \
othersrc/usr.bin/sleepto/parsetime.c othersrc/usr.bin/sleepto/parsetime.h \
othersrc/usr.bin/sleepto/sleepto.c othersrc/usr.bin/sleepto/tzfile.h

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

Added files:

Index: othersrc/usr.bin/sleepto/Makefile
diff -u /dev/null othersrc/usr.bin/sleepto/Makefile:1.1
--- /dev/null	Thu Feb 25 07:03:57 2021
+++ othersrc/usr.bin/sleepto/Makefile	Thu Feb 25 07:03:57 2021
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2021/02/25 07:03:57 simonb Exp $
+
+PROG=	sleepto
+SRCS=	sleepto.c parsetime.c
+NOMAN=	# defined
+WARNS?=	4
+
+.include 
Index: othersrc/usr.bin/sleepto/parsetime.c
diff -u /dev/null othersrc/usr.bin/sleepto/parsetime.c:1.1
--- /dev/null	Thu Feb 25 07:03:57 2021
+++ othersrc/usr.bin/sleepto/parsetime.c	Thu Feb 25 07:03:57 2021
@@ -0,0 +1,673 @@
+/*	$NetBSD: parsetime.c,v 1.1 2021/02/25 07:03:57 simonb Exp $	*/
+
+/* 
+ * parsetime.c - parse time for at(1)
+ * Copyright (C) 1993, 1994  Thomas Koenig
+ *
+ * modifications for english-language times
+ * Copyright (C) 1993  David Parsons
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author(s) may not be used to endorse or promote
+ *products derived from this software without specific prior written
+ *permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  at [NOW] PLUS NUMBER MINUTES|HOURS|DAYS|WEEKS
+ * /NUMBER [DOT NUMBER] [AM|PM]\ /[MONTH NUMBER [NUMBER]] \
+ * |NOON   | |[TOMORROW]  |
+ * |MIDNIGHT   | |[DAY OF WEEK]   |
+ * \TEATIME/ |NUMBER [SLASH NUMBER [SLASH NUMBER]]|
+ *   \PLUS NUMBER MINUTES|HOURS|DAYS|WEEKS/
+ */
+
+/* System Headers */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "parsetime.h"
+
+/* Structures and unions */
+
+enum {	/* symbols */
+	MIDNIGHT, NOON, TEATIME,
+	PM, AM, TOMORROW, TODAY, NOW,
+	MINUTES, HOURS, DAYS, WEEKS,
+	NUMBER, PLUS, DOT, SLASH, ID, JUNK,
+	JAN, FEB, MAR, APR, MAY, JUN,
+	JUL, AUG, SEP, OCT, NOV, DEC,
+	SUN, MON, TUE, WED, THU, FRI, SAT
+};
+
+/*
+ * parse translation table - table driven parsers can be your FRIEND!
+ */
+struct {
+	const char *name;	/* token name */
+	int value;		/* token id */
+	int plural;		/* is this plural? */
+} Specials[] = {
+	{ "midnight", MIDNIGHT, 0 },	/* 00:00:00 of today or tomorrow */
+	{ "noon", NOON, 0 },		/* 12:00:00 of today or tomorrow */
+	{ "teatime", TEATIME, 0 },	/* 16:00:00 of today or tomorrow */
+	{ "am", AM, 0 },		/* morning times for 0-12 clock */
+	{ "pm", PM, 0 },		/* evening times for 0-12 clock */
+	{ "tomorrow", TOMORROW, 0 },	/* execute 24 hours from time */
+	{ "today", TODAY, 0 },		/* execute today - don't advance time */
+	{ "now", NOW, 0 },		/* opt prefix for PLUS */
+
+	{ "minute", MINUTES, 0 },	/* minutes multiplier */
+	{ "min", MINUTES, 0 },
+	{ "m", MINUTES, 0 },
+	{ "minutes", MINUTES, 1 },	/* (pluralized) */
+	{ "hour", HOURS, 0 },		/* hours ... */
+	{ "hr", HOURS, 0 },		/* abbreviated */
+	{ "h", HOURS, 0 },
+	{ "hours", HOURS, 1 },		/* (pluralized) */
+	{ "day", DAYS, 0 },		/* days ... */
+	{ "d", DAYS, 0 },
+	{ "days", DAYS, 1 },		/* (pluralized) */
+	{ "week", WEEKS, 0 },		/* week ... */
+	{ "w", WEEKS, 0 },
+	{ "weeks", WEEKS, 1 },		/* (pluralized) */
+	{ "jan", JAN, 0 },
+	{ "feb", FEB, 0 },
+	{ "mar", MAR, 0 },
+	{ "apr", APR, 0 },
+	{ "may", MAY, 0 },
+	{ "jun", JUN, 0 },
+	{ "jul", JUL, 0 },
+	{ "aug", AUG, 0 },
+	{ "sep", SEP, 0 },

CVS commit: src/usr.sbin/installboot

2021-02-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 25 03:44:28 UTC 2021

Modified Files:
src/usr.sbin/installboot: installboot.8

Log Message:
Adjust manpage for amiga/boot ver 3.1.

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.sbin/installboot/installboot.8

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/installboot.8
diff -u src/usr.sbin/installboot/installboot.8:1.100 src/usr.sbin/installboot/installboot.8:1.101
--- src/usr.sbin/installboot/installboot.8:1.100	Sat Feb  6 12:18:45 2021
+++ src/usr.sbin/installboot/installboot.8	Thu Feb 25 03:44:27 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: installboot.8,v 1.100 2021/02/06 12:18:45 rin Exp $
+.\"	$NetBSD: installboot.8,v 1.101 2021/02/25 03:44:27 rin Exp $
 .\"
 .\" Copyright (c) 2002-2019 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 6, 2021
+.Dd February 25, 2021
 .Dt INSTALLBOOT 8
 .Os
 .Sh NAME
@@ -741,7 +741,7 @@ Remove the primary bootstrap from disk
 .Ss Nx Ns /amiga
 Modify the command line to change the default from "netbsd -ASn2" to
 "netbsd -S":
-.Dl Ic installboot -m amiga -o command="netbsd -S" /dev/rsd0a /usr/mdec/bootxx_ffs
+.Dl Ic installboot -m amiga -o command="netbsd -S" /dev/rsd0a /usr/mdec/bootxx_ffsv1
 .
 .Ss Nx Ns /evbarm
 Install the



CVS commit: src/share/man/man8/man8.amiga

2021-02-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 25 03:43:57 UTC 2021

Modified Files:
src/share/man/man8/man8.amiga: boot.8 installboot.8

Log Message:
Adjust for amiga/boot ver 3.1.

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/share/man/man8/man8.amiga/boot.8
cvs rdiff -u -r1.23 -r1.24 src/share/man/man8/man8.amiga/installboot.8

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

Modified files:

Index: src/share/man/man8/man8.amiga/boot.8
diff -u src/share/man/man8/man8.amiga/boot.8:1.16 src/share/man/man8/man8.amiga/boot.8:1.17
--- src/share/man/man8/man8.amiga/boot.8:1.16	Sat Feb 18 21:47:11 2017
+++ src/share/man/man8/man8.amiga/boot.8	Thu Feb 25 03:43:57 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: boot.8,v 1.16 2017/02/18 21:47:11 wiz Exp $
+.\"	$NetBSD: boot.8,v 1.17 2021/02/25 03:43:57 rin Exp $
 .\"
 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
 .\" All rights reserved.
@@ -34,7 +34,7 @@
 .\"	From:
 .\"	@(#)boot_hp300.8	8.2 (Berkeley) 4/19/94
 .\"
-.Dd February 17, 2017
+.Dd February 25, 2021
 .Dt BOOT 8 amiga
 .Os
 .Sh NAME
@@ -233,11 +233,13 @@ filesystems such as bffs to access the
 .Nx
 root partition from AmigaOS.
 .Sh FILES
-.Bl -tag -width /usr/mdec/bootxx_ffs -compact
+.Bl -tag -width /usr/mdec/bootxx_ffsv1 -compact
 .It Pa /netbsd
 system kernel
-.It Pa /usr/mdec/bootxx_ffs
-RDB device primary boot block
+.It Pa /usr/mdec/bootxx_ffsv1
+RDB device primary boot block for FFSv1 (and ustarfs)
+.It Pa /usr/mdec/bootxx_ffsv2
+RDB device primary boot block for FFSv2
 .It Pa /usr/mdec/bootxx_fd
 floppy disk primary boot block
 .It Pa /usr/mdec/boot.amiga

Index: src/share/man/man8/man8.amiga/installboot.8
diff -u src/share/man/man8/man8.amiga/installboot.8:1.23 src/share/man/man8/man8.amiga/installboot.8:1.24
--- src/share/man/man8/man8.amiga/installboot.8:1.23	Mon Jul  3 21:31:00 2017
+++ src/share/man/man8/man8.amiga/installboot.8	Thu Feb 25 03:43:57 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: installboot.8,v 1.23 2017/07/03 21:31:00 wiz Exp $
+.\"	$NetBSD: installboot.8,v 1.24 2021/02/25 03:43:57 rin Exp $
 .\"
 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 17, 2017
+.Dd February 25, 2021
 .Dt INSTALLBOOT 8 amiga
 .Os
 .Sh NAME
@@ -69,27 +69,30 @@ filesystem code in
 to load the kernel from the filesystem on the partition it was started from.
 The code for the boot program can be found in
 .Pa /usr/mdec/bootxx_fd
-.Pq floppy disk code
+.Pq floppy disk code ,
+.Pa /usr/mdec/bootxx_ffsv1
+.Pq generic RDB disk code for FFSv1 ,
 or
-.Pa /usr/mdec/bootxx_ffs
-.Pq generic RDB disk code .
+.Pa /usr/mdec/bootxx_ffsv2
+.Pq generic RDB disk code for FFSv2 .
 .Pp
 The arguments are:
 .Bl -tag -width bootblock
 .It Fl l Ar newcommandline
 Specify a different command line to replace the default.
 .It Ar bootblock
-The file containing the bootblock (normally /usr/mdec/bootxx_ffs for RDB devices).
+The file containing the bootblock (normally /usr/mdec/bootxx_ffsv1 or
+bootxx_ffsv2 for RDB devices).
 .It Ar device
 The name of the character special device specifying the partition on which the
 bootstrap is to be installed.
 .El
 .Sh EXAMPLES
 The following command will install the
-boot program in the bootblock area on
+boot program for FFSv1 in the bootblock area on
 .Dq sd0a :
 .Bd -literal -offset indent
-installboot /usr/mdec/bootxx_ffs /dev/rsd0a
+installboot /usr/mdec/bootxx_ffsv1 /dev/rsd0a
 .Ed
 .Sh SEE ALSO
 .Xr dd 1 ,
@@ -122,8 +125,8 @@ There is currently no easy way to edit t
 .Nx .
 Therefore, you have to use HDTOOLBOX or a similar tool to
 set the partition to bootable, "use custom bootblocks" and the number
-of bootblocks to 16 (for bootxx_ffs) or 2 (for bootxx_fd), at least the first
-time you install the bootblock.
+of bootblocks to 16 (for bootxx_ffsv1 or bootxx_ffsv2) or 2 (for bootxx_fd),
+at least the first time you install the bootblock.
 .Pp
 As normal dd is used to install the bootblock, you can only install onto
 your currently used root (or any other mounted) partition from single-user



CVS commit: src/distrib/sets/lists/base

2021-02-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 25 03:43:00 UTC 2021

Modified Files:
src/distrib/sets/lists/base: md.amiga

Log Message:
Adjust for amiga/boot ver 3.1.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/distrib/sets/lists/base/md.amiga

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

Modified files:

Index: src/distrib/sets/lists/base/md.amiga
diff -u src/distrib/sets/lists/base/md.amiga:1.56 src/distrib/sets/lists/base/md.amiga:1.57
--- src/distrib/sets/lists/base/md.amiga:1.56	Wed Aug  6 12:15:01 2014
+++ src/distrib/sets/lists/base/md.amiga	Thu Feb 25 03:42:59 2021
@@ -1,8 +1,10 @@
-# $NetBSD: md.amiga,v 1.56 2014/08/06 12:15:01 martin Exp $
+# $NetBSD: md.amiga,v 1.57 2021/02/25 03:42:59 rin Exp $
 ./sbin/binpatch	base-sysutil-root
 ./usr/mdec/boot.amigabase-sysutil-bin
 ./usr/mdec/bootxx_fdbase-sysutil-bin
-./usr/mdec/bootxx_ffsbase-sysutil-bin
+./usr/mdec/bootxx_ffsbase-sysutil-bin	obsolete
+./usr/mdec/bootxx_ffsv1base-sysutil-bin
+./usr/mdec/bootxx_ffsv2base-sysutil-bin
 ./usr/mdec/fdbootbase-obsolete		obsolete
 ./usr/mdec/installbootbase-obsolete		obsolete
 ./usr/mdec/xxbootbase-obsolete		obsolete



CVS commit: src/sys/arch/amiga/stand/bootblock

2021-02-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 25 03:42:15 UTC 2021

Modified Files:
src/sys/arch/amiga/stand/bootblock: Makefile
src/sys/arch/amiga/stand/bootblock/boot: Makefile version xd.c
src/sys/arch/amiga/stand/bootblock/bootxx_ffs: Makefile
Added Files:
src/sys/arch/amiga/stand/bootblock/bootxx_ffsv2: Makefile

Log Message:
Add FFSv2 support for primary- and second-stage boot loaders.

Rename primary-stage boot for FFSv1 (and ustarfs) to bootxx_ffsv1 for clarity.

Bump version to 3.1.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amiga/stand/bootblock/Makefile
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/amiga/stand/bootblock/boot/Makefile
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amiga/stand/bootblock/boot/version
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amiga/stand/bootblock/boot/xd.c
cvs rdiff -u -r1.25 -r1.26 \
src/sys/arch/amiga/stand/bootblock/bootxx_ffs/Makefile
cvs rdiff -u -r0 -r1.1 \
src/sys/arch/amiga/stand/bootblock/bootxx_ffsv2/Makefile

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

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/Makefile:1.4 src/sys/arch/amiga/stand/bootblock/Makefile:1.5
--- src/sys/arch/amiga/stand/bootblock/Makefile:1.4	Tue Jul  6 05:59:57 2010
+++ src/sys/arch/amiga/stand/bootblock/Makefile	Thu Feb 25 03:42:14 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2010/07/06 05:59:57 mrg Exp $
+#	$NetBSD: Makefile,v 1.5 2021/02/25 03:42:14 rin Exp $
 
 .include 
 
@@ -9,7 +9,7 @@ SUBDIR+=elf2bb
 .endif
 
 # but these:
-SUBDIR+=boot bootxx_ffs
+SUBDIR+=boot bootxx_ffs bootxx_ffsv2
 
 
 .include 

Index: src/sys/arch/amiga/stand/bootblock/boot/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.56 src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.57
--- src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.56	Sun Apr  9 14:51:52 2017
+++ src/sys/arch/amiga/stand/bootblock/boot/Makefile	Thu Feb 25 03:42:14 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.56 2017/04/09 14:51:52 christos Exp $
+#	$NetBSD: Makefile,v 1.57 2021/02/25 03:42:14 rin Exp $
 
 .include 
 .include 		# for HOST_SH
@@ -40,7 +40,7 @@ BINDIR=/usr/mdec
 
 COBJS = main.o console.o xd.o twiddle.o bzero.o gets.o
 COBJS+=  lseek.o open.o read.o close.o dev.o errno.o
-COBJS+=  ufs.o ustarfs.o panic.o vers.o files.o
+COBJS+=  ufs.o ustarfs.o ffsv2.o panic.o vers.o files.o
 COBJS+=  divdi3.o moddi3.o qdivrem.o
 
 SOBJS = alloc.o ashrdi3.o ashldi3.o bcopy.o muldi3.o printf.o startit.o

Index: src/sys/arch/amiga/stand/bootblock/boot/version
diff -u src/sys/arch/amiga/stand/bootblock/boot/version:1.1 src/sys/arch/amiga/stand/bootblock/boot/version:1.2
--- src/sys/arch/amiga/stand/bootblock/boot/version:1.1	Mon Dec 17 05:41:13 2001
+++ src/sys/arch/amiga/stand/bootblock/boot/version	Thu Feb 25 03:42:14 2021
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.1 2001/12/17 05:41:13 mhitch Exp $
+$NetBSD: version,v 1.2 2021/02/25 03:42:14 rin Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -11,3 +11,4 @@ is taken as the current.
 2.3:	???
 2.4:	Moved default command into fixed location for easy patching
 3.0:	Initial 2 stage amiga bootblocks
+3.1:	Add support for FFSv2

Index: src/sys/arch/amiga/stand/bootblock/boot/xd.c
diff -u src/sys/arch/amiga/stand/bootblock/boot/xd.c:1.10 src/sys/arch/amiga/stand/bootblock/boot/xd.c:1.11
--- src/sys/arch/amiga/stand/bootblock/boot/xd.c:1.10	Sat Mar 14 21:04:04 2009
+++ src/sys/arch/amiga/stand/bootblock/boot/xd.c	Thu Feb 25 03:42:14 2021
@@ -1,5 +1,5 @@
 /*
- * $NetBSD: xd.c,v 1.10 2009/03/14 21:04:04 dsl Exp $
+ * $NetBSD: xd.c,v 1.11 2021/02/25 03:42:14 rin Exp $
  *
  * Copyright (c) 1996 Ignatios Souvatzis.
  * Copyright (c) 1995 Waldi Ravens.
@@ -53,8 +53,13 @@ struct devsw devsw[] = {
 };
 
 struct fs_ops file_system[] = {
+#if !defined(_PRIMARY_BOOT) || BOOTXX_FFS_VERSION == 1
 	FS_OPS(ufs),
 	FS_OPS(ustarfs),
+#endif
+#if !defined(_PRIMARY_BOOT) || BOOTXX_FFS_VERSION == 2
+	FS_OPS(ffsv2),
+#endif
 };
 
 int nfsys = sizeof(file_system)/sizeof(struct fs_ops);

Index: src/sys/arch/amiga/stand/bootblock/bootxx_ffs/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/bootxx_ffs/Makefile:1.25 src/sys/arch/amiga/stand/bootblock/bootxx_ffs/Makefile:1.26
--- src/sys/arch/amiga/stand/bootblock/bootxx_ffs/Makefile:1.25	Sun Apr  9 14:51:52 2017
+++ src/sys/arch/amiga/stand/bootblock/bootxx_ffs/Makefile	Thu Feb 25 03:42:14 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.25 2017/04/09 14:51:52 christos Exp $
+#	$NetBSD: Makefile,v 1.26 2021/02/25 03:42:14 rin Exp $
 
 .include 
 .include 
@@ -24,12 +24,21 @@ S=		${DIR_TOP}
 .SUFFIXES:
 .SUFFIXES: .out .o .po .pico .so .s .S .c .cc .C .f .y .l .ln .m4 .sh
 
-FILES= bootxx_ffs bootxx_fd
+.ifdef BOOTXX_FFSV2
+FILES=		bootxx_ffsv2

CVS commit: src/sys/arch/amiga/stand/bootblock/elf2bb

2021-02-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 25 03:40:27 UTC 2021

Modified Files:
src/sys/arch/amiga/stand/bootblock/elf2bb: elf2bb.c

Log Message:
For upcoming FFSv2 support for boot.amiga, dynamically scale its size,
instead of fixing to 32KB.

Old 32KB limit comes from

(1) all R_68K_PC16 symbols get relocated, and

(2) all values in our relocation table for R_68K_32 symbols fit within
16-bit integer.

(1) is already checked in the code. Assertion for (2) is added, but this
limit is satisfied with sufficient margin at the moment. If it is not the
case in the future, we may need to change format for relocation table.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c

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

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c
diff -u src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c:1.17 src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c:1.18
--- src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c:1.17	Thu Aug 20 15:54:12 2020
+++ src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c	Thu Feb 25 03:40:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2bb.c,v 1.17 2020/08/20 15:54:12 riastradh Exp $	*/
+/*	$NetBSD: elf2bb.c,v 1.18 2021/02/25 03:40:27 rin Exp $	*/
 
 /*-
  * Copyright (c) 1996,2006 The NetBSD Foundation, Inc.
@@ -33,6 +33,7 @@
 #include "nbtool_config.h"
 #endif
 
+#include 
 #include 
 
 #include 
@@ -111,6 +112,7 @@ main(int argc, char *argv[])
 	int undefsyms;
 	uint32_t tmp32;
 	uint16_t tmp16;
+	int Sflag = 0;
 
 	progname = argv[0];
 
@@ -122,7 +124,7 @@ main(int argc, char *argv[])
 		break;
 	case 'S':
 		/* Dynamically size second-stage boot */
-		sumsize = 0;
+		Sflag = 1;
 		break;
 	case 'd':
 		debug = 1;
@@ -155,7 +157,7 @@ main(int argc, char *argv[])
 		htobe16(eh->e_machine));
 
 	/* Calculate sizes from section headers. */
-	tsz = dsz = bsz = trsz = pcrelsz = r32sz = 0;
+	tsz = dsz = bsz = trsz = 0;
 	sh = (Elf32_Shdr *)(image + htobe32(eh->e_shoff));
 	shstrtab = (char *)(image + htobe32(sh[htobe16(eh->e_shstrndx)].sh_offset));
 	symtab = NULL;	/*XXX*/
@@ -201,31 +203,45 @@ main(int argc, char *argv[])
 
 	dprintf(("%d relocs\n", trsz/12));
 
-	if (sumsize == 0) {
+	if (Sflag) {
 		/*
-		 * XXX overly cautious, but this guarantees that 16bit
-		 * pc offsets and our relocs always work.
+		 * For second-stage boot, there's no limit for binary size,
+		 * and we dynamically scale it. However, it should be small
+		 * enough so that
+		 *
+		 *  (1) all R_68K_PC16 symbols get relocated, and
+		 *
+		 *  (2) all values in our relocation table for R_68K_32
+		 *  symbols fit within 16-bit integer.
+		 *
+		 * Both will be checked by codes below.
+		 *
+		 * At the moment, (2) is satisfied with sufficient margin.
+		 * But if it is not the case in the future, format for
+		 * relocation table should be modified.
 		 */
-		bbsize = 32768;
-		if (bbsize < (tsz + dsz + bsz)) {
-			errx(1, "%s: too big (%d < (%d + %d + %d))",
-			argv[0], bbsize, tsz, dsz, bsz);
-		}
+		bbsize = roundup(tsz + dsz, 512);
 		sumsize = bbsize / 512;
+	} else {
+		/*
+		 * We have one contiguous area allocated by the ROM to us.
+		 */
+		if (tsz + dsz + bsz > bbsize)
+			errx(1, "%s: resulting image too big %d+%d+%d=%d",
+			argv[0], tsz, dsz, bsz, tsz + dsz + bsz);
 	}
 
-	buffer = malloc(bbsize);
-	relbuf = (u_int32_t *)malloc(bbsize);
+	buffer = NULL;
+	relbuf = NULL;
+
+retry:
+	pcrelsz = r32sz = 0;
+
+	buffer = realloc(buffer, bbsize);
+	relbuf = realloc(relbuf, bbsize);
 	if (buffer == NULL || relbuf == NULL)
 		err(1, "Unable to allocate memory\n");
 
-	/*
-	 * We have one contiguous area allocated by the ROM to us.
-	 */
-	if (tsz+dsz+bsz > bbsize)
-		errx(1, "%s: resulting image too big %d+%d+%d=%d", argv[0],
-		tsz, dsz, bsz, tsz + dsz + bsz);
-
 	memset(buffer, 0, bbsize);
 
 	/* Allocate and load loadable sections */
@@ -363,7 +379,10 @@ main(int argc, char *argv[])
 		lptr = (u_int32_t *)[relbuf[i]];
 		addrdiff = relbuf[i] - oldaddr;
 		dprintf(("(0x%04x, 0x%04x): ", *lptr, addrdiff));
-		if (addrdiff > 255) {
+		if (addrdiff > 0x) {
+			errx(1, "addrdiff overflows: relbuf = 0x%08x, "
+			"oldaddr = 0x%08x, abort.\n", relbuf[i], oldaddr);
+		} else if (addrdiff > 0xff) {
 			*rpo = 0;
 			if (delta > 0) {
 ++rpo;
@@ -387,8 +406,16 @@ main(int argc, char *argv[])
 		oldaddr = relbuf[i];
 
 		if (delta < 0 ? rpo <= buffer+tsz+dsz
-		: rpo >= buffer + bbsize)
-			errx(1, "Relocs don't fit.");
+		: rpo >= buffer + bbsize) {
+			printf("relocs don't fit, ");
+			if (Sflag) {
+printf("retry.\n");
+bbsize += 512;
+sumsize++;
+goto retry;
+			} else
+errx(1, "abort.");
+		}
 	}
 	*rpo = 0; rpo += delta;
 	*rpo = 0; rpo += delta;
@@ -401,8 +428,16 @@ main(int argc, char *argv[])
 	 * RELOCs must fit into the bss area.
 	 */
 	if 

CVS commit: src/tests/lib/libcurses/tests

2021-02-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 25 01:07:43 UTC 2021

Modified Files:
src/tests/lib/libcurses/tests: addbytes addch

Log Message:
tests/libcurses: add test for '\b' in addch

Just to ensure that addch and addstr behave the same, after the recent
fix for handling '\t'.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/tests/addbytes
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/tests/addch

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

Modified files:

Index: src/tests/lib/libcurses/tests/addbytes
diff -u src/tests/lib/libcurses/tests/addbytes:1.3 src/tests/lib/libcurses/tests/addbytes:1.4
--- src/tests/lib/libcurses/tests/addbytes:1.3	Thu Feb 25 00:26:57 2021
+++ src/tests/lib/libcurses/tests/addbytes	Thu Feb 25 01:07:43 2021
@@ -1,4 +1,4 @@
-# $NetBSD: addbytes,v 1.3 2021/02/25 00:26:57 rillig Exp $
+# $NetBSD: addbytes,v 1.4 2021/02/25 01:07:43 rillig Exp $
 #
 # Tests adding bytes to stdscr.
 #
@@ -19,13 +19,15 @@ call2 0 16 getyx STDSCR
 call OK addbytes "\n" 1
 call2 1 0 getyx STDSCR
 
+# Ensure that backspace works as intended.
+# See tests/addch.
 call OK addbytes "12345\010" 6
 call2 1 4 getyx STDSCR
 
 call OK addbytes "\010\010\010\010" 4
 call2 1 0 getyx STDSCR
 
-# When curx is already 0, backspace is a no-op.
+# If curx is already 0, backspace is a no-op.
 call OK addbytes "\010" 1
 call2 1 0 getyx STDSCR
 

Index: src/tests/lib/libcurses/tests/addch
diff -u src/tests/lib/libcurses/tests/addch:1.7 src/tests/lib/libcurses/tests/addch:1.8
--- src/tests/lib/libcurses/tests/addch:1.7	Sun Feb 14 11:21:37 2021
+++ src/tests/lib/libcurses/tests/addch	Thu Feb 25 01:07:43 2021
@@ -1,4 +1,4 @@
-# $NetBSD: addch,v 1.7 2021/02/14 11:21:37 rillig Exp $
+# $NetBSD: addch,v 1.8 2021/02/25 01:07:43 rillig Exp $
 #
 # Between at least 2012 and 2016, addstr did not advance win->curx for a '\t',
 # but addch did.  This was inconsistent.
@@ -33,3 +33,29 @@ call OK addch `\000\n`
 
 call OK refresh
 compare addch.chk
+
+# Ensure that backspace works as intended.
+# See tests/addbytes.
+call OK move 1 0
+call OK addstr "12345"
+call OK addch `\000\010`
+call2 1 4 getyx STDSCR
+
+call OK addch `\000\010`
+call OK addch `\000\010`
+call OK addch `\000\010`
+call OK addch `\000\010`
+call2 1 0 getyx STDSCR
+
+# If curx is already 0, backspace is a no-op.
+call OK addch `\000\010`
+call2 1 0 getyx STDSCR
+
+call OK addstr "123"
+call OK addch `\000\t`
+call2 1 8 getyx STDSCR
+
+# Backspace affects the cursor position, no matter whether the previously
+# output char was a tab or a space.
+call OK addch `\000\010`
+call2 1 7 getyx STDSCR



CVS commit: src/tests/lib/libcurses/director

2021-02-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 25 00:50:10 UTC 2021

Modified Files:
src/tests/lib/libcurses/director: testlang_conf.l

Log Message:
tests/libcurses: use common style for parse error messages


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/tests/lib/libcurses/director/testlang_conf.l

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

Modified files:

Index: src/tests/lib/libcurses/director/testlang_conf.l
diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.24 src/tests/lib/libcurses/director/testlang_conf.l:1.25
--- src/tests/lib/libcurses/director/testlang_conf.l:1.24	Thu Feb 25 00:42:00 2021
+++ src/tests/lib/libcurses/director/testlang_conf.l	Thu Feb 25 00:50:10 2021
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: testlang_conf.l,v 1.24 2021/02/25 00:42:00 rillig Exp $ 	*/
+/*	$NetBSD: testlang_conf.l,v 1.25 2021/02/25 00:50:10 rillig Exp $ 	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -125,7 +125,8 @@ dequote(const char *s, size_t *len)
 			default:
 if (isalpha(*p))
 	errx(2,
-	"%s:%zu: invalid escape sequence '\\%c' in string literal",
+	"%s:%zu: Invalid escape sequence "
+	"'\\%c' in string literal",
 	cur_file, line, *p);
 *q++ = *p++;
 			}
@@ -182,10 +183,9 @@ include		BEGIN(incl);
 		char *inc_file;
 
 		if (include_ptr > MAX_INCLUDES) {
-			fprintf(stderr,
-"Maximum number of nested includes exceeded "
-"at line %zu of file %s\n", line, cur_file);
-exit(2);
+			errx(2,
+			"%s:%zu: Maximum number of nested includes "
+			"exceeded", cur_file, line);
 		}
 
 		const char *dir_begin;



CVS commit: src/tests/lib/libcurses/director

2021-02-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 25 00:42:00 UTC 2021

Modified Files:
src/tests/lib/libcurses/director: testlang_conf.l

Log Message:
tests/libcurses: use common syntax for accessing array elements

Writing *(p+1) is needlessly confusing, even though it adds a little
symmetry between *p and *(p+1).  Still, one of these expressions has
parentheses, the other doesn't, which breaks the symmetry.

Wrap overly long code line.

It's confusing to refer to the digits after the backslash once with
index 0 to 2, and the other time with index 1 to 3.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/tests/lib/libcurses/director/testlang_conf.l

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

Modified files:

Index: src/tests/lib/libcurses/director/testlang_conf.l
diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.23 src/tests/lib/libcurses/director/testlang_conf.l:1.24
--- src/tests/lib/libcurses/director/testlang_conf.l:1.23	Thu Feb 25 00:32:44 2021
+++ src/tests/lib/libcurses/director/testlang_conf.l	Thu Feb 25 00:42:00 2021
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: testlang_conf.l,v 1.23 2021/02/25 00:32:44 rillig Exp $ 	*/
+/*	$NetBSD: testlang_conf.l,v 1.24 2021/02/25 00:42:00 rillig Exp $ 	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -59,9 +59,8 @@ dequote(const char *s, size_t *len)
 	*len = 0;
 	p = (const unsigned char *)s;
 	while (*p) {
-		if (*p == '\\' && *(p+1)) {
-			if (isdigit(*(p+1)) && *(p+2) && isdigit(*(p+2)) &&
-			*(p+3) && isdigit(*(p+3)))
+		if (*p == '\\' && p[1]) {
+			if (isdigit(p[1]) && isdigit(p[2]) && isdigit(p[3]))
 p += 3;
 			else
 ++p;
@@ -77,13 +76,14 @@ dequote(const char *s, size_t *len)
 	p = (const unsigned char *)s;
 	q = buf;
 	while (*p) {
-		if (*p == '\\' && *(p+1)) {
+		if (*p == '\\' && p[1]) {
 			++p;
 
-			if (isdigit(*p)) {
-if (*(p+1) && isdigit(*(p+1)) && *(p+2) &&
-isdigit(*(p+2))) {
-	*q++ = ((*p - '0') * 8 + (*(p+1) - '0')) * 8 + (*(p+2) - '0');
+			if (isdigit(p[0])) {
+if (isdigit(p[1]) && isdigit(p[2])) {
+	*q++ = (p[0] - '0') * 64 +
+	(p[1] - '0') * 8 +
+	(p[2] - '0');
 	p += 3;
 } else {
 	*q++ = *p++;



CVS commit: src/tests/lib/libcurses/director

2021-02-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 25 00:32:44 UTC 2021

Modified Files:
src/tests/lib/libcurses/director: testlang_conf.l

Log Message:
tests/libcurses: reduce indentation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libcurses/director/testlang_conf.l

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

Modified files:

Index: src/tests/lib/libcurses/director/testlang_conf.l
diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.22 src/tests/lib/libcurses/director/testlang_conf.l:1.23
--- src/tests/lib/libcurses/director/testlang_conf.l:1.22	Thu Feb 25 00:25:31 2021
+++ src/tests/lib/libcurses/director/testlang_conf.l	Thu Feb 25 00:32:44 2021
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: testlang_conf.l,v 1.22 2021/02/25 00:25:31 rillig Exp $ 	*/
+/*	$NetBSD: testlang_conf.l,v 1.23 2021/02/25 00:32:44 rillig Exp $ 	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -79,6 +79,7 @@ dequote(const char *s, size_t *len)
 	while (*p) {
 		if (*p == '\\' && *(p+1)) {
 			++p;
+
 			if (isdigit(*p)) {
 if (*(p+1) && isdigit(*(p+1)) && *(p+2) &&
 isdigit(*(p+2))) {
@@ -87,45 +88,46 @@ dequote(const char *s, size_t *len)
 } else {
 	*q++ = *p++;
 }
-			} else {
-switch (*p) {
-case 'e':
-	/* escape */
-	*q++ = '\e';
-	p++;
-	break;
-
-case 'n':
-	/* newline */
-	*q++ = '\n';
-	p++;
-	break;
-
-case 'r':
-	/* carriage return */
-	*q++ = '\r';
-	p++;
-	break;
-
-case 't':
-	/* tab */
-	*q++ = '\t';
-	p++;
-	break;
-
-case '\\':
-	/* backslash */
-	*q++ = '\\';
-	p++;
-	break;
-
-default:
-	if (isalpha((unsigned char)*p))
-		errx(2,
-		"%s:%zu: invalid escape sequence '\\%c' in string literal",
-		cur_file, line, *p);
-	*q++ = *p++;
-}
+continue;
+			}
+
+			switch (*p) {
+			case 'e':
+/* escape */
+*q++ = '\e';
+p++;
+break;
+
+			case 'n':
+/* newline */
+*q++ = '\n';
+p++;
+break;
+
+			case 'r':
+/* carriage return */
+*q++ = '\r';
+p++;
+break;
+
+			case 't':
+/* tab */
+*q++ = '\t';
+p++;
+break;
+
+			case '\\':
+/* backslash */
+*q++ = '\\';
+p++;
+break;
+
+			default:
+if (isalpha(*p))
+	errx(2,
+	"%s:%zu: invalid escape sequence '\\%c' in string literal",
+	cur_file, line, *p);
+*q++ = *p++;
 			}
 		} else
 			*q++ = *p++;



CVS commit: src/tests/lib/libcurses/tests

2021-02-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 25 00:26:57 UTC 2021

Modified Files:
src/tests/lib/libcurses/tests: addbytes

Log Message:
libcurses: ensure that '\b' in handled correctly in addstr

Just to ensure that the recent fix for '\t' handling in addstr/addch
didn't introduce another bug.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/tests/addbytes

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

Modified files:

Index: src/tests/lib/libcurses/tests/addbytes
diff -u src/tests/lib/libcurses/tests/addbytes:1.2 src/tests/lib/libcurses/tests/addbytes:1.3
--- src/tests/lib/libcurses/tests/addbytes:1.2	Sat Feb 13 22:19:47 2021
+++ src/tests/lib/libcurses/tests/addbytes	Thu Feb 25 00:26:57 2021
@@ -1,4 +1,4 @@
-# $NetBSD: addbytes,v 1.2 2021/02/13 22:19:47 rillig Exp $
+# $NetBSD: addbytes,v 1.3 2021/02/25 00:26:57 rillig Exp $
 #
 # Tests adding bytes to stdscr.
 #
@@ -18,3 +18,21 @@ call2 0 16 getyx STDSCR
 
 call OK addbytes "\n" 1
 call2 1 0 getyx STDSCR
+
+call OK addbytes "12345\010" 6
+call2 1 4 getyx STDSCR
+
+call OK addbytes "\010\010\010\010" 4
+call2 1 0 getyx STDSCR
+
+# When curx is already 0, backspace is a no-op.
+call OK addbytes "\010" 1
+call2 1 0 getyx STDSCR
+
+call OK addbytes "123\t" 4
+call2 1 8 getyx STDSCR
+
+# Backspace affects the cursor position, no matter whether the previously
+# output char was a tab or a space.
+call OK addbytes "\010" 1
+call2 1 7 getyx STDSCR



CVS commit: src/tests/lib/libcurses

2021-02-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 25 00:25:31 UTC 2021

Modified Files:
src/tests/lib/libcurses/director: testlang_conf.l
src/tests/lib/libcurses/tests: addchstr

Log Message:
libcurses: prevent unknown escpae sequences in tests

Before, '\b' was interpreted as a simple 'b', which is confusing for C
programmers.  Same for '\a'.  There is absolutely no reason to escape
letters, so fail early in these cases.

The '\h' in the test addchstr was obviously a typo that was easy to
detect, if only the compiler had been strict enough from the very
beginning.

The code is wider than 80 characters, same as the code that parses octal
escape sequences a few lines above it.  This code will be refactored to
use less indentation in a follow-up commit.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/tests/lib/libcurses/director/testlang_conf.l
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/tests/addchstr

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

Modified files:

Index: src/tests/lib/libcurses/director/testlang_conf.l
diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.21 src/tests/lib/libcurses/director/testlang_conf.l:1.22
--- src/tests/lib/libcurses/director/testlang_conf.l:1.21	Mon Feb 15 07:06:27 2021
+++ src/tests/lib/libcurses/director/testlang_conf.l	Thu Feb 25 00:25:31 2021
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: testlang_conf.l,v 1.21 2021/02/15 07:06:27 rillig Exp $ 	*/
+/*	$NetBSD: testlang_conf.l,v 1.22 2021/02/25 00:25:31 rillig Exp $ 	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -120,6 +120,10 @@ dequote(const char *s, size_t *len)
 	break;
 
 default:
+	if (isalpha((unsigned char)*p))
+		errx(2,
+		"%s:%zu: invalid escape sequence '\\%c' in string literal",
+		cur_file, line, *p);
 	*q++ = *p++;
 }
 			}

Index: src/tests/lib/libcurses/tests/addchstr
diff -u src/tests/lib/libcurses/tests/addchstr:1.3 src/tests/lib/libcurses/tests/addchstr:1.4
--- src/tests/lib/libcurses/tests/addchstr:1.3	Sat Oct 24 04:46:17 2020
+++ src/tests/lib/libcurses/tests/addchstr	Thu Feb 25 00:25:31 2021
@@ -4,7 +4,7 @@ call OK refresh
 compare addchstr.chk
 call OK move 0 5
 call OK bkgdset `\002\000`
-call OK addchstr `\004f\004g\004\h`
+call OK addchstr `\004f\004g\004h`
 call OK refresh
 compare addchstr2.chk
 # check wrapping (should not wrap)



CVS commit: src/tests/lib/libc/regex

2021-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb 24 18:18:53 UTC 2021

Modified Files:
src/tests/lib/libc/regex: debug.c

Log Message:
remove casts


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/regex/debug.c

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

Modified files:

Index: src/tests/lib/libc/regex/debug.c
diff -u src/tests/lib/libc/regex/debug.c:1.5 src/tests/lib/libc/regex/debug.c:1.6
--- src/tests/lib/libc/regex/debug.c:1.5	Tue Feb 23 21:33:56 2021
+++ src/tests/lib/libc/regex/debug.c	Wed Feb 24 13:18:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.5 2021/02/24 02:33:56 christos Exp $	*/
+/*	$NetBSD: debug.c,v 1.6 2021/02/24 18:18:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993 The NetBSD Foundation, Inc.
@@ -64,9 +64,7 @@ regprint(regex_t *r, FILE *d)
 #ifndef REGEX_NODEBUG
 	struct re_guts *g = r->re_g;
 
-	fprintf(d, "%ld states, %zu ncsets", (long)g->nstates, g->ncsets);
-	fprintf(d, ", first %ld last %ld", (long)g->firststate,
-		(long)g->laststate);
+	fprintf(d, ", first %u last %u", g->firststate, g->laststate);
 	if (g->iflags)
 		fprintf(d, ", USEBOL");
 	if (g->iflags)
@@ -74,14 +72,13 @@ regprint(regex_t *r, FILE *d)
 	if (g->iflags)
 		fprintf(d, ", BAD");
 	if (g->nsub > 0)
-		fprintf(d, ", nsub=%ld", (long)g->nsub);
+		fprintf(d, ", nsub=%zu", g->nsub);
 	if (g->must != NULL)
-		fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen,
-g->must);
+		fprintf(d, ", must(%zu) `%*s'", g->mlen, (int)g->mlen, g->must);
 	if (g->backrefs)
 		fprintf(d, ", backrefs");
 	if (g->nplus > 0)
-		fprintf(d, ", nplus %ld", (long)g->nplus);
+		fprintf(d, ", nplus %u", g->nplus);
 	fprintf(d, "\n");
 	s_print(g, d);
 	fprintf(d, "\n");
@@ -144,63 +141,63 @@ s_print(struct re_guts *g, FILE *d)
 			fprintf(d, ".");
 			break;
 		case OANYOF:
-			fprintf(d, "[(%ld)", (long)opnd);
+			fprintf(d, "[(%u)", opnd);
 			fprintf(d, "]");
 			break;
 		case OBACK_:
-			fprintf(d, "(\\<%ld>", (long)opnd);
+			fprintf(d, "(\\<%u>", opnd);
 			break;
 		case O_BACK:
-			fprintf(d, "<%ld>\\)", (long)opnd);
+			fprintf(d, "<%u>\\)", opnd);
 			break;
 		case OPLUS_:
 			fprintf(d, "(+");
 			if (OP(*(s+opnd)) != O_PLUS)
-fprintf(d, "<%ld>", (long)opnd);
+fprintf(d, "<%u>", opnd);
 			break;
 		case O_PLUS:
 			if (OP(*(s-opnd)) != OPLUS_)
-fprintf(d, "<%ld>", (long)opnd);
+fprintf(d, "<%u>", opnd);
 			fprintf(d, "+)");
 			break;
 		case OQUEST_:
 			fprintf(d, "(?");
 			if (OP(*(s+opnd)) != O_QUEST)
-fprintf(d, "<%ld>", (long)opnd);
+fprintf(d, "<%u>", opnd);
 			break;
 		case O_QUEST:
 			if (OP(*(s-opnd)) != OQUEST_)
-fprintf(d, "<%ld>", (long)opnd);
+fprintf(d, "<%u>", opnd);
 			fprintf(d, "?)");
 			break;
 		case OLPAREN:
-			fprintf(d, "((<%ld>", (long)opnd);
+			fprintf(d, "((<%u>", opnd);
 			break;
 		case ORPAREN:
-			fprintf(d, "<%ld>))", (long)opnd);
+			fprintf(d, "<%u>))", opnd);
 			break;
 		case OCH_:
 			fprintf(d, "<");
-			if (OP(*(s+opnd)) != (sop)OOR2)
-fprintf(d, "<%ld>", (long)opnd);
+			if (OP(*(s+opnd)) != OOR2)
+fprintf(d, "<%u>", opnd);
 			break;
 		case OOR1:
-			if (OP(*(s-opnd)) != (sop)OOR1 && OP(*(s-opnd)) != (sop)OCH_)
-fprintf(d, "<%ld>", (long)opnd);
+			if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_)
+fprintf(d, "<%u>", opnd);
 			fprintf(d, "|");
 			break;
 		case OOR2:
 			fprintf(d, "|");
-			if (OP(*(s+opnd)) != (sop)OOR2 && OP(*(s+opnd)) != (sop)O_CH)
-fprintf(d, "<%ld>", (long)opnd);
+			if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH)
+fprintf(d, "<%u>", opnd);
 			break;
 		case O_CH:
-			if (OP(*(s-opnd)) != (sop)OOR1)
-fprintf(d, "<%ld>", (long)opnd);
+			if (OP(*(s-opnd)) != OOR1)
+fprintf(d, "<%u>", opnd);
 			fprintf(d, ">");
 			break;
 		default:
-			fprintf(d, "!%ld(%ld)!", (long)OP(*s), (long)opnd);
+			fprintf(d, "!%u(%u)!", OP(*s), opnd);
 			break;
 		}
 		if (!done)



CVS commit: src/lib/libc/regex

2021-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb 24 18:13:21 UTC 2021

Modified Files:
src/lib/libc/regex: engine.c regcomp.c regex2.h regexec.c regfree.c

Log Message:
reduce casts


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/regex/engine.c
cvs rdiff -u -r1.39 -r1.40 src/lib/libc/regex/regcomp.c
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/regex/regex2.h
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/regex/regexec.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/regex/regfree.c

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

Modified files:

Index: src/lib/libc/regex/engine.c
diff -u src/lib/libc/regex/engine.c:1.26 src/lib/libc/regex/engine.c:1.27
--- src/lib/libc/regex/engine.c:1.26	Wed Feb 24 04:10:12 2021
+++ src/lib/libc/regex/engine.c	Wed Feb 24 13:13:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: engine.c,v 1.26 2021/02/24 09:10:12 wiz Exp $ */
+/* $NetBSD: engine.c,v 1.27 2021/02/24 18:13:21 christos Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
@@ -41,7 +41,7 @@
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/lib/libc/regex/engine.c 368358 2020-12-05 03:16:05Z kevans $");
 #endif
-__RCSID("$NetBSD: engine.c,v 1.26 2021/02/24 09:10:12 wiz Exp $");
+__RCSID("$NetBSD: engine.c,v 1.27 2021/02/24 18:13:21 christos Exp $");
 
 #include 
 
@@ -210,7 +210,7 @@ matcher(struct re_guts *g,
 	const char *stop;
 	/* Boyer-Moore algorithms variables */
 	const char *pp;
-	int cj, mj;
+	size_t cj, mj;
 	const char *mustfirst;
 	const char *mustlast;
 	size_t *matchjump;
@@ -325,7 +325,7 @@ matcher(struct re_guts *g,
 break;
 			assert(m->coldp < m->endp);
 			m->coldp += XMBRTOWC(NULL, m->coldp,
-			m->endp - m->coldp, >mbs, 0);
+			(size_t)(m->endp - m->coldp), >mbs, 0);
 		}
 		if (nmatch == 1 && !g->backrefs)
 			break;		/* no further info needed */
@@ -385,7 +385,7 @@ matcher(struct re_guts *g,
 		NOTE("false alarm");
 		/* recycle starting later */
 		start = m->coldp + XMBRTOWC(NULL, m->coldp,
-		stop - m->coldp, >mbs, 0);
+		(size_t)(stop - m->coldp), >mbs, 0);
 		assert(start <= stop);
 	}
 
@@ -412,7 +412,7 @@ done:
 		m->pmatch = NULL;
 	}
 	if (m->lastpos != NULL) {
-		free((char *)m->lastpos);
+		free(__UNCONST(m->lastpos));
 		m->lastpos = NULL;
 	}
 	STATETEARDOWN(m);
@@ -461,7 +461,7 @@ dissect(
 			es += OPND(m->g->strip[es]);
 			break;
 		case OCH_:
-			while (OP(m->g->strip[es]) != (sop)O_CH)
+			while (OP(m->g->strip[es]) != O_CH)
 es += OPND(m->g->strip[es]);
 			break;
 		}
@@ -473,7 +473,8 @@ dissect(
 			assert(nope);
 			break;
 		case OCHAR:
-			sp += XMBRTOWC(NULL, sp, stop - start, >mbs, 0);
+			sp += XMBRTOWC(NULL, sp, (size_t)(stop - start),
+			>mbs, 0);
 			break;
 		case OBOL:
 		case OEOL:
@@ -486,7 +487,8 @@ dissect(
 			break;
 		case OANY:
 		case OANYOF:
-			sp += XMBRTOWC(NULL, sp, stop - start, >mbs, 0);
+			sp += XMBRTOWC(NULL, sp, (size_t)(stop - start),
+			>mbs, 0);
 			break;
 		case OBACK_:
 		case O_BACK:
@@ -579,7 +581,7 @@ dissect(
 assert(OP(m->g->strip[esub]) == OOR2);
 ssub = esub + 1;
 esub += OPND(m->g->strip[esub]);
-if (OP(m->g->strip[esub]) == (sop)OOR2)
+if (OP(m->g->strip[esub]) == OOR2)
 	esub--;
 else
 	assert(OP(m->g->strip[esub]) == O_CH);
@@ -669,14 +671,16 @@ backref(
 		case OCHAR:
 			if (sp == stop)
 return(NULL);
-			sp += XMBRTOWC(, sp, stop - sp, >mbs, BADCHAR);
+			sp += XMBRTOWC(, sp, (size_t)(stop - sp),
+			>mbs, BADCHAR);
 			if (wc != (wint_t)OPND(s))
 return(NULL);
 			break;
 		case OANY:
 			if (sp == stop)
 return(NULL);
-			sp += XMBRTOWC(, sp, stop - sp, >mbs, BADCHAR);
+			sp += XMBRTOWC(, sp, (size_t)(stop - sp),
+			>mbs, BADCHAR);
 			if (wc == BADCHAR)
 return (NULL);
 			break;
@@ -684,7 +688,8 @@ backref(
 			if (sp == stop)
 return (NULL);
 			cs = >g->sets[OPND(s)];
-			sp += XMBRTOWC(, sp, stop - sp, >mbs, BADCHAR);
+			sp += XMBRTOWC(, sp, (size_t)(stop - sp),
+			>mbs, BADCHAR);
 			if (wc == BADCHAR || !CHIN(cs, wc))
 return(NULL);
 			break;
@@ -751,7 +756,7 @@ backref(
 			do {
 assert(OP(s) == OOR2);
 ss += OPND(s);
-			} while (OP(s = m->g->strip[ss]) != (sop)O_CH);
+			} while (OP(s = m->g->strip[ss]) != O_CH);
 			/* note that the ss++ gets us past the O_CH */
 			break;
 		default:	/* have to make a choice */
@@ -784,7 +789,7 @@ backref(
 		ssp = m->offp + m->pmatch[i].rm_so;
 		if (memcmp(sp, ssp, len) != 0)
 			return(NULL);
-		while (m->g->strip[ss] != (sop)SOP(O_BACK, i))
+		while (m->g->strip[ss] != SOP(O_BACK, i))
 			ss++;
 		return(backref(m, sp+len, stop, ss+1, stopst, lev, rec));
 	case OQUEST_:		/* to null or not */
@@ -816,13 +821,13 @@ backref(
 			if (dp != NULL)
 return(dp);
 			/* that one missed, try next one */
-			if (OP(m->g->strip[esub]) == (sop)O_CH)
+			if (OP(m->g->strip[esub]) == O_CH)
 return(NULL);	/* there is none */
 			esub++;
-			assert(OP(m->g->strip[esub]) == 

CVS commit: src/sys/arch/powerpc/oea

2021-02-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Feb 24 17:35:40 UTC 2021

Modified Files:
src/sys/arch/powerpc/oea: ofw_subr.S

Log Message:
- Fix a comment.
- rename ofwsrsave to clsrsave; we're saving / restoring the client's
  (i.e. kernel's) SRs there, not the firmware's.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/powerpc/oea/ofw_subr.S

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

Modified files:

Index: src/sys/arch/powerpc/oea/ofw_subr.S
diff -u src/sys/arch/powerpc/oea/ofw_subr.S:1.18 src/sys/arch/powerpc/oea/ofw_subr.S:1.19
--- src/sys/arch/powerpc/oea/ofw_subr.S:1.18	Wed Feb 24 16:53:00 2021
+++ src/sys/arch/powerpc/oea/ofw_subr.S	Wed Feb 24 17:35:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.S,v 1.18 2021/02/24 16:53:00 thorpej Exp $	*/
+/*	$NetBSD: ofw_subr.S,v 1.19 2021/02/24 17:35:39 thorpej Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -47,10 +47,10 @@
 	/* Entry trampoline used by openfirmware(). */
 	.lcomm	oftramp,4,4
 
-	/* OpenFirmware SR save area */
-	.lcomm	ofwsrsave,64,4
+	/* Client SR save area */
+	.lcomm	clsrsave,64,4
 
-	/* MSR and SPRG[0-3] used in OpenFirmware */
+	/* MSR used in OpenFirmware */
 	.globl	ofwmsr
 	.comm	ofwmsr,4,4
 
@@ -173,8 +173,8 @@ ENTRY_NOPROFILE(openfirmware_trampoline)
 	mtibatu	3,%r0
 #endif /* PPC_OEA */
 
-	lis	%r4,ofwsrsave@ha		/* save current SRs */
-	addi	%r4,%r4,ofwsrsave@l
+	lis	%r4,clsrsave@ha		/* save current SRs */
+	addi	%r4,%r4,clsrsave@l
 	li	%r5,0
 1:	mfsrin	%r0,%r5
 	stw	%r0,0(%r4)
@@ -215,8 +215,8 @@ ENTRY_NOPROFILE(openfirmware_trampoline)
 	addi	%r5,%r5,_C_LABEL(battable)@l
 	stw	%r5,CI_BATTABLE(%r4)
 
-	lis	%r4,ofwsrsave@ha	/* restore saved SRs */
-	addi	%r4,%r4,ofwsrsave@l
+	lis	%r4,clsrsave@ha		/* restore saved SRs */
+	addi	%r4,%r4,clsrsave@l
 	li	%r5,0
 1:	lwz	%r0,0(%r4)
 	mtsrin	%r0,%r5



CVS commit: src/sys/arch/powerpc/oea

2021-02-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Feb 24 16:53:00 UTC 2021

Modified Files:
src/sys/arch/powerpc/oea: ofw_subr.S ofwoea_machdep.c

Log Message:
Don't save the firmware's copy of SPRG[0-3], and don't fiddle with
SPRG[0-3] in the firmware trampoline.  Section 7.1 of the OpenFirmware
PowerPC CPU bindings says that firmware "client interface shall not modify"
when in virtual-mode, and "client interface shall preserve" in real-mode.

This is important because in vritual-mode, DSI exceptions will land in
the kernel's DSI exception handler, and that handler depends on the
kernel's SPRG0 value (it contains the pointer to the cpu_info for that
CPU).

Additionally, in the firmware trampoline, point curcpu at an empty
ofw_battable.  This ensures that the DSI exception handler won't
load a BAT register with a kernel block translation that clobbers
a segment translation owned by the firmware.  Eventually, this ofw_battable
might contain some of the larger translations owned by the firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/powerpc/oea/ofw_subr.S
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/powerpc/oea/ofwoea_machdep.c

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

Modified files:

Index: src/sys/arch/powerpc/oea/ofw_subr.S
diff -u src/sys/arch/powerpc/oea/ofw_subr.S:1.17 src/sys/arch/powerpc/oea/ofw_subr.S:1.18
--- src/sys/arch/powerpc/oea/ofw_subr.S:1.17	Fri Feb 19 18:03:21 2021
+++ src/sys/arch/powerpc/oea/ofw_subr.S	Wed Feb 24 16:53:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.S,v 1.17 2021/02/19 18:03:21 thorpej Exp $	*/
+/*	$NetBSD: ofw_subr.S,v 1.18 2021/02/24 16:53:00 thorpej Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 
 	/* MSR and SPRG[0-3] used in OpenFirmware */
 	.globl	ofwmsr
-	.comm	ofwmsr,20,4
+	.comm	ofwmsr,4,4
 
 #ifdef FIRMWORKSBUGS
 	.lcomm	ofwreal_incharge,4,4
@@ -101,16 +101,7 @@ ENTRY_NOPROFILE(ofwinit)
 	/* Save the MSR that OpenFirmware is using. */
 	mfmsr	%r0
 	lis	%r9,ofwmsr@ha
-	stwu	%r0,ofwmsr@l(%r9)
-
-	mfsprg0	%r0/* save SPRGs */
-	stw	%r0,4(%r9)
-	mfsprg1	%r0
-	stw	%r0,8(%r9)
-	mfsprg2	%r0
-	stw	%r0,12(%r9)
-	mfsprg3	%r0
-	stw	%r0,16(%r9)
+	stw	%r0,ofwmsr@l(%r9)
 
 	lis	%r8,OF_buffer@ha
 	addi	%r8,%r8,OF_buffer@l
@@ -161,15 +152,6 @@ ENTRY_NOPROFILE(openfirmware_trampoline)
 	lwz	%r4,ofentry@l(%r4)
 	mtlr	%r4
 
-	mfsprg0	%r5			/* save current sprg0 (curcpu) */
-	stw	%r5,16(%r1)
-	mfsprg1	%r5			/* save current sprg1 */
-	stw	%r5,20(%r1)
-	mfsprg2	%r5			/* save current sprg1 */
-	stw	%r5,24(%r1)
-	mfsprg3	%r5			/* save current sprg3 */
-	stw	%r5,28(%r1)
-
 #ifdef FIRMWORKSBUGS
 	lis	%r4,ofwreal_incharge@ha
 	lwz	%r4,ofwreal_incharge@l(%r4)
@@ -214,21 +196,25 @@ ENTRY_NOPROFILE(openfirmware_trampoline)
 	cmpwi	%r5,0
 	bne	1b
 2:
-	lis	%r4,ofwmsr+16@ha	/* Open Firmware msr + sprg[0-3] */
-	lwzu	%r5,ofwmsr+16@l(%r4)
-	mtsprg3	%r5
-	lwz	%r5,-4(%r4)
-	mtsprg2	%r5
-	lwz	%r5,-8(%r4)
-	mtsprg1	%r5
-	lwz	%r5,-12(%r4)
-	mtsprg0	%r5
-	lwz	%r5,-16(%r4)
+	/* curcpu()->ci_battable = _battable */
+	GET_CPUINFO(%r4)
+	lis	%r5,_C_LABEL(ofw_battable)@ha
+	addi	%r5,%r5,_C_LABEL(ofw_battable)@l
+	stw	%r5,CI_BATTABLE(%r4)
+
+	lis	%r4,ofwmsr@ha		/* Open Firmware msr */
+	lwz	%r5,ofwmsr@l(%r4)
 	mtmsr	%r5
 	isync
 
 	blrl/* call Open Firmware */
 
+	/* curcpu()->ci_battable =  */
+	GET_CPUINFO(%r4)
+	lis	%r5,_C_LABEL(battable)@ha
+	addi	%r5,%r5,_C_LABEL(battable)@l
+	stw	%r5,CI_BATTABLE(%r4)
+
 	lis	%r4,ofwsrsave@ha	/* restore saved SRs */
 	addi	%r4,%r4,ofwsrsave@l
 	li	%r5,0
@@ -243,15 +229,6 @@ ENTRY_NOPROFILE(openfirmware_trampoline)
 	mtmsr	%r4
 	isync
 4:	
-	lwz	%r5,16(%r1)		/* restore saved sprgs (curcpu) */
-	mtsprg0	%r5
-	lwz	%r5,20(%r1)
-	mtsprg1	%r5
-	lwz	%r5,24(%r1)
-	mtsprg2	%r5
-	lwz	%r5,28(%r1)
-	mtsprg3	%r5
-
 	addi	%r1,%r1,48		/* pop stack frame and save area */
 	lwz	%r0,4(%r1)		/* return address */
 	mtlr	%r0

Index: src/sys/arch/powerpc/oea/ofwoea_machdep.c
diff -u src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.53 src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.54
--- src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.53	Fri Feb 19 18:10:51 2021
+++ src/sys/arch/powerpc/oea/ofwoea_machdep.c	Wed Feb 24 16:53:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ofwoea_machdep.c,v 1.53 2021/02/19 18:10:51 thorpej Exp $ */
+/* $NetBSD: ofwoea_machdep.c,v 1.54 2021/02/24 16:53:00 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.53 2021/02/19 18:10:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.54 2021/02/24 16:53:00 thorpej Exp $");
 
 #include "ksyms.h"
 #include "wsdisplay.h"
@@ -100,7 +100,19 @@ typedef struct _rangemap {
 
 struct OF_translation ofw_translations[OFW_MAX_TRANSLATIONS];
 
+/*
+ * Data structures holding OpenFirmware's translations when running
+ * in virtual-mode.
+ *
+ * When we call 

CVS commit: src/sys/arch/powerpc

2021-02-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Feb 24 16:42:38 UTC 2021

Modified Files:
src/sys/arch/powerpc/include: cpu.h
src/sys/arch/powerpc/oea: cpu_subr.c genassym.cf
src/sys/arch/powerpc/powerpc: trap_subr.S

Log Message:
Add a provision for a per-cpu battable.  Each CPU starts with the global
one, but this allows CPUs to temporarily switch to an alternate battable
if needed.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/powerpc/include/cpu.h
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/powerpc/oea/cpu_subr.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/powerpc/oea/genassym.cf
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/powerpc/powerpc/trap_subr.S

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

Modified files:

Index: src/sys/arch/powerpc/include/cpu.h
diff -u src/sys/arch/powerpc/include/cpu.h:1.116 src/sys/arch/powerpc/include/cpu.h:1.117
--- src/sys/arch/powerpc/include/cpu.h:1.116	Wed Feb  3 10:37:05 2021
+++ src/sys/arch/powerpc/include/cpu.h	Wed Feb 24 16:42:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.116 2021/02/03 10:37:05 rin Exp $	*/
+/*	$NetBSD: cpu.h,v 1.117 2021/02/24 16:42:38 thorpej Exp $	*/
 
 /*
  * Copyright (C) 1999 Wolfgang Solfrank.
@@ -94,6 +94,10 @@ struct cpu_info {
 	struct lwp *ci_onproc;		/* current user LWP / kthread */
 	struct pcb *ci_curpcb;
 	struct pmap *ci_curpm;
+#if defined(PPC_OEA) || defined(PPC_OEA601) || defined(PPC_OEA64) || \
+defined(PPC_OEA64_BRIDGE) || defined(MODULAR) || defined(_MODULE)
+	void *ci_battable;		/* BAT table in use by this CPU */
+#endif
 	struct lwp *ci_softlwps[SOFTINT_COUNT];
 	int ci_cpuid;			/* from SPR_PIR */
 

Index: src/sys/arch/powerpc/oea/cpu_subr.c
diff -u src/sys/arch/powerpc/oea/cpu_subr.c:1.104 src/sys/arch/powerpc/oea/cpu_subr.c:1.105
--- src/sys/arch/powerpc/oea/cpu_subr.c:1.104	Mon Jul  6 10:31:23 2020
+++ src/sys/arch/powerpc/oea/cpu_subr.c	Wed Feb 24 16:42:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_subr.c,v 1.104 2020/07/06 10:31:23 rin Exp $	*/
+/*	$NetBSD: cpu_subr.c,v 1.105 2021/02/24 16:42:38 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2001 Matt Thomas.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.104 2020/07/06 10:31:23 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.105 2021/02/24 16:42:38 thorpej Exp $");
 
 #include "sysmon_envsys.h"
 
@@ -235,24 +235,27 @@ static const struct cputab models[] = {
 	{ "",		0,		REVFMT_HEX }
 };
 
+#include 
+extern struct bat battable[];
+
 #ifdef MULTIPROCESSOR
 struct cpu_info cpu_info[CPU_MAXNUM] = {
 [0] = {
 	.ci_curlwp = ,
+	.ci_battable = battable,
 },
 };
 volatile struct cpu_hatch_data *cpu_hatch_data;
 volatile int cpu_hatch_stack;
 #define HATCH_STACK_SIZE 0x1000
 extern int ticks_per_intr;
-#include 
 #include 
 #include 
-extern struct bat battable[];
 #else
 struct cpu_info cpu_info[1] = {
 [0] = {
 	.ci_curlwp = ,
+	.ci_battable = battable,
 },
 };
 #endif /*MULTIPROCESSOR*/
@@ -1329,6 +1332,7 @@ cpu_spinup(device_t self, struct cpu_inf
 	ci->ci_curlwp = ci->ci_data.cpu_idlelwp;
 	ci->ci_curpcb = lwp_getpcb(ci->ci_curlwp);
 	ci->ci_curpm = ci->ci_curpcb->pcb_pm;
+	ci->ci_battable = battable;
 
 	cpu_hatch_data = h;
 	h->hatch_running = 0;

Index: src/sys/arch/powerpc/oea/genassym.cf
diff -u src/sys/arch/powerpc/oea/genassym.cf:1.28 src/sys/arch/powerpc/oea/genassym.cf:1.29
--- src/sys/arch/powerpc/oea/genassym.cf:1.28	Mon Jul  6 09:34:17 2020
+++ src/sys/arch/powerpc/oea/genassym.cf	Wed Feb 24 16:42:38 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.28 2020/07/06 09:34:17 rin Exp $
+#	$NetBSD: genassym.cf,v 1.29 2021/02/24 16:42:38 thorpej Exp $
 
 #
 # Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -66,6 +66,7 @@ define	PM_USRSR	offsetof(struct pmap, pm
 define	PM_KERNELSR	offsetof(struct pmap, pm_sr[KERNEL_SR])
 endif
 
+define	CI_BATTABLE	offsetof(struct cpu_info, ci_battable)
 define	CI_TEMPSAVE	offsetof(struct cpu_info, ci_savearea[CI_SAVETEMP])
 define	CI_DDBSAVE	offsetof(struct cpu_info, ci_savearea[CI_SAVEDDB])
 define	CI_DISISAVE	offsetof(struct cpu_info, ci_savearea[CI_SAVEMMU])

Index: src/sys/arch/powerpc/powerpc/trap_subr.S
diff -u src/sys/arch/powerpc/powerpc/trap_subr.S:1.84 src/sys/arch/powerpc/powerpc/trap_subr.S:1.85
--- src/sys/arch/powerpc/powerpc/trap_subr.S:1.84	Sun Jul 12 21:18:01 2020
+++ src/sys/arch/powerpc/powerpc/trap_subr.S	Wed Feb 24 16:42:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap_subr.S,v 1.84 2020/07/12 21:18:01 rin Exp $	*/
+/*	$NetBSD: trap_subr.S,v 1.85 2021/02/24 16:42:38 thorpej Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -268,14 +268,20 @@ _C_LABEL(dsitrap):
 	rlwinm	%r31,%r31,3+(32-BAT_ADDR_SHIFT),BAT_ADDR_SHIFT-3,28
 	/* get segment * 8 */
 
+	/* Get address of this CPU's current battable */
+	GET_CPUINFO(%r30)
+	ldreg	%r30,CI_BATTABLE(%r30)
+
+	/* Add offset to the slot we care about. */
+	add	%r31,%r31,%r30
+
 	

CVS commit: src/lib/libc/regex

2021-02-24 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Feb 24 09:10:12 UTC 2021

Modified Files:
src/lib/libc/regex: engine.c re_format.7 regex.3

Log Message:
Restore NetBSD RCS Ids.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libc/regex/engine.c
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/regex/re_format.7
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/regex/regex.3

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

Modified files:

Index: src/lib/libc/regex/engine.c
diff -u src/lib/libc/regex/engine.c:1.25 src/lib/libc/regex/engine.c:1.26
--- src/lib/libc/regex/engine.c:1.25	Tue Feb 23 22:14:59 2021
+++ src/lib/libc/regex/engine.c	Wed Feb 24 09:10:12 2021
@@ -1,3 +1,5 @@
+/* $NetBSD: engine.c,v 1.26 2021/02/24 09:10:12 wiz Exp $ */
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -39,7 +41,7 @@
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/lib/libc/regex/engine.c 368358 2020-12-05 03:16:05Z kevans $");
 #endif
-__RCSID("$NetBSD: engine.c,v 1.25 2021/02/23 22:14:59 christos Exp $");
+__RCSID("$NetBSD: engine.c,v 1.26 2021/02/24 09:10:12 wiz Exp $");
 
 #include 
 

Index: src/lib/libc/regex/re_format.7
diff -u src/lib/libc/regex/re_format.7:1.13 src/lib/libc/regex/re_format.7:1.14
--- src/lib/libc/regex/re_format.7:1.13	Tue Feb 23 22:14:59 2021
+++ src/lib/libc/regex/re_format.7	Wed Feb 24 09:10:12 2021
@@ -1,3 +1,5 @@
+.\" $NetBSD: re_format.7,v 1.14 2021/02/24 09:10:12 wiz Exp $
+.\"
 .\" Copyright (c) 1992, 1993, 1994 Henry Spencer.
 .\" Copyright (c) 1992, 1993, 1994
 .\"	The Regents of the University of California.  All rights reserved.

Index: src/lib/libc/regex/regex.3
diff -u src/lib/libc/regex/regex.3:1.27 src/lib/libc/regex/regex.3:1.28
--- src/lib/libc/regex/regex.3:1.27	Tue Feb 23 22:14:59 2021
+++ src/lib/libc/regex/regex.3	Wed Feb 24 09:10:12 2021
@@ -1,3 +1,5 @@
+.\" $NetBSD: regex.3,v 1.28 2021/02/24 09:10:12 wiz Exp $
+.\"
 .\" Copyright (c) 1992, 1993, 1994 Henry Spencer.
 .\" Copyright (c) 1992, 1993, 1994
 .\"	The Regents of the University of California.  All rights reserved.



CVS commit: [netbsd-9] src/doc

2021-02-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 24 08:08:44 UTC 2021

Modified Files:
src/doc [netbsd-9]: CHANGES-9.2

Log Message:
Ticket #1213


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.48 -r1.1.2.49 src/doc/CHANGES-9.2

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

Modified files:

Index: src/doc/CHANGES-9.2
diff -u src/doc/CHANGES-9.2:1.1.2.48 src/doc/CHANGES-9.2:1.1.2.49
--- src/doc/CHANGES-9.2:1.1.2.48	Tue Feb 23 18:55:29 2021
+++ src/doc/CHANGES-9.2	Wed Feb 24 08:08:43 2021
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.2,v 1.1.2.48 2021/02/23 18:55:29 martin Exp $
+# $NetBSD: CHANGES-9.2,v 1.1.2.49 2021/02/24 08:08:43 martin Exp $
 
 A complete list of changes from the NetBSD 9.1 release to the NetBSD 9.2
 release:
@@ -1693,3 +1693,9 @@ bin/ksh/siglist.sh1.13
 	PR/56007: ksh unable to execute ERR traps.
 	[christos, ticket #1212]
 
+sys/arch/xen/xen/xennetback_xenbus.c		(apply patch)
+
+	xen: do not panic Dom0 when hypervisor grant_table_op(GNTTABOP_copy)
+	fails in xennet(4) backend driver. Part of fixes for XSA-362.
+	[jdolecek, ticket #1213]
+



CVS commit: [netbsd-9] src/sys/arch/xen/xen

2021-02-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 24 08:05:08 UTC 2021

Modified Files:
src/sys/arch/xen/xen [netbsd-9]: xennetback_xenbus.c

Log Message:
Apply patch, requested by jdolecek in ticket 1213:

Do not panic Dom0 when hypervisor grant_table_op(GNTTABOP_copy) fails
in xennet(4) backend driver, that can be triggered by malicious or buggy
DomU via bad grant reference.

Part of fixes for XSA-362.


To generate a diff of this commit:
cvs rdiff -u -r1.75.4.1 -r1.75.4.2 src/sys/arch/xen/xen/xennetback_xenbus.c

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

Modified files:

Index: src/sys/arch/xen/xen/xennetback_xenbus.c
diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.75.4.1 src/sys/arch/xen/xen/xennetback_xenbus.c:1.75.4.2
--- src/sys/arch/xen/xen/xennetback_xenbus.c:1.75.4.1	Tue Feb 23 18:50:21 2021
+++ src/sys/arch/xen/xen/xennetback_xenbus.c	Wed Feb 24 08:05:08 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: xennetback_xenbus.c,v 1.75.4.1 2021/02/23 18:50:21 martin Exp $  */
+/*  $NetBSD: xennetback_xenbus.c,v 1.75.4.2 2021/02/24 08:05:08 martin Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.75.4.1 2021/02/23 18:50:21 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.75.4.2 2021/02/24 08:05:08 martin Exp $");
 
 #include "opt_xen.h"
 
@@ -1041,15 +1041,19 @@ xennetback_ifsoftstart_copy(void *arg)
 			bpf_mtap(ifp, m, BPF_D_OUT);
 		}
 		if (i != 0) {
-			if (HYPERVISOR_grant_table_op(GNTTABOP_copy,
-			xstart_gop_copy, i) != 0) {
-panic("%s: GNTTABOP_copy failed",
-ifp->if_xname);
+			int result;
+
+			result = HYPERVISOR_grant_table_op(GNTTABOP_copy,
+			xstart_gop_copy, i);
+			if (result != 0) {
+printf("%s: GNTTABOP_copy failed %d",
+ifp->if_xname, result);
 			}
 
 			for (j = 0; j < i; j++) {
-if (xstart_gop_copy[j].status != GNTST_okay) {
-	printf("%s GNTTABOP_copy[%d] %d\n",
+if (result < 0 || (result > 0 && j >= result)
+|| xstart_gop_copy[j].status != GNTST_okay){
+	printf("%s GNTTABOP_copy[%d] st %d\n",
 	ifp->if_xname,
 	j, xstart_gop_copy[j].status);
 	printf("%s: req_prod %u req_cons "