Subject: libvmf,cpp,rauboot,mkstr(1) fixes, ld feature (#441)
Index:	usr.lib/libvmf,lib/cpp,sys/mdec/rauboot.s,... 2.11BSD

Description:
	1. The libvmf (virtual memory using tmp files) routines could crash
	   or hang an application if too many locked segments were requested.

	2. The C preprocessor (cpp) had a memory leak which could cause it
	   to run out of memory _and_ also failed to check the return
	   status of calloc() which would cause cpp to fail ungracefully.

	3. The MSCP bootblock would not work with a CMD CQD220 adaptor due
	   to the bootblock relying on the (undocumented?) behaviour of DEC
	   adaptors.

	4. In the mkstr(1) manpage the usage example given used lseek(2)
	   incorrectly.

	5. The linker (ld) does not accept the '-g' flag which on other
	   systems says to retain debuggin symbols.

	6. creat() is no longer a system call, thus it is an error to
	   have creat(2) instead of creat(3).

Repeat-By:
	Observation.

	Alternatively have Anders Magnusson beating on the system and
	submitting bug reports on a regular basis :-)

	The change to ld(1) is for compatibility for the same reason that '-z'
	was added a long time ago.  Eventually perhaps extra debug information
	will be generated by the compilers.

Fix:
	The following files are removed/added/modified by this update:

	added: /usr/src/man/man3/creat.3
	removed: /usr/man/cat2/creat.0
	removed: /usr/src/man/man2/creat.2

	modified: /usr/src/usr.lib/libvmf/vmf.c.old
	modified: /usr/src/sys/mdec/rauboot.s.old
	modified: /usr/src/bin/ld/ld.c.old
	modified: /usr/src/lib/cpp/cpp.c.old
	modified: /usr/src/lib/cpp/Makefile.old
	modified: /usr/src/man/man1/mkstr.1.old
	modified: /usr/src/man/man2/Makefile.old
	modified: /usr/src/man/man3/Makefile.old
	modified: /VERSION.old

	The file attached below is a shar file containing:
		
		441.sh - a script to remove the two manpages 
		441.shar - a shar file to add the new manpage
		441.patch - a patch file to modify the remaining files

	To apply this update cut where indicated and save to a file (/tmp/441).

	Then:
		cd /tmp
		sh 441
		./441.sh
		sh 441.shar
		patch -p0 < 441.patch

		cd /usr/src/usr.lib/libvmf
		make
		make install
		make clean

		cd /usr/src/lib/cpp
		make 
		make install
		make clean

		cd /usr/src/bin/ld
		make
		make install
		make clean

		cd /usr/src/man/man1
		/usr/man/manroff mkstr.1 > /usr/man/cat1/mkstr.0

		cd ../man3
		/usr/man/manroff creat.3 > /usr/man/cat3/creat.0

		cd /sys/mdec
		make
		make install
		make clean

	And with that you're done.

	As always this and previous updates to 2.11BSD are available via
	anonymous FTP to either FTP.TO.GD-ES.COM or MOE.2BSD.COM in the
	directory /pub/2.11BSD.

---------------------------cut here----------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	441.sh
#	441.shar
#	441.patch
# This archive created: Tue Dec  4 20:22:11 2001
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f '441.sh'
then
	echo shar: "will not over-write existing file '441.sh'"
else
sed 's/^Y//' << \SHAR_EOF > '441.sh'
Y#!/bin/sh
Y
Yrm -f /usr/man/cat2/creat.0
Yrm -f /usr/src/man/man2/creat.2
SHAR_EOF
chmod 755 '441.sh'
fi
if test -f '441.shar'
then
	echo shar: "will not over-write existing file '441.shar'"
else
sed 's/^Y//' << \SHAR_EOF > '441.shar'
Y#! /bin/sh
Y# This is a shell archive, meaning:
Y# 1. Remove everything above the #! /bin/sh line.
Y# 2. Save the resulting text in a file.
Y# 3. Execute the file with /bin/sh (not csh) to create:
Y#	/usr/src/man/man3/creat.3
Y# This archive created: Tue Dec  4 19:51:12 2001
Yexport PATH; PATH=/bin:/usr/bin:$PATH
Yif test -f '/usr/src/man/man3/creat.3'
Ythen
Y	echo shar: "will not over-write existing file '/usr/src/man/man3/creat.3'"
Yelse
Ycat << \SHAR_EOF > '/usr/src/man/man3/creat.3'
Y.\" Copyright (c) 1980 Regents of the University of California.
Y.\" All rights reserved.  The Berkeley software License Agreement
Y.\" specifies the terms and conditions for redistribution.
Y.\"
Y.\"	@(#)creat.2	6.7 (2.11BSD) 2001/11/19
Y.\"
Y.TH CREAT 3 "November 19, 2001"
Y.UC 4
Y.SH NAME
Ycreat \- create a new file
Y.SH SYNOPSIS
Y.nf
Y.ft B
Y#include <sys/types.h>
Y#include <fcntl.h>
Y
Ycreat(name, mode)
Y    char *name;
Y    int mode;
Y.ft R
Y.fi
Y.SH DESCRIPTION
Y\fBThis interface is made obsolete by:\fP open(2).
Y.PP
Y.BR Creat ()
Yis the same as:
Y.nf
Y
Y    open(name, O_CREAT | O_TRUNC | O_WRONLY, mode);
Y.fi 
Y.SH "SEE ALSO"
Yopen(2)
Y.SH "HISTORY"
YThe \fBcreat\fP function call appeared in Version 6 AT&T UNIX.
YSHAR_EOF
Yfi
Yexit 0
Y#	End of shell archive
SHAR_EOF
chmod 644 '441.shar'
fi
if test -f '441.patch'
then
	echo shar: "will not over-write existing file '441.patch'"
else
sed 's/^Y//' << \SHAR_EOF > '441.patch'
Y*** /usr/src/usr.lib/libvmf/vmf.c.old	Thu Oct 21 20:55:38 1993
Y--- /usr/src/usr.lib/libvmf/vmf.c	Mon Nov 19 19:43:14 2001
Y***************
Y*** 93,100 ****
Y  
Y  	nmapsegs++;
Y  
Y! 	if	(segno >= vspace->v_maxsegno || segno < 0)
Y! 		{
Y  #ifdef DEBUG
Y  		fprintf(stderr,"vmmapseg vspace0%o segno%d\n", vspace, segno);
Y  #endif
Y--- 93,99 ----
Y  
Y  	nmapsegs++;
Y  
Y! 	if (segno >= vspace->v_maxsegno) {
Y  #ifdef DEBUG
Y  		fprintf(stderr,"vmmapseg vspace0%o segno%d\n", vspace, segno);
Y  #endif
Y***************
Y*** 110,122 ****
Y  			{     /* not in memory */
Y  			int status;
Y  
Y! 			for (s = (struct vseg *)s->s_link.back; s->s_lock_count != 0; 
Y! 					s = (struct vseg *)s->s_link.back)
Y! 				{
Y! 				if (s == (struct vseg *)seghead)
Y! 					vmerror("Too many locked segs!");
Y  				debugseg(s, "back skip");
Y! 				}
Y  			debugseg(s, "dump on");
Y  			if	(s->s_flags & S_DIRTY)
Y  				if	(swap(s, write) != 0)
Y--- 109,120 ----
Y  			{     /* not in memory */
Y  			int status;
Y  
Y! 			for (s = (struct vseg *)s->s_link.back;
Y! 			    s !=(struct vseg *)seghead && s->s_lock_count != 0;
Y! 			    s = (struct vseg *)s->s_link.back)
Y  				debugseg(s, "back skip");
Y! 			if (s == (struct vseg *)seghead)
Y! 				vmerror("Too many locked segs!");
Y  			debugseg(s, "dump on");
Y  			if	(s->s_flags & S_DIRTY)
Y  				if	(swap(s, write) != 0)
Y*** /usr/src/sys/mdec/rauboot.s.old	Wed May 17 19:54:13 2000
Y--- /usr/src/sys/mdec/rauboot.s	Mon Nov 19 20:02:57 2001
Y***************
Y*** 16,22 ****
Y  
Y  MSCPSIZE =	64.	/ One MSCP command packet is 64bytes long (need 2)
Y  
Y! RASEMAP	=	140000	/ RA controller owner semaphore
Y  
Y  RAERR =		100000	/ error bit 
Y  RASTEP1 =	04000	/ step1 has started
Y--- 16,22 ----
Y  
Y  MSCPSIZE =	64.	/ One MSCP command packet is 64bytes long (need 2)
Y  
Y! RASEMAP	=	100000	/ RA controller owner semaphore
Y  
Y  RAERR =		100000	/ error bit 
Y  RASTEP1 =	04000	/ step1 has started
Y***************
Y*** 287,309 ****
Y  	mov	$RASEMAP,*$ra+RARSPH	/ set mscp semaphores
Y  	mov	$RASEMAP,*$ra+RACMDH
Y  	mov	*raip,r0		/ tap controllers shoulder
Y! 	mov	$ra+RACMDI,r0
Y  1:
Y  	tst	(r0)
Y! 	beq	1b			/ Wait till command read
Y! 	clr	(r0)+			/ Tell controller we saw it, ok.
Y  2:
Y  	tst	(r0)
Y! 	beq	2b			/ Wait till response written
Y  	clr	(r0)			/ Tell controller we go it
Y  	rts	pc
Y  
Y! / Some adaptors (TD Systems Viking for example) require the vector field
Y! /  to be initialized even though interrupts are not enabled.  Use the primary
Y! /  vector of 0154.   The standalone MSCP driver does the same thing and later on
Y! /  the  kernel programs the adaptor with an assigned vector
Y! 
Y! icons:	RAERR + 033			/ 033 = 0154 >> 2
Y  	ra+RARING
Y  	0
Y  	RAGO
Y--- 287,306 ----
Y  	mov	$RASEMAP,*$ra+RARSPH	/ set mscp semaphores
Y  	mov	$RASEMAP,*$ra+RACMDH
Y  	mov	*raip,r0		/ tap controllers shoulder
Y! 	mov	$ra+RACMDH,r0
Y  1:
Y  	tst	(r0)
Y! 	bmi	1b			/ Wait till command read
Y! 	mov	$ra+RARSPH,r0
Y  2:
Y  	tst	(r0)
Y! 	bmi	2b			/ Wait till response written
Y! 	mov	$ra+RACMDI,r0
Y! 	clr	(r0)+			/ Tell controller we saw it, ok.
Y  	clr	(r0)			/ Tell controller we go it
Y  	rts	pc
Y  
Y! icons:	RAERR + 033
Y  	ra+RARING
Y  	0
Y  	RAGO
Y*** /usr/src/bin/ld/ld.c.old	Mon Nov 19 19:41:48 2001
Y--- /usr/src/bin/ld/ld.c	Mon Nov 19 19:42:29 2001
Y***************
Y*** 478,483 ****
Y--- 478,485 ----
Y  			}
Y  			curov++;
Y  			continue;
Y+ 		case 'g': /* Just ignore the debug flag */
Y+ 			continue;
Y  		case 'y':
Y  		case 'A':
Y  		case 'H':
Y*** /usr/src/lib/cpp/cpp.c.old	Sun Aug 26 09:36:03 2001
Y--- /usr/src/lib/cpp/cpp.c	Mon Nov 19 19:49:46 2001
Y***************
Y*** 148,153 ****
Y--- 148,154 ----
Y  STATIC	char	*dirnams[MAXINC];	/* actual directory of #include files */
Y  STATIC	int	fins[MAXINC];
Y  STATIC	int	lineno[MAXINC];
Y+ STATIC	char	*lowmem;	/* set to lowest address that malloc uses */
Y  
Y  STATIC	char	*dirs[10];	/* -I and <> directories */
Y  char *strdex(), *copy(), *subst(), *trmdir();
Y***************
Y*** 804,809 ****
Y--- 805,812 ----
Y  				cp2 = cp;
Y  				while (*cp2 != '"' && cp2 < inp)
Y  					cp2++;
Y+ 				if (fnames[ifno] >= lowmem)
Y+ 					free(fnames[ifno]);
Y  				fnames[ifno] = savestring(cp, cp2);
Y  			}
Y  			continue;
Y***************
Y*** 823,828 ****
Y--- 826,833 ----
Y  	register char *cp;
Y  
Y  	retbuf = (char *) calloc(finish - start + 1, sizeof (char));
Y+ 	if (retbuf == NULL)
Y+ 		pperror("calloc");
Y  	cp = retbuf;
Y  	while (start < finish)
Y  		*cp++ = *start++;
Y***************
Y*** 1088,1093 ****
Y--- 1093,1100 ----
Y  	fnames[ifno=0] = (char *)inquire(stdin, _FILENAME);
Y  	dirnams[0] = dirs[0] = trmdir(copy(fnames[0]));
Y  # endif
Y+ 	lowmem = (char *)sbrk(0);	/* for free() */
Y+ 
Y  	for(i=1; i<argc; i++)
Y  		{
Y  		switch(argv[i][0])
Y*** /usr/src/lib/cpp/Makefile.old	Thu Jul 11 19:55:10 1996
Y--- /usr/src/lib/cpp/Makefile	Mon Nov 19 20:00:58 2001
Y***************
Y*** 1,39 ****
Y! #	Makefile	1.3	(2.11BSD) 96/7/11
Y  #
Y- 
Y- # Defined SHARED_DATA to be whatever will make your compiler make initialized
Y- # variables shared and read only.  Don't do this on a PDP-11 if you're also
Y- # compiling separate I&D since doing so puts the shared data in text space
Y- # which can't be accessed normally.
Y- #
Y- #SHARED_DATA=-R
Y- 
Y- # CFLAGS=-O -Dunix=1 -DFLEXNAMES
Y- # If you don't have split I/D, you'll have to edit the constant
Y- # SBSIZE in cpp.c to reflect this.
Y- 
Y  CFLAGS=-O -Dpdp11=1 -DFLEXNAMES -DBSD2_11 -UBSD2_10
Y  SEPFLAG=-i
Y  
Y! cpp :	cpp.o cpy.o rodata.o
Y! 	$(CC) $(CFLAGS) $(SEPFLAG) -o cpp rodata.o cpp.o cpy.o
Y  
Y  cpy.c : cpy.y
Y  	yacc cpy.y
Y- 	../pcc/:yyfix yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef
Y  	mv y.tab.c cpy.c
Y  
Y  cpy.o :	cpy.c yylex.c
Y  
Y- rodata.o : cpy.c
Y- 	$(CC) $(CFLAGS) ${SHARED_DATA} -c rodata.c
Y- 
Y  clean :
Y! 	rm -f *.s *.o cpy.c rodata.c cpp
Y  
Y  install : cpp
Y  	install -s cpp $(DESTDIR)/lib
Y- 
Y- sources : cpp.c cpy.y yylex.c README
Y- cpp.c cpy.y yylex.c README :
Y- 	sccs get $@
Y--- 1,19 ----
Y! #	Makefile	1.4	(2.11BSD) 2001/11/19
Y  #
Y  CFLAGS=-O -Dpdp11=1 -DFLEXNAMES -DBSD2_11 -UBSD2_10
Y  SEPFLAG=-i
Y  
Y! cpp :	cpp.o cpy.o
Y! 	$(CC) $(CFLAGS) $(SEPFLAG) -o cpp cpp.o cpy.o
Y  
Y  cpy.c : cpy.y
Y  	yacc cpy.y
Y  	mv y.tab.c cpy.c
Y  
Y  cpy.o :	cpy.c yylex.c
Y  
Y  clean :
Y! 	rm -f *.o cpy.c cpp
Y  
Y  install : cpp
Y  	install -s cpp $(DESTDIR)/lib
Y*** /usr/src/man/man1/mkstr.1.old	Tue Oct 22 20:22:35 1996
Y--- /usr/src/man/man1/mkstr.1	Mon Nov 19 20:12:48 2001
Y***************
Y*** 74,80 ****
Y  			exit(1);
Y  		}
Y  	}
Y! 	\fBif\fR (lseek(efil, (long) a1, 0) |\|| read(efil, buf, 256) <= 0)
Y  		\fBgoto\fR oops;
Y  	printf(buf, a2, a3, a4);
Y  }
Y--- 74,81 ----
Y  			exit(1);
Y  		}
Y  	}
Y! 	\fBif\fR (lseek(efil, (long) a1, 0) <= 0 |\||
Y! 	    read(efil, buf, 256) <= 0)
Y  		\fBgoto\fR oops;
Y  	printf(buf, a2, a3, a4);
Y  }
Y*** /usr/src/man/man2/Makefile.old	Sat Mar  4 16:12:17 2000
Y--- /usr/src/man/man2/Makefile	Mon Nov 19 20:18:29 2001
Y***************
Y*** 14,24 ****
Y  # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
Y  # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Y  #
Y! #	@(#)Makefile	2.11 (2.11BSD) 2000/3/4
Y  #
Y  MDIR=	/usr/man/cat2
Y  SRCS=	accept.2 access.2 acct.2 adjtime.2 bind.2 brk.2 chdir.2 chmod.2 \
Y! 	chown.2 chroot.2 close.2 connect.2 creat.2 dup.2 execve.2 exit.2 \
Y  	chflags.2 \
Y  	fcntl.2 fetchi.2 flock.2 fork.2 fperr.2 fsync.2 getdtablesize.2 \
Y  	getgroups.2 gethostid.2 gethostname.2 getitimer.2 \
Y--- 14,24 ----
Y  # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
Y  # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Y  #
Y! #	@(#)Makefile	2.12 (2.11BSD) 2001/11/19
Y  #
Y  MDIR=	/usr/man/cat2
Y  SRCS=	accept.2 access.2 acct.2 adjtime.2 bind.2 brk.2 chdir.2 chmod.2 \
Y! 	chown.2 chroot.2 close.2 connect.2 dup.2 execve.2 exit.2 \
Y  	chflags.2 \
Y  	fcntl.2 fetchi.2 flock.2 fork.2 fperr.2 fsync.2 getdtablesize.2 \
Y  	getgroups.2 gethostid.2 gethostname.2 getitimer.2 \
Y***************
Y*** 37,43 ****
Y  	stat.2 statfs.2 swapon.2 symlink.2 sync.2 syscall.2 truncate.2 ucall.2 \
Y  	umask.2 unlink.2 utimes.2 vfork.2 vhangup.2 wait.2 write.2
Y  OBJS=	accept.0 access.0 acct.0 adjtime.0 bind.0 brk.0 chdir.0 chmod.0 \
Y! 	chown.0 chroot.0 close.0 connect.0 creat.0 dup.0 execve.0 exit.0 \
Y  	chflags.0 \
Y  	fcntl.0 fetchi.0 flock.0 fork.0 fperr.0 fsync.0 getdtablesize.0 \
Y  	getgroups.0 gethostid.0 gethostname.0 getitimer.0 \
Y--- 37,43 ----
Y  	stat.2 statfs.2 swapon.2 symlink.2 sync.2 syscall.2 truncate.2 ucall.2 \
Y  	umask.2 unlink.2 utimes.2 vfork.2 vhangup.2 wait.2 write.2
Y  OBJS=	accept.0 access.0 acct.0 adjtime.0 bind.0 brk.0 chdir.0 chmod.0 \
Y! 	chown.0 chroot.0 close.0 connect.0 dup.0 execve.0 exit.0 \
Y  	chflags.0 \
Y  	fcntl.0 fetchi.0 flock.0 fork.0 fperr.0 fsync.0 getdtablesize.0 \
Y  	getgroups.0 gethostid.0 gethostname.0 getitimer.0 \
Y*** /usr/src/man/man3/Makefile.old	Mon Dec  8 21:29:48 1997
Y--- /usr/src/man/man3/Makefile	Mon Nov 19 20:20:21 2001
Y***************
Y*** 14,24 ****
Y  # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
Y  # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Y  #
Y! #	@(#)Makefile	5.4.15 (2.11BSD) 1997/12/8
Y  #
Y  MDIR=	/usr/man/cat3
Y  SRCS1=	abort.3 abs.3 alarm.3 asinh.3 assert.3 atof.3 bstring.3 byteorder.3 \
Y! 	compat-sys5.3 crypt.3 ctime.3 ctype.3 curses.3 dbm.3 daemon.3 \
Y  	devname.3 directory.3 ecvt.3 end.3 erf.3 err.3 execl.3 exit.3 \
Y  	exp.3 fclose.3 ferror.3 floor.3 \
Y  	fopen.3 fread.3 frexp.3 fseek.3 getc.3 getdisk.3 getenv.3 getfsent.3 \
Y--- 14,24 ----
Y  # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
Y  # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Y  #
Y! #	@(#)Makefile	5.4.16 (2.11BSD) 2001/11/19
Y  #
Y  MDIR=	/usr/man/cat3
Y  SRCS1=	abort.3 abs.3 alarm.3 asinh.3 assert.3 atof.3 bstring.3 byteorder.3 \
Y! 	compat-sys5.3 creat.3 crypt.3 ctime.3 ctype.3 curses.3 dbm.3 daemon.3 \
Y  	devname.3 directory.3 ecvt.3 end.3 erf.3 err.3 execl.3 exit.3 \
Y  	exp.3 fclose.3 ferror.3 floor.3 \
Y  	fopen.3 fread.3 frexp.3 fseek.3 getc.3 getdisk.3 getenv.3 getfsent.3 \
Y***************
Y*** 39,45 ****
Y  	syserrlst.3 \
Y  	utime.3 valloc.3 varargs.3
Y  OBJS1=	abort.0 abs.0 alarm.0 asinh.0 assert.0 atof.0 bstring.0 byteorder.0 \
Y! 	compat-sys5.0 crypt.0 ctime.0 ctype.0 curses.0 dbm.0 daemon.0 \
Y  	devname.0 directory.0 ecvt.0 end.0 erf.0 err.0 execl.0 exit.0 \
Y  	exp.0 fclose.0 ferror.0 floor.0 \
Y  	fopen.0 fread.0 frexp.0 fseek.0 getc.0 getdisk.0 getenv.0 getfsent.0 \
Y--- 39,45 ----
Y  	syserrlst.3 \
Y  	utime.3 valloc.3 varargs.3
Y  OBJS1=	abort.0 abs.0 alarm.0 asinh.0 assert.0 atof.0 bstring.0 byteorder.0 \
Y! 	compat-sys5.0 creat.0 crypt.0 ctime.0 ctype.0 curses.0 dbm.0 daemon.0 \
Y  	devname.0 directory.0 ecvt.0 end.0 erf.0 err.0 execl.0 exit.0 \
Y  	exp.0 fclose.0 ferror.0 floor.0 \
Y  	fopen.0 fread.0 frexp.0 fseek.0 getc.0 getdisk.0 getenv.0 getfsent.0 \
Y*** /VERSION.old	Mon Nov 19 20:14:53 2001
Y--- /VERSION	Tue Dec  4 19:33:14 2001
Y***************
Y*** 1,5 ****
Y! Current Patch Level: 440
Y! Date: November 19, 2001
Y  
Y  2.11 BSD
Y  ============
Y--- 1,5 ----
Y! Current Patch Level: 441
Y! Date: December 4, 2001
Y  
Y  2.11 BSD
Y  ============
SHAR_EOF
chmod 644 '441.patch'
fi
exit 0
#	End of shell archive
