Subject: port-sparc/13429: ofwboot 1.3 does not allow '-' in kernel filename
To: None <gnats-bugs@gnats.netbsd.org>
From: None <heas@foad.shrubbery.net>
List: netbsd-bugs
Date: 07/11/2001 01:40:14
>Number:         13429
>Category:       port-sparc
>Synopsis:       ofwboot 1.3 does not allow '-' in kernel filename
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-sparc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 10 18:38:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD-current 20010709
>Organization:
>Environment:
System: NetBSD foad 1.5W NetBSD 1.5W (foad) #10: Mon Jul 2 20:31:53 UTC 2001 root@foad:/home/src/sys/arch/sparc64/compile/foad sparc64
Architecture: sparc64
Machine: sparc64
>Description:
	when ofwboot looks for boot options in the command string, it ignores
	whether a the comment delimiter '-' appears following a space or at
	the beginning of a line.  thus a kernel name such as netbsd-1.5W is
	interpretted as "netbsd" with options -1.5W.
>How-To-Repeat:
	cp /netbsd /netbsd-foo
	halt
	boot netbsd-foo

	it will boot /netbsd as in

	{0} ok boot netbsd-1.5W -s
	Resetting ... 

	screen not found.
	Can't open input device.
	Keyboard not present.  Using ttya for input and output.
	
	Sun Ultra 2 UPA/SBus (2 X UltraSPARC-II 296MHz), No Keyboard
	OpenBoot 3.25, 256 MB memory installed, Serial #9370632.
	Ethernet address 8:0:20:8e:fc:8, Host ID: 808efc08.
	
	Rebooting with command: boot netbsd-1.5W -s                           
	Boot device: /sbus/SUNW,fas@e,8800000/sd@0,0  File and args: netbsd-1.5W -s
	NetBSD IEEE 1275 Bootblock
	..>> NetBSD/sparc64 OpenFirmware Boot, Revision 1.3
	>> (root@foad, Mon Jul  9 20:11:51 UTC 2001)
	open /sbus@1f,0/SUNW,fas@e,8800000/sd@0,0:a/netbsd: No such file or directory
	: trying netbsd.gz ...
	open /sbus@1f,0/SUNW,fas@e,8800000/sd@0,0:a/netbsd: No such file or directory
	: trying netbsd.old ...
	open /sbus@1f,0/SUNW,fas@e,8800000/sd@0,0:a/netbsd: No such file or directory
	: trying netbsd.old.gz ...
	open : No such file or directory

>Fix:
	this patch fixes it, but not sure if i missed corner cases.

	Index: boot.c
	===================================================================
	RCS file: /cvsroot/syssrc/sys/arch/sparc/stand/ofwboot/boot.c,v
	retrieving revision 1.3
	diff -c -r1.3 boot.c
	*** boot.c	2001/05/31 08:55:19	1.3
	--- boot.c	2001/07/11 01:39:17
	***************
	*** 143,149 ****
	  	}
	  	*howtop = 0;
	  	for (cp = str; *cp; cp++)
	! 		if (*cp == ' ' || *cp == '-')
	  			break;
	  	if (!*cp)
	  		return;
	--- 143,149 ----
	  	}
	  	*howtop = 0;
	  	for (cp = str; *cp; cp++)
	! 		if (*cp == ' ' || *cp == 0)
	  			break;
	  	if (!*cp)
	  		return;
	Index: ofdev.c
	===================================================================
	RCS file: /cvsroot/syssrc/sys/arch/sparc/stand/ofwboot/ofdev.c,v
	retrieving revision 1.1
	diff -c -r1.1 ofdev.c
	*** ofdev.c	2000/08/20 14:58:41	1.1
	--- ofdev.c	2001/07/11 01:39:17
	***************
	*** 93,99 ****
	  				printf("filename: hunting for arguments in %s\n", str);
	  #endif
	  				for (cp = lp;
	! 				     --cp >= str && *cp != '/' && *cp != '-';);
	  				if (cp >= str && *cp == '-') {
	  					/* found arguments, make firmware ignore them */
	  					*cp = 0;
	--- 93,102 ----
	  				printf("filename: hunting for arguments in %s\n", str);
	  #endif
	  				for (cp = lp;
	! 				     --cp >= str && *cp != '/' && (
	! !(cp - 1 >= str && (*cp == '-' && *(cp - 1) == ' ')) ||
	! (cp - 1 < str && *cp != '-')
	! ););
	  				if (cp >= str && *cp == '-') {
	  					/* found arguments, make firmware ignore them */
	  					*cp = 0;
>Release-Note:
>Audit-Trail:
>Unformatted: