[comp.bugs.2bsd] readv/writev/rdwri/namei-encapsulation/f_ops

sms@wlv.imsd.contel.com (Steven M. Schultz) (04/14/90)

Subject: readv/writev/rdwri/namei-encapsulation/f_ops (part 1 of 2)
Index:	sys/many 2.10BSD

Description:
	Under 2.10.1BSD the writev() and readv() functionality is provided
	by an emulation routine using normal read(2) and write(2) syscalls.

	Also, the kernel's I/O interface was still the readi()/writei()
	from earlier versions of pdp-11 Unix rather than the rdwri()
	method from 4.3BSD

	And, the namei encapsulation of arguments into the u.u_nd structure
	was not present.

Repeat-By:
	Examination of the sources.  Or optionally, "diff" the kernel sources
	from a 2.10.1BSD system against those from a 4.3BSD system.

Fix:
	This is part 1 of 2

	The patches below bring the 2.10.1BSD kernel sources much closer to
	those of 4.3BSD as well as directly implementing readv and writev.

		1) the 4.3BSD "rdwri()" and uio/iovec kernel I/O model, this
		   results in u_offset, u_count, u_base, u_segflg and dummy3
		   being removed from the u structure.

		   this makes I/O the kernel wishes to perform on his own
		   behalf much easier to perform since the necessary uio and
		   iovec structures are dynamically allocated on the stack
		   rather than requiring the u struct members be saved, loaded
		   and then restored.

		   the previous partial implementation of 'rdwri' to support
		   the quota system has been replaced with 4.3BSD version.

		2) the 4.3BSD "namei encapsulation" (u_nd in the u struct),
		   this removes ni_endoff, u_pdir, u_dirp and u_dent from
		   the u structure.

		   namei() now looks much closer to the 4.3BSD version, the
		   only differences left are basically from the on disc
		   directory structures being different.

		3) readv() and writev() as syscalls rather than an emulation
		   routine in libc.a using read() and write(). sendmsg(2) and
		   recvmsg(2) now work as they do under 4.3BSD rather
		   than being limited to a msghdr vector length of 1.

		4) a more 4.3BSD lookalike dispatching to the functions acting
		   on a file descriptor.  the 'f_ops' field in the file
		   structure was NOT implemented, rather a global table

		   	struct fileops F_ops[] =
				{NULL,&inodeops,&socketops,&pipeops};

		   is used, and the f_type member of the file structure is
		   used as an index.  this reduces the amount of "ifdef'd"
		   code and reduces the differences from 4.3BSD to a mere
		   handful of lines for several kernel files.

	Many of the changes are small but repeated.  For example, all of the
	disc and tape drivers had to have their XXread and XXwrite entry points
	modified to accept a ",uio" as a second argument and to pass the uio
	argument on to physio().

	Some of the changes, in particular those in ufs_namei.c and
	ufs_syscalls.c are larger and more complex.

	The rename() syscall handling for example, was essentially re-ported
	from 4.3BSD to take advantage of the new rdwri interface.  The
	physio() routine was rewritten as was the uiomove() routine (the latter
	in both kernel and supervisor mode).

	The putchar() routine was removed from the supervisor networking, and
	in it's place a "SKcall(putchar, ...)" to the kernel putchar() added.
	This has the benefit of placing networking printf data into the
	kernel logging system for syslogd to pick up.

	Several other minor differences from 4.3BSD were also fixed.
	For example, tty_pty.c was missing the check for a null pointer, etc.

	The file /sys/sys/sys_inode2.c was folded into /sys/sys/sys_inode.c
	as it is in 4.3BSD.

	I debated for sometime whether this posting should be in multiple
        pieces, or a single monolithic one.  The compromise is two parts,
	mainly due to the fact that 'vi' can't handle the whole thing at
	once on a pdp-11.

        The two parts are each roughly 112kb is size.

	A pass thru the OTHERS directory was made and references to
	now obsolete/removed u struct members were changed (u_offset becomes
	uio->uio_offset, etc).  NO other changes were made to OTHERS - if
	a driver didn't work before or was untested, nothing was done to
	change that.

	This posting contains:

		1) context diffs for the /usr/src/sys files excluding the
		   OTHERS directory.

		2) diffs for /usr/src/lib/libc/pdp/Makefile and
		   /usr/src/lib/libc/pdp/sys/Makefile

		3) the source to readv(2) and writev(2) -
		   /usr/src/lib/libc/pdp/sys/{readv,writev}.s

		4) diffs for the read(2) and write(2) man pages -
		   /usr/src/man/man2/{read,write}.2

		5) patch for 'pstat.c' to handle the new u struct.

		6) a replacement adb script for pretty printing the u struct -
		   /usr/lib/adb/u

		7) a list of system utilities which will need to be
		   recompiled after the user.h file is updated.

		8) a reminder to "rm -r /usr/src/lib/libc/com-4.3" and
		   "ar d /lib/libc.a rdwrv.o" (and libc_p.a) because the
		   readv/writev compatibility routine is no longer needed,
		   and a reminder to "rm /sys/sys/sys_inode2.c" because it
		   has been merged with /sys/sys/sys_inode.c

		9) an implicit assumption that all previous patches have
		   been applied.

	For quick reference, this is the list of modified files:

diff -r -c /usr/src/oldsys/conf/Make.nsunix /usr/src/sys/conf/Make.nsunix
diff -r -c /usr/src/oldsys/conf/Make.sunix /usr/src/sys/conf/Make.sunix
diff -r -c /usr/src/oldsys/conf/Make.sys /usr/src/sys/conf/Make.sys
diff -r -c /usr/src/oldsys/conf/Make.unix /usr/src/sys/conf/Make.unix
diff -r -c /usr/src/oldsys/conf/param.c /usr/src/sys/conf/param.c
diff -r -c /usr/src/oldsys/h/dir.h /usr/src/sys/h/dir.h
diff -r -c /usr/src/oldsys/h/file.h /usr/src/sys/h/file.h
diff -r -c /usr/src/oldsys/h/namei.h /usr/src/sys/h/namei.h
diff -r -c /usr/src/oldsys/h/uio.h /usr/src/sys/h/uio.h
diff -r -c /usr/src/oldsys/h/user.h /usr/src/sys/h/user.h
diff -r -c /usr/src/oldsys/pdp/cons.c /usr/src/sys/pdp/cons.c
diff -r -c /usr/src/oldsys/pdp/machdep.c /usr/src/sys/pdp/machdep.c
diff -r -c /usr/src/oldsys/pdp/machdep2.c /usr/src/sys/pdp/machdep2.c
diff -r -c /usr/src/oldsys/pdp/mem.c /usr/src/sys/pdp/mem.c
diff -r -c /usr/src/oldsys/pdp/net_mac.h /usr/src/sys/pdp/net_mac.h
diff -r -c /usr/src/oldsys/pdpuba/br.c /usr/src/sys/pdpuba/br.c
diff -r -c /usr/src/oldsys/pdpuba/dh.c /usr/src/sys/pdpuba/dh.c
diff -r -c /usr/src/oldsys/pdpuba/dhu.c /usr/src/sys/pdpuba/dhu.c
diff -r -c /usr/src/oldsys/pdpuba/dn.c /usr/src/sys/pdpuba/dn.c
diff -r -c /usr/src/oldsys/pdpuba/dr.c /usr/src/sys/pdpuba/dr.c
diff -r -c /usr/src/oldsys/pdpuba/dz.c /usr/src/sys/pdpuba/dz.c
diff -r -c /usr/src/oldsys/pdpuba/hk.c /usr/src/sys/pdpuba/hk.c
diff -r -c /usr/src/oldsys/pdpuba/ht.c /usr/src/sys/pdpuba/ht.c
diff -r -c /usr/src/oldsys/pdpuba/lp.c /usr/src/sys/pdpuba/lp.c
diff -r -c /usr/src/oldsys/pdpuba/ra.c /usr/src/sys/pdpuba/ra.c
diff -r -c /usr/src/oldsys/pdpuba/rk.c /usr/src/sys/pdpuba/rk.c
diff -r -c /usr/src/oldsys/pdpuba/rl.c /usr/src/sys/pdpuba/rl.c
diff -r -c /usr/src/oldsys/pdpuba/rx.c /usr/src/sys/pdpuba/rx.c
diff -r -c /usr/src/oldsys/pdpuba/si.c /usr/src/sys/pdpuba/si.c
diff -r -c /usr/src/oldsys/pdpuba/tm.c /usr/src/sys/pdpuba/tm.c
diff -r -c /usr/src/oldsys/pdpuba/ts.c /usr/src/sys/pdpuba/ts.c
diff -r -c /usr/src/oldsys/pdpuba/xp.c /usr/src/sys/pdpuba/xp.c
diff -r -c /usr/src/oldsys/sys/init_main.c /usr/src/sys/sys/init_main.c
diff -r -c /usr/src/oldsys/sys/init_sysent.c /usr/src/sys/sys/init_sysent.c
diff -r -c /usr/src/oldsys/sys/kern_acct.c /usr/src/sys/sys/kern_acct.c
diff -r -c /usr/src/oldsys/sys/kern_descrip.c /usr/src/sys/sys/kern_descrip.c
diff -r -c /usr/src/oldsys/sys/kern_exec.c /usr/src/sys/sys/kern_exec.c
diff -r -c /usr/src/oldsys/sys/kern_sig.c /usr/src/sys/sys/kern_sig.c
diff -r -c /usr/src/oldsys/sys/kern_subr.c /usr/src/sys/sys/kern_subr.c
diff -r -c /usr/src/oldsys/sys/quota_kern.c /usr/src/sys/sys/quota_kern.c
diff -r -c /usr/src/oldsys/sys/subr_log.c /usr/src/sys/sys/subr_log.c
diff -r -c /usr/src/oldsys/sys/sys_generic.c /usr/src/sys/sys/sys_generic.c
diff -r -c /usr/src/oldsys/sys/sys_inode.c /usr/src/sys/sys/sys_inode.c
diff -r -c /usr/src/oldsys/sys/sys_kern.c /usr/src/sys/sys/sys_kern.c
diff -r -c /usr/src/oldsys/sys/sys_net.c /usr/src/sys/sys/sys_net.c
diff -r -c /usr/src/oldsys/sys/sys_pipe.c /usr/src/sys/sys/sys_pipe.c
diff -r -c /usr/src/oldsys/sys/tty.c /usr/src/sys/sys/tty.c
diff -r -c /usr/src/oldsys/sys/tty_pty.c /usr/src/sys/sys/tty_pty.c
diff -r -c /usr/src/oldsys/sys/tty_tb.c /usr/src/sys/sys/tty_tb.c
diff -r -c /usr/src/oldsys/sys/tty_tty.c /usr/src/sys/sys/tty_tty.c
diff -r -c /usr/src/oldsys/sys/ufs_alloc.c /usr/src/sys/sys/ufs_alloc.c
diff -r -c /usr/src/oldsys/sys/ufs_bmap.c /usr/src/sys/sys/ufs_bmap.c
diff -r -c /usr/src/oldsys/sys/ufs_fio.c /usr/src/sys/sys/ufs_fio.c
diff -r -c /usr/src/oldsys/sys/ufs_inode.c /usr/src/sys/sys/ufs_inode.c
diff -r -c /usr/src/oldsys/sys/ufs_mount.c /usr/src/sys/sys/ufs_mount.c
diff -r -c /usr/src/oldsys/sys/ufs_namei.c /usr/src/sys/sys/ufs_namei.c
diff -r -c /usr/src/oldsys/sys/ufs_syscalls.c /usr/src/sys/sys/ufs_syscalls.c
diff -r -c /usr/src/oldsys/sys/uipc_socket.c /usr/src/sys/sys/uipc_socket.c
diff -r -c /usr/src/oldsys/sys/uipc_sys.c /usr/src/sys/sys/uipc_sys.c
diff -r -c /usr/src/oldsys/sys/uipc_usrreq.c /usr/src/sys/sys/uipc_usrreq.c
diff -r -c /usr/src/oldsys/sys/vm_swp.c /usr/src/sys/sys/vm_swp.c
diff -r -c /usr/src/oldsys/sys/vm_text.c /usr/src/sys/sys/vm_text.c
diff -r -c /usr/src/oldsys/OTHERS/berknet/bk.c /usr/src/sys/OTHERS/berknet/bk.c
diff -r -c /usr/src/oldsys/OTHERS/dig_anal/ds.c /usr/src/sys/OTHERS/dig_anal/ds.c
diff -r -c /usr/src/oldsys/OTHERS/dmc11/dmc.c /usr/src/sys/OTHERS/dmc11/dmc.c
diff -r -c /usr/src/oldsys/OTHERS/du11/du.c /usr/src/sys/OTHERS/du11/du.c
diff -r -c /usr/src/oldsys/OTHERS/dv/dv.c /usr/src/sys/OTHERS/dv/dv.c
diff -r -c /usr/src/oldsys/OTHERS/ht/ht.c /usr/src/sys/OTHERS/ht/ht.c
diff -r -c /usr/src/oldsys/OTHERS/multiplexor/mx2.c /usr/src/sys/OTHERS/multiplexor/mx2.c
diff -r -c /usr/src/oldsys/OTHERS/rc/rc.c /usr/src/sys/OTHERS/rc/rc.c
diff -r -c /usr/src/oldsys/OTHERS/versatec/vp.c /usr/src/sys/OTHERS/versatec/vp.c
diff -r -c /usr/src/oldsys/conf/Make.nsunix /usr/src/sys/conf/Make.nsunix
*** /usr/src/oldsys/conf/Make.nsunix	Mon Aug 14 14:36:53 1989
--- /usr/src/sys/conf/Make.nsunix	Mon Apr  9 10:07:18 1990
***************
*** 65,71 ****
  	tm.o ts.o tty.o tty_conf.o tty_subr.o tty_tb.o ufs_alloc.o \
  	ufs_bio.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_namei.o \
  	vm_proc.o vm_sched.o vm_swap.o vm_swp.o vm_text.o xp.o quota_subr.o
! OV1=	sys_generic.o sys_inode2.o ufs_syscalls.o
  OV2=	kern_acct.o kern_exec.o kern_exit.o kern_fork.o kern_resrce.o
  OV3=	kern_rtp.o kern_time.o sys_process.o ufs_mount.o ufs_subr.o uipc_sys.o
  OV4=	dkbad.o kern_sig.o mem.o subr_xxx.o trap.o tty_pty.o tty_tty.o
--- 65,71 ----
  	tm.o ts.o tty.o tty_conf.o tty_subr.o tty_tb.o ufs_alloc.o \
  	ufs_bio.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_namei.o \
  	vm_proc.o vm_sched.o vm_swap.o vm_swp.o vm_text.o xp.o quota_subr.o
! OV1=	sys_generic.o ufs_syscalls.o
  OV2=	kern_acct.o kern_exec.o kern_exit.o kern_fork.o kern_resrce.o
  OV3=	kern_rtp.o kern_time.o sys_process.o ufs_mount.o ufs_subr.o uipc_sys.o
  OV4=	dkbad.o kern_sig.o mem.o subr_xxx.o trap.o tty_pty.o tty_tty.o
diff -r -c /usr/src/oldsys/conf/Make.sunix /usr/src/sys/conf/Make.sunix
*** /usr/src/oldsys/conf/Make.sunix	Mon Aug  7 21:57:10 1989
--- /usr/src/sys/conf/Make.sunix	Mon Apr  9 10:04:43 1990
***************
*** 52,58 ****
  	tty_conf.o tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o ufs_bio.o \
  	ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_namei.o \
  	ufs_subr.o vm_proc.o vm_sched.o vm_swap.o vm_swp.o vm_text.o xp.o
! OV1=	kern_prot.o sys_generic.o sys_inode2.o ufs_syscalls.o mem.o
  OV2=	kern_acct.o kern_exec.o kern_exit.o kern_fork.o kern_resrce.o
  OV3=	clock.o cons.o init_main.o kern_pdp.o kern_rtp.o kern_time.o \
  	kern_xxx.o machdep2.o quota_sys.o subr_prf.o sys_process.o \
--- 52,58 ----
  	tty_conf.o tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o ufs_bio.o \
  	ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_namei.o \
  	ufs_subr.o vm_proc.o vm_sched.o vm_swap.o vm_swp.o vm_text.o xp.o
! OV1=	kern_prot.o sys_generic.o ufs_syscalls.o mem.o
  OV2=	kern_acct.o kern_exec.o kern_exit.o kern_fork.o kern_resrce.o
  OV3=	clock.o cons.o init_main.o kern_pdp.o kern_rtp.o kern_time.o \
  	kern_xxx.o machdep2.o quota_sys.o subr_prf.o sys_process.o \
diff -r -c /usr/src/oldsys/conf/Make.sys /usr/src/sys/conf/Make.sys
*** /usr/src/oldsys/conf/Make.sys	Mon Aug  7 21:57:04 1989
--- /usr/src/sys/conf/Make.sys	Mon Apr  9 10:00:25 1990
***************
*** 23,29 ****
  	${S}/quota_sys.c ${S}/quota_kern.c ${S}/quota_ufs.c		\
  	${S}/quota_subr.c ${S}/subr_log.c ${S}/subr_prf.c ${S}/subr_rmap.c \
  	${S}/subr_xxx.c ${S}/sys_generic.c ${S}/sys_inode.c		\
! 	${S}/sys_inode2.c ${S}/sys_kern.c ${S}/sys_pipe.c		\
  	${S}/sys_process.c ${S}/syscalls.c ${S}/tty.c ${S}/tty_conf.c	\
  	${S}/tty_pty.c ${S}/tty_subr.c ${S}/tty_tb.c ${S}/tty_tty.c	\
  	${S}/ufs_alloc.c ${S}/ufs_bio.c ${S}/ufs_bmap.c			\
--- 23,29 ----
  	${S}/quota_sys.c ${S}/quota_kern.c ${S}/quota_ufs.c		\
  	${S}/quota_subr.c ${S}/subr_log.c ${S}/subr_prf.c ${S}/subr_rmap.c \
  	${S}/subr_xxx.c ${S}/sys_generic.c ${S}/sys_inode.c		\
! 	${S}/sys_kern.c ${S}/sys_pipe.c					\
  	${S}/sys_process.c ${S}/syscalls.c ${S}/tty.c ${S}/tty_conf.c	\
  	${S}/tty_pty.c ${S}/tty_subr.c ${S}/tty_tb.c ${S}/tty_tty.c	\
  	${S}/ufs_alloc.c ${S}/ufs_bio.c ${S}/ufs_bmap.c			\
***************
*** 36,42 ****
  	kern_proc.o kern_prot.o kern_resrce.o kern_rtp.o kern_sig.o	\
  	kern_subr.o kern_synch.o kern_time.o kern_xxx.o quota_sys.o	\
         quota_kern.o quota_ufs.o quota_subr.o subr_log.o subr_prf.o subr_rmap.o \
! 	subr_xxx.o sys_generic.o sys_inode.o sys_inode2.o sys_kern.o	\
  	sys_pipe.o sys_process.o syscalls.o tty.o tty_conf.o tty_pty.o	\
  	tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o	\
  	ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o	\
--- 36,42 ----
  	kern_proc.o kern_prot.o kern_resrce.o kern_rtp.o kern_sig.o	\
  	kern_subr.o kern_synch.o kern_time.o kern_xxx.o quota_sys.o	\
         quota_kern.o quota_ufs.o quota_subr.o subr_log.o subr_prf.o subr_rmap.o \
! 	subr_xxx.o sys_generic.o sys_inode.o sys_kern.o			\
  	sys_pipe.o sys_process.o syscalls.o tty.o tty_conf.o tty_pty.o	\
  	tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o	\
  	ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o	\
diff -r -c /usr/src/oldsys/conf/Make.unix /usr/src/sys/conf/Make.unix
*** /usr/src/oldsys/conf/Make.unix	Mon Aug  7 21:57:13 1989
--- /usr/src/sys/conf/Make.unix	Mon Apr  9 09:53:00 1990
***************
*** 55,61 ****
  	kern_subr.o kern_synch.o kern_time.o kern_xxx.o lp.o machdep.o \
  	machdep2.o mem.o quota_kern.o quota_subr.o quota_sys.o \
  	quota_ufs.o ra.o ram.o rk.o rl.o rx.o si.o subr_prf.o subr_rmap.o \
! 	subr_xxx.o sys_generic.o sys_inode.o sys_inode2.o sys_kern.o \
  	sys_pipe.o sys_process.o syscalls.o tm.o trap.o ts.o tty.o \
  	tty_conf.o tty_pty.o tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o \
  	ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o \
--- 55,61 ----
  	kern_subr.o kern_synch.o kern_time.o kern_xxx.o lp.o machdep.o \
  	machdep2.o mem.o quota_kern.o quota_subr.o quota_sys.o \
  	quota_ufs.o ra.o ram.o rk.o rl.o rx.o si.o subr_prf.o subr_rmap.o \
! 	subr_xxx.o sys_generic.o sys_inode.o sys_kern.o 		\
  	sys_pipe.o sys_process.o syscalls.o tm.o trap.o ts.o tty.o \
  	tty_conf.o tty_pty.o tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o \
  	ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o \
diff -r -c /usr/src/oldsys/conf/param.c /usr/src/sys/conf/param.c
*** /usr/src/oldsys/conf/param.c	Wed Mar  8 14:47:43 1989
--- /usr/src/sys/conf/param.c	Mon Apr  9 11:14:28 1990
***************
*** 14,19 ****
--- 14,20 ----
  #include "../h/proc.h"
  #include "../h/text.h"
  #include "../h/file.h"
+ #include "../h/dir.h"
  #include "../h/inode.h"
  #include "../h/fs.h"
  #include "../h/mount.h"
diff -r -c /usr/src/oldsys/h/dir.h /usr/src/sys/h/dir.h
*** /usr/src/oldsys/h/dir.h	Sat May 16 11:29:22 1987
--- /usr/src/sys/h/dir.h	Thu Apr  5 21:48:18 1990
***************
*** 6,11 ****
--- 6,14 ----
   *	@(#)dir.h	1.1 (2.10BSD Berkeley) 12/1/86
   */

+ #ifndef	_DIR_
+ #define	_DIR_
+
  #ifndef MAXNAMLEN
  #define MAXNAMLEN	14
  #endif
***************
*** 74,76 ****
--- 77,80 ----
  	char	dotdot_name[MAXNAMLEN];
  };
  #endif
+ #endif	_DIR_
diff -r -c /usr/src/oldsys/h/file.h /usr/src/sys/h/file.h
*** /usr/src/oldsys/h/file.h	Mon Jul  4 11:54:18 1988
--- /usr/src/sys/h/file.h	Thu Apr  5 21:45:43 1990
***************
*** 22,27 ****
--- 22,35 ----
  	} f_un;
  	off_t	f_offset;
  };
+
+ struct	fileops {
+ 	int	(*fo_rw)();
+ 	int	(*fo_ioctl)();
+ 	int	(*fo_select)();
+ 	int	(*fo_close)();
+ };
+
  #define f_data		f_un.f_Data
  #define f_socket	f_un.f_Socket

diff -r -c /usr/src/oldsys/h/namei.h /usr/src/sys/h/namei.h
*** /usr/src/oldsys/h/namei.h	Sat Jan 27 00:31:19 1990
--- /usr/src/sys/h/namei.h	Thu Apr  5 22:55:28 1990
***************
*** 16,21 ****
--- 16,45 ----
  #endif

  /*
+  * Encapsulation of namei parameters.
+  * One of these is located in the u. area to
+  * minimize space allocated on the kernel stack.
+  */
+ struct nameidata {
+ 	caddr_t	ni_dirp;		/* pathname pointer */
+ 	short	ni_nameiop;		/* see below */
+ 	short	ni_error;		/* error return if any */
+ 	off_t	ni_endoff;		/* end of useful stuff in directory */
+ 	struct	inode *ni_pdir;		/* inode of parent directory of dirp */
+ 	struct	iovec ni_iovec;		/* MUST be pointed to by ni_iov */
+ 	struct	uio ni_uio;		/* directory I/O parameters */
+ 	struct	v7direct ni_dent;	/* current directory entry */
+ };
+
+ #define	ni_base		ni_iovec.iov_base
+ #define	ni_count	ni_iovec.iov_len
+ #define	ni_iov		ni_uio.uio_iov
+ #define	ni_iovcnt	ni_uio.uio_iovcnt
+ #define	ni_offset	ni_uio.uio_offset
+ #define	ni_segflg	ni_uio.uio_segflg
+ #define	ni_resid	ni_uio.uio_resid
+
+ /*
   * namei operations and modifiers
   */
  #define	LOOKUP		0	/* perform name lookup only */
diff -r -c /usr/src/oldsys/h/uio.h /usr/src/sys/h/uio.h
*** /usr/src/oldsys/h/uio.h	Sat May 16 11:29:21 1987
--- /usr/src/sys/h/uio.h	Thu Apr  5 21:34:00 1990
***************
*** 11,17 ****

  struct iovec {
  	caddr_t	iov_base;
! 	int	iov_len;
  };

  struct uio {
--- 11,17 ----

  struct iovec {
  	caddr_t	iov_base;
! 	u_short	iov_len;
  };

  struct uio {
***************
*** 19,25 ****
  	int	uio_iovcnt;
  	off_t	uio_offset;
  	int	uio_segflg;
! 	int	uio_resid;
  };

  enum	uio_rw { UIO_READ, UIO_WRITE };
--- 19,25 ----
  	int	uio_iovcnt;
  	off_t	uio_offset;
  	int	uio_segflg;
! 	u_short	uio_resid;
  };

  enum	uio_rw { UIO_READ, UIO_WRITE };
diff -r -c /usr/src/oldsys/h/user.h /usr/src/sys/h/user.h
*** /usr/src/oldsys/h/user.h	Fri Apr 29 21:33:51 1988
--- /usr/src/sys/h/user.h	Thu Apr  5 21:41:25 1990
***************
*** 12,17 ****
--- 12,18 ----
  #include "exec.h"
  #include "time.h"
  #include "resource.h"
+ #include "namei.h"
  #else
  #include <machine/fperr.h>
  #include <sys/dir.h>
***************
*** 18,23 ****
--- 19,25 ----
  #include <sys/exec.h>
  #include <sys/time.h>
  #include <sys/resource.h>
+ #include <sys/namei.h>
  #endif

  /*
***************
*** 109,115 ****
  #define	UF_MAPPED 	0x2		/* mapped from device */
  	struct	inode *u_cdir;		/* current directory */
  	struct	inode *u_rdir;		/* root directory of current process */
- 	struct	inode *u_pdir;		/* inode of parent directory of dirp */
  	struct	tty *u_ttyp;		/* controlling tty pointer */
  	dev_t	u_ttyd;			/* controlling tty dev */
  	short	u_cmask;		/* mask for file creation */
--- 111,116 ----
***************
*** 133,145 ****
  	struct	rlimit u_rlimit[RLIM_NLIMITS];
  	struct	quota *u_quota;		/* user's quota structure */

- /* I/O */
- 	caddr_t	u_base;			/* base address for I/O */
- 	u_short	u_count;		/* bytes remaining for I/O */
- 	off_t	u_offset;		/* offset in file for I/O */
- 	char	u_segflg;		/* I/O flag; uio.h */
- 	char	dummy3;			/* room for another char */
-
  /* namei & co. */
  	struct	nameicache {		/* last successful directory search */
  		off_t nc_prevoffset;	/* offset at which last entry found */
--- 134,139 ----
***************
*** 146,154 ****
  		ino_t nc_inumber;	/* inum of cached directory */
  		dev_t nc_dev;		/* dev of cached directory */
  	} u_ncache;
! 	off_t	ni_endoff;		/* end of useful stuff in directory */
! 	caddr_t	u_dirp;			/* pathname pointer */
! 	struct v7direct	u_dent;		/* standard V7 directory structure */

  	short	u_stack[1];		/* kernel stack per user
  					 * extends from u + USIZE*64
--- 140,146 ----
  		ino_t nc_inumber;	/* inum of cached directory */
  		dev_t nc_dev;		/* dev of cached directory */
  	} u_ncache;
! 	struct	nameidata u_nd;

  	short	u_stack[1];		/* kernel stack per user
  					 * extends from u + USIZE*64
diff -r -c /usr/src/oldsys/pdp/cons.c /usr/src/sys/pdp/cons.c
*** /usr/src/oldsys/pdp/cons.c	Tue Jul  5 22:43:13 1988
--- /usr/src/sys/pdp/cons.c	Thu Apr  5 20:19:43 1990
***************
*** 83,103 ****
  }

  /*ARGSUSED*/
! cnread(dev)
  	dev_t dev;
  {
  	register struct tty *tp = &cons[minor(dev)];

! 	return ((*linesw[tp->t_line].l_read)(tp));
  }

  /*ARGSUSED*/
! cnwrite(dev)
  	dev_t dev;
  {
  	register struct tty *tp = &cons[minor(dev)];

! 	return ((*linesw[tp->t_line].l_write)(tp));
  }

  /*ARGSUSED*/
--- 83,104 ----
  }

  /*ARGSUSED*/
! cnread(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
  	register struct tty *tp = &cons[minor(dev)];

! 	return ((*linesw[tp->t_line].l_read)(tp, uio));
  }

  /*ARGSUSED*/
! cnwrite(dev, uio)
  	dev_t dev;
  {
  	register struct tty *tp = &cons[minor(dev)];

! 	return ((*linesw[tp->t_line].l_write)(tp, uio));
  }

  /*ARGSUSED*/
diff -r -c /usr/src/oldsys/pdp/machdep.c /usr/src/sys/pdp/machdep.c
*** /usr/src/oldsys/pdp/machdep.c	Mon Jul  4 12:44:00 1988
--- /usr/src/sys/pdp/machdep.c	Thu Apr  5 16:15:25 1990
***************
*** 146,151 ****
--- 146,164 ----
  	regs[RPS] = scp->sc_ps;
  }

+ physstrat(bp, strat, prio)
+ 	register struct buf *bp;
+ 	int (*strat)(), prio;
+ {
+ 	register int s;
+
+ 	(*strat)(bp);
+ 	s = splbio();
+ 	while ((bp->b_flags & B_DONE) == 0)
+ 		sleep((caddr_t)bp, prio);
+ 	splx(s);
+ }
+
  #ifdef UNIBUS_MAP

  #define	UMAPSIZ	10
diff -r -c /usr/src/oldsys/pdp/machdep2.c /usr/src/sys/pdp/machdep2.c
*** /usr/src/oldsys/pdp/machdep2.c	Sat Jan 27 20:04:11 1990
--- /usr/src/sys/pdp/machdep2.c	Thu Apr  5 20:22:18 1990
***************
*** 10,15 ****
--- 10,16 ----
  #include "../machine/seg.h"
  #include "../machine/iopage.h"

+ #include "dir.h"
  #include "inode.h"
  #include "user.h"
  #include "proc.h"
diff -r -c /usr/src/oldsys/pdp/mem.c /usr/src/sys/pdp/mem.c
*** /usr/src/oldsys/pdp/mem.c	Mon Jul 13 12:49:54 1987
--- /usr/src/sys/pdp/mem.c	Thu Apr  5 20:08:00 1990
***************
*** 15,32 ****
  #include "hk.h"
  #include "xp.h"

! mmread(dev)
  	dev_t dev;
  {

! 	return (mmrw(dev, UIO_READ));
  }

! mmwrite(dev)
  	dev_t dev;
  {

! 	return (mmrw(dev, UIO_WRITE));
  }

  /*
--- 15,34 ----
  #include "hk.h"
  #include "xp.h"

! mmread(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {

! 	return (mmrw(dev, uio, UIO_READ));
  }

! mmwrite(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {

! 	return (mmrw(dev, uio, UIO_WRITE));
  }

  /*
***************
*** 34,74 ****
   * kernel as it assumes normal mapping and doesn't
   * bother to save R5.
   */
! mmrw(dev, rw)
  	dev_t dev;
  	enum uio_rw rw;
  {
! 	switch (minor(dev)) {

! 	case 0: /* minor device 0 is physical memory */
! 		{
! 			register u_int on;
! 			register int error;

! 			while (u.u_count) {
! 				mapseg5((memaddr)(u.u_offset>>6),
  				   ((btoc(8192)-1)<<8)|RW);
! 				on = u.u_offset & 077L;
! 				error = uiomove(SEG5+on,
! 				    MIN(u.u_count, 8192-on), rw);
! 				if (error)
! 					break;
! 			}
  			normalseg5();
! 			return(error);
  		}
!
! 	case 1: /* minor device 1 is kernel memory */
! 		return(uiomove((caddr_t)u.u_offset, (int)u.u_count, rw));
!
! 	case 2: /* minor device 2 is EOF/RATHOLE */
! 		if (rw == UIO_READ)
! 			return(0);
! 		u.u_base += u.u_count;
! 		u.u_offset += u.u_count;
! 		u.u_count = 0;
! 		return(0);
  	}
  }

  #if NHK > 0 || NXPD > 0
--- 36,90 ----
   * kernel as it assumes normal mapping and doesn't
   * bother to save R5.
   */
! mmrw(dev, uio, rw)
  	dev_t dev;
+ 	register struct uio *uio;
  	enum uio_rw rw;
  {
! 	register struct iovec *iov;
! 	int error = 0;
! register u_int c;
! 	u_int on;

! 	while (uio->uio_resid && error == 0) {
! 		iov = uio->uio_iov;
! 		if (iov->iov_len == 0) {
! 			uio->uio_iov++;
! 			uio->uio_iovcnt--;
! 			if (uio->uio_iovcnt < 0)
! 				panic("mmrw");
! 			continue;
! 		}
! 		switch (minor(dev)) {

! /* minor device 0 is physical memory */
! 		case 0:
! 			mapseg5((memaddr)(uio->uio_offset>>6),
  				   ((btoc(8192)-1)<<8)|RW);
! 			on = uio->uio_offset & 077L;
! 			c = MIN(iov->iov_len, 8192 - on);
! 			error = uiomove(SEG5+on, c, rw, uio);
  			normalseg5();
! 			continue;
! /* minor device 1 is kernel memory */
! 		case 1:
! 			error = uiomove((caddr_t)uio->uio_offset, iov->iov_len, rw, uio);
! 			continue;
! /* minor device 2 is EOF/RATHOLE */
! 		case 2:
! 			if (rw == UIO_READ)
! 				return(0);
! 			c = iov->iov_len;
! 			break;
  		}
! 		if (error)
! 			break;
! 		iov->iov_base += c;
! 		iov->iov_len -= c;
! 		uio->uio_offset += c;
! 		uio->uio_resid -= c;
  	}
+ 	return(error);
  }

  #if NHK > 0 || NXPD > 0
diff -r -c /usr/src/oldsys/pdp/net_mac.h /usr/src/sys/pdp/net_mac.h
*** /usr/src/oldsys/pdp/net_mac.h	Fri Sep  2 20:44:27 1988
--- /usr/src/sys/pdp/net_mac.h	Thu Apr  5 20:15:25 1990
***************
*** 159,172 ****
  	    so, ub)

  int soreceive();
! #define	SORECEIVE(so, aname, flags, rightsp) \
  	KScall(soreceive, sizeof(struct socket *) + sizeof(struct mbuf **) + \
! 	    sizeof(int) + sizeof(struct mbuf **), so, aname, flags, rightsp)

  int sosend();
! #define	SOSEND(so, nam, flags, rights) \
  	KScall(sosend, sizeof(struct socket *) + sizeof(struct mbuf *) + \
! 	    sizeof(int) + sizeof(struct mbuf *), so, nam, flags, rights)

  int sosetopt();
  #define	SOSETOPT(so, level, optname, m0) \
--- 159,174 ----
  	    so, ub)

  int soreceive();
! #define	SORECEIVE(so, aname, uiop, flags, rightsp) \
  	KScall(soreceive, sizeof(struct socket *) + sizeof(struct mbuf **) + \
! 	    sizeof(struct uio *) + sizeof(int) + sizeof(struct mbuf **), \
! 	    so, aname, uiop, flags, rightsp)

  int sosend();
! #define	SOSEND(so, nam, uiop, flags, rights) \
  	KScall(sosend, sizeof(struct socket *) + sizeof(struct mbuf *) + \
! 	    sizeof(struct uio *) + sizeof(int) + sizeof(struct mbuf *), \
! 	    so, nam, uiop, flags, rights)

  int sosetopt();
  #define	SOSETOPT(so, level, optname, m0) \
diff -r -c /usr/src/oldsys/pdpuba/br.c /usr/src/sys/pdpuba/br.c
*** /usr/src/oldsys/pdpuba/br.c	Mon Aug  7 21:56:47 1989
--- /usr/src/sys/pdpuba/br.c	Tue Apr  3 17:36:33 1990
***************
*** 354,369 ****
  	brstart();
  }

! brread(dev)
  	int dev;
  {
! 	return(physio(brstrategy, &rbrbuf, dev, B_READ, WORD));
  }

! brwrite(dev)
  	int dev;
  {
! 	return(physio(brstrategy, &rbrbuf, dev, B_WRITE, WORD));
  }

  #ifdef BR_DUMP
--- 354,371 ----
  	brstart();
  }

! brread(dev, uio)
  	int dev;
+ 	struct uio *uio;
  {
! 	return(physio(brstrategy, &rbrbuf, dev, B_READ, WORD, uio));
  }

! brwrite(dev, uio)
  	int dev;
+ 	struct uio *uio;
  {
! 	return(physio(brstrategy, &rbrbuf, dev, B_WRITE, WORD, uio));
  }

  #ifdef BR_DUMP
diff -r -c /usr/src/oldsys/pdpuba/dh.c /usr/src/sys/pdpuba/dh.c
*** /usr/src/oldsys/pdpuba/dh.c	Sat Aug 26 23:11:40 1989
--- /usr/src/sys/pdpuba/dh.c	Tue Apr  3 19:45:16 1990
***************
*** 192,211 ****
  	ttyclose(tp);
  }

! dhread(dev)
  	dev_t dev;
  {
  	register struct tty *tp = &dh11[UNIT(dev)];

! 	return ((*linesw[tp->t_line].l_read)(tp));
  }

! dhwrite(dev)
  	dev_t dev;
  {
  	register struct tty *tp = &dh11[UNIT(dev)];

! 	return ((*linesw[tp->t_line].l_write)(tp));
  }

  /*
--- 192,213 ----
  	ttyclose(tp);
  }

! dhread(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
  	register struct tty *tp = &dh11[UNIT(dev)];

! 	return ((*linesw[tp->t_line].l_read)(tp, uio));
  }

! dhwrite(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
  	register struct tty *tp = &dh11[UNIT(dev)];

! 	return ((*linesw[tp->t_line].l_write)(tp, uio));
  }

  /*
diff -r -c /usr/src/oldsys/pdpuba/dhu.c /usr/src/sys/pdpuba/dhu.c
*** /usr/src/oldsys/pdpuba/dhu.c	Fri Sep  2 21:03:56 1988
--- /usr/src/sys/pdpuba/dhu.c	Tue Apr  3 16:50:14 1990
***************
*** 217,236 ****
  	ttyclose(tp);
  }

! dhuread(dev)
  	dev_t dev;
  {
  	register struct tty *tp = &dhu_tty[UNIT(dev)];

! 	return ((*linesw[tp->t_line].l_read)(tp));
  }

! dhuwrite(dev)
  	dev_t dev;
  {
  	register struct tty *tp = &dhu_tty[UNIT(dev)];

! 	return ((*linesw[tp->t_line].l_write)(tp));
  }

  /*
--- 217,238 ----
  	ttyclose(tp);
  }

! dhuread(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
  	register struct tty *tp = &dhu_tty[UNIT(dev)];

! 	return ((*linesw[tp->t_line].l_read)(tp, uio));
  }

! dhuwrite(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
  	register struct tty *tp = &dhu_tty[UNIT(dev)];

! 	return ((*linesw[tp->t_line].l_write)(tp, uio));
  }

  /*
diff -r -c /usr/src/oldsys/pdpuba/dn.c /usr/src/sys/pdpuba/dn.c
*** /usr/src/oldsys/pdpuba/dn.c	Fri Apr 29 20:05:39 1988
--- /usr/src/sys/pdpuba/dn.c	Tue Apr  3 21:25:01 1990
***************
*** 52,59 ****
  	return(0);
  }

! dnwrite(dev)
  register dev_t	dev;
  {
  	register int c, *dp;
  	int s;
--- 52,60 ----
  	return(0);
  }

! dnwrite(dev, uio)
  register dev_t	dev;
+ register struct uio *uio;
  {
  	register int c, *dp;
  	int s;
***************
*** 62,68 ****
  	dp = (int *)&(dn_addr[dev >> 2]->dnisr[dev & 03]);
  	while ((*dp & (DN_PWI | DN_ACR | DN_DSS)) == 0) {
  		s = spl4();
! 		if ((*dp & DN_FPND) == 0 || !u.u_count || (c = uwritec()) < 0)
  			sleep((caddr_t) dp, DNPRI);
  		else if (c == '-') {
  			sleep((caddr_t) &lbolt, DNPRI);
--- 63,69 ----
  	dp = (int *)&(dn_addr[dev >> 2]->dnisr[dev & 03]);
  	while ((*dp & (DN_PWI | DN_ACR | DN_DSS)) == 0) {
  		s = spl4();
! 		if ((*dp & DN_FPND) == 0 || !uio->uio_resid || (c = uwritec(uio)) < 0)
  			sleep((caddr_t) dp, DNPRI);
  		else if (c == '-') {
  			sleep((caddr_t) &lbolt, DNPRI);
diff -r -c /usr/src/oldsys/pdpuba/dr.c /usr/src/sys/pdpuba/dr.c
*** /usr/src/oldsys/pdpuba/dr.c	Sun Jan 17 08:21:40 1988
--- /usr/src/sys/pdpuba/dr.c	Tue Apr  3 16:43:20 1990
***************
*** 202,219 ****
  		drstart(drptr);
  }

! drread(dev)
  	dev_t dev;
  {
  	return (physio(drstrategy, &dr11[minor(dev) & 07].i_buf,
! 	    dev, B_READ, WORD));
  }

! drwrite(dev)
  	dev_t dev;
  {
  	return (physio(drstrategy, &dr11[minor(dev) & 07].i_buf,
! 	    dev, B_WRITE, WORD));
  }

  drioctl(dev, cmd, data, flag)
--- 202,221 ----
  		drstart(drptr);
  }

! drread(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
  	return (physio(drstrategy, &dr11[minor(dev) & 07].i_buf,
! 	    dev, B_READ, WORD, uio));
  }

! drwrite(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
  	return (physio(drstrategy, &dr11[minor(dev) & 07].i_buf,
! 	    dev, B_WRITE, WORD, uio));
  }

  drioctl(dev, cmd, data, flag)
diff -r -c /usr/src/oldsys/pdpuba/dz.c /usr/src/sys/pdpuba/dz.c
*** /usr/src/oldsys/pdpuba/dz.c	Mon Aug  7 21:57:00 1989
--- /usr/src/sys/pdpuba/dz.c	Tue Apr  3 15:44:25 1990
***************
*** 186,207 ****
  	ttyclose(tp);
  }

! dzread(dev)
  	register dev_t	dev;
  {
  	register struct tty *tp;

  	tp = &dz_tty[UNIT(dev)];
! 	return ((*linesw[tp->t_line].l_read)(tp));
  }

! dzwrite(dev)
  	register dev_t	dev;
  {
  	register struct tty *tp;

  	tp = &dz_tty[UNIT(dev)];
! 	return ((*linesw[tp->t_line].l_write)(tp));
  }

  /*ARGSUSED*/
--- 186,209 ----
  	ttyclose(tp);
  }

! dzread(dev, uio)
  	register dev_t	dev;
+ 	struct uio *uio;
  {
  	register struct tty *tp;

  	tp = &dz_tty[UNIT(dev)];
! 	return ((*linesw[tp->t_line].l_read)(tp, uio));
  }

! dzwrite(dev, uio)
  	register dev_t	dev;
+ 	struct uio *uio;
  {
  	register struct tty *tp;

  	tp = &dz_tty[UNIT(dev)];
! 	return ((*linesw[tp->t_line].l_write)(tp, uio));
  }

  /*ARGSUSED*/
diff -r -c /usr/src/oldsys/pdpuba/hk.c /usr/src/sys/pdpuba/hk.c
*** /usr/src/oldsys/pdpuba/hk.c	Sun Jan 17 08:27:58 1988
--- /usr/src/sys/pdpuba/hk.c	Tue Apr  3 14:44:30 1990
***************
*** 493,508 ****
  		hkaddr->hkcs1 = HK_IE;
  }

! hkread(dev)
  	dev_t dev;
  {
! 	return (physio(hkstrategy, &rhkbuf[hkunit(dev)], dev, B_READ, WORD));
  }

! hkwrite(dev)
  	dev_t dev;
  {
! 	return (physio(hkstrategy, &rhkbuf[hkunit(dev)], dev, B_WRITE, WORD));
  }

  #ifdef HK_DUMP
--- 493,510 ----
  		hkaddr->hkcs1 = HK_IE;
  }

! hkread(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
! 	return (physio(hkstrategy, &rhkbuf[hkunit(dev)], dev, B_READ, WORD, uio));
  }

! hkwrite(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
! 	return (physio(hkstrategy, &rhkbuf[hkunit(dev)], dev, B_WRITE, WORD, uio));
  }

  #ifdef HK_DUMP
diff -r -c /usr/src/oldsys/pdpuba/ht.c /usr/src/sys/pdpuba/ht.c
*** /usr/src/oldsys/pdpuba/ht.c	Sun Jan 17 08:30:38 1988
--- /usr/src/sys/pdpuba/ht.c	Tue Apr  3 23:00:43 1990
***************
*** 403,429 ****
  	HTADDR->htcs1 = HT_DCLR | HT_GO;
  }

! htread(dev)
  register dev_t	dev;
  {
! 	htphys(dev);
! 	return (physio(htstrategy, &rhtbuf, dev, B_READ, BYTE));
  }

! htwrite(dev)
  register dev_t	dev;
  {
! 	htphys(dev);
! 	return (physio(htstrategy, &rhtbuf, dev, B_WRITE, BYTE));
  }

! htphys(dev)
  dev_t dev;
  {
  	daddr_t a;
  	register struct softc *sc = &tu_softc[TUUNIT(dev)];

! 	a = dbtofsb(u.u_offset >> 9);
  	sc->sc_blkno = a;
  	sc->sc_nxrec = a + 1;
  }
--- 403,432 ----
  	HTADDR->htcs1 = HT_DCLR | HT_GO;
  }

! htread(dev, uio)
  register dev_t	dev;
+ register struct uio *uio;
  {
! 	htphys(dev, uio);
! 	return (physio(htstrategy, &rhtbuf, dev, B_READ, BYTE, uio));
  }

! htwrite(dev, uio)
  register dev_t	dev;
+ register struct uio *uio;
  {
! 	htphys(dev, uio);
! 	return (physio(htstrategy, &rhtbuf, dev, B_WRITE, BYTE, uio));
  }

! htphys(dev, uio)
  dev_t dev;
+ register struct uio *uio;
  {
  	daddr_t a;
  	register struct softc *sc = &tu_softc[TUUNIT(dev)];

! 	a = dbtofsb(uio->uio_offset >> 9);
  	sc->sc_blkno = a;
  	sc->sc_nxrec = a + 1;
  }
diff -r -c /usr/src/oldsys/pdpuba/lp.c /usr/src/sys/pdpuba/lp.c
*** /usr/src/oldsys/pdpuba/lp.c	Sat Aug  8 16:53:58 1987
--- /usr/src/sys/pdpuba/lp.c	Tue Apr  3 21:33:17 1990
***************
*** 109,116 ****
  	sc->sc_state &= ~OPEN;
  }

! lpwrite(dev)
  	register dev_t dev;
  {
  	register int n;
  	register char *cp;
--- 109,117 ----
  	sc->sc_state &= ~OPEN;
  }

! lpwrite(dev, uio)
  	register dev_t dev;
+ 	register struct uio *uio;
  {
  	register int n;
  	register char *cp;
***************
*** 117,125 ****
  	char inbuf[LPBUFSIZE];
  	int error;

! 	while (n = MIN(LPBUFSIZE, u.u_count)) {
  		cp = inbuf;
! 		error = uiomove(cp, (int)n, UIO_WRITE);
  		if (error)
  			return (error);
  		do
--- 118,126 ----
  	char inbuf[LPBUFSIZE];
  	int error;

! 	while (n = MIN(LPBUFSIZE, uio->uio_resid)) {
  		cp = inbuf;
! 		error = uiomove(cp, (int)n, UIO_WRITE, uio);
  		if (error)
  			return (error);
  		do
diff -r -c /usr/src/oldsys/pdpuba/ra.c /usr/src/sys/pdpuba/ra.c
*** /usr/src/oldsys/pdpuba/ra.c	Tue Sep 27 13:48:19 1988
--- /usr/src/sys/pdpuba/ra.c	Tue Apr  3 13:46:32 1990
***************
*** 516,523 ****
  	return(disk);
  }

! raread(dev)
! 	dev_t 				dev;
  {
  	register	ra_infoT	*disk;

--- 516,524 ----
  	return(disk);
  }

! raread(dev, uio)
! 	dev_t 	dev;
! 	struct	uio *uio;
  {
  	register	ra_infoT	*disk;

***************
*** 525,535 ****
  	if ((disk = rarawcheck(dev)) == NULL)
  		return(ENXIO);

! 	return(physio(rastrategy, &disk->ra_rtab, dev, B_READ, WORD));
  }

! rawrite(dev)
! 	dev_t 				dev;
  {
  	register	ra_infoT	*disk;

--- 526,537 ----
  	if ((disk = rarawcheck(dev)) == NULL)
  		return(ENXIO);

! 	return(physio(rastrategy, &disk->ra_rtab, dev, B_READ, WORD, uio));
  }

! rawrite(dev, uio)
! 	dev_t 	dev;
! 	struct	uio *uio;
  {
  	register	ra_infoT	*disk;

***************
*** 537,543 ****
  	if ((disk = rarawcheck(dev)) == NULL)
  		return(ENXIO);

! 	return(physio(rastrategy, &disk->ra_rtab, dev, B_WRITE, WORD));
  }

  /* Start i/o, must be called at level splbio */
--- 539,545 ----
  	if ((disk = rarawcheck(dev)) == NULL)
  		return(ENXIO);

! 	return(physio(rastrategy, &disk->ra_rtab, dev, B_WRITE, WORD, uio));
  }

  /* Start i/o, must be called at level splbio */
diff -r -c /usr/src/oldsys/pdpuba/rk.c /usr/src/sys/pdpuba/rk.c
*** /usr/src/oldsys/pdpuba/rk.c	Fri Sep  2 21:06:18 1988
--- /usr/src/sys/pdpuba/rk.c	Tue Apr  3 13:32:23 1990
***************
*** 168,182 ****
  	rkstart();
  }

! rkread(dev)
  	register dev_t dev;
  {
! 	return (physio(rkstrategy, &rrkbuf[rkunit(dev)], dev, B_READ, WORD));
  }

! rkwrite(dev)
  	register dev_t dev;
  {
! 	return (physio(rkstrategy, &rrkbuf[rkunit(dev)], dev, B_WRITE, WORD));
  }
  #endif NRK
--- 168,184 ----
  	rkstart();
  }

! rkread(dev, uio)
  	register dev_t dev;
+ 	struct	uio *uio;
  {
! 	return (physio(rkstrategy, &rrkbuf[rkunit(dev)], dev, B_READ, WORD, uio));
  }

! rkwrite(dev, uio)
  	register dev_t dev;
+ 	struct	uio *uio;
  {
! 	return (physio(rkstrategy, &rrkbuf[rkunit(dev)], dev, B_WRITE, WORD, uio));
  }
  #endif NRK
diff -r -c /usr/src/oldsys/pdpuba/rl.c /usr/src/sys/pdpuba/rl.c
*** /usr/src/oldsys/pdpuba/rl.c	Sun Jan 17 08:22:53 1988
--- /usr/src/sys/pdpuba/rl.c	Tue Apr  3 13:26:00 1990
***************
*** 289,304 ****
  #endif
  }

! rlread(dev)
  	register dev_t dev;
  {
! 	return (physio(rlstrategy, &rrlbuf[minor(dev)], dev, B_READ, WORD));
  }

! rlwrite(dev)
  	register dev_t dev;
  {
! 	return (physio(rlstrategy, &rrlbuf[minor(dev)], dev, B_WRITE, WORD));
  }

  /*
--- 289,306 ----
  #endif
  }

! rlread(dev, uio)
  	register dev_t dev;
+ 	struct uio *uio;
  {
! 	return (physio(rlstrategy, &rrlbuf[minor(dev)], dev, B_READ, WORD, uio));
  }

! rlwrite(dev, uio)
  	register dev_t dev;
+ 	struct uio *uio;
  {
! 	return (physio(rlstrategy, &rrlbuf[minor(dev)], dev, B_WRITE, WORD, uio));
  }

  /*
diff -r -c /usr/src/oldsys/pdpuba/rx.c /usr/src/sys/pdpuba/rx.c
*** /usr/src/oldsys/pdpuba/rx.c	Sat Dec 24 20:14:29 1988
--- /usr/src/sys/pdpuba/rx.c	Tue Apr  3 11:10:34 1990
***************
*** 299,315 ****
  		(*xmem)++;
  }

! rxread(dev)
  	dev_t dev;
  {
! 	return (physio(rxstrategy, &rrxbuf, dev, B_READ, WORD));
  }


! rxwrite(dev)
  	dev_t dev;
  {
! 	return (physio(rxstrategy, &rrxbuf, dev, B_WRITE, WORD));
  }

  /*
--- 299,317 ----
  		(*xmem)++;
  }

! rxread(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
! 	return (physio(rxstrategy, &rrxbuf, dev, B_READ, WORD, uio));
  }


! rxwrite(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
! 	return (physio(rxstrategy, &rrxbuf, dev, B_WRITE, WORD, uio));
  }

  /*
diff -r -c /usr/src/oldsys/pdpuba/si.c /usr/src/sys/pdpuba/si.c
*** /usr/src/oldsys/pdpuba/si.c	Fri Apr 29 20:05:50 1988
--- /usr/src/sys/pdpuba/si.c	Tue Apr  3 09:59:43 1990
***************
*** 400,415 ****
  	sistart();
  }

! siread(dev)
  	dev_t	dev;
  {
! 	return (physio(sistrategy, &rsibuf, dev, B_READ, WORD));
  }

! siwrite(dev)
  	dev_t	dev;
  {
! 	return (physio(sistrategy, &rsibuf, dev, B_WRITE, WORD));
  }

  #ifdef SI_DUMP
--- 400,417 ----
  	sistart();
  }

! siread(dev, uio)
  	dev_t	dev;
+ 	struct uio *uio;
  {
! 	return (physio(sistrategy, &rsibuf, dev, B_READ, WORD, uio));
  }

! siwrite(dev, uio)
  	dev_t	dev;
+ 	struct uio *uio;
  {
! 	return (physio(sistrategy, &rsibuf, dev, B_WRITE, WORD, uio));
  }

  #ifdef SI_DUMP
diff -r -c /usr/src/oldsys/pdpuba/tm.c /usr/src/sys/pdpuba/tm.c
*** /usr/src/oldsys/pdpuba/tm.c	Fri Sep  2 21:07:01 1988
--- /usr/src/sys/pdpuba/tm.c	Tue Apr  3 21:47:56 1990
***************
*** 574,591 ****
  	sc->sc_nxrec = bn;
  }

! tmread(dev)
  register dev_t dev;
  {
! 	tmphys(dev);
! 	return (physio(tmstrategy, &rtmbuf, dev, B_READ, BYTE));
  }

! tmwrite(dev)
  register dev_t dev;
  {
! 	tmphys(dev);
! 	return (physio(tmstrategy, &rtmbuf, dev, B_WRITE, BYTE));
  }

  /*
--- 574,601 ----
  	sc->sc_nxrec = bn;
  }

! tmread(dev, uio)
  register dev_t dev;
+ register struct uio *uio;
  {
! 	int errno;
!
! 	errno = tmphys(dev, uio);
! 	if (errno)
! 		return (errno);
! 	return (physio(tmstrategy, &rtmbuf, dev, B_READ, BYTE, uio));
  }

! tmwrite(dev, uio)
  register dev_t dev;
+ register struct uio *uio;
  {
! 	int errno;
!
! 	errno = tmphys(dev, uio);
! 	if (errno)
! 		return (errno);
! 	return (physio(tmstrategy, &rtmbuf, dev, B_WRITE, BYTE, uio));
  }

  /*
***************
*** 592,604 ****
   * Set up sc_blkno and sc_nxrec
   * so that the tape will appear positioned correctly.
   */
! tmphys(dev)
  dev_t dev;
  {
  	daddr_t a;
  	register struct te_softc *sc = &te_softc[TEUNIT(dev)];

! 	a = dbtofsb(u.u_offset >> 9);
  	sc->sc_blkno = a;
  	sc->sc_nxrec = a + 1;
  }
--- 602,615 ----
   * Set up sc_blkno and sc_nxrec
   * so that the tape will appear positioned correctly.
   */
! tmphys(dev, uio)
  dev_t dev;
+ register struct uio *uio;
  {
  	daddr_t a;
  	register struct te_softc *sc = &te_softc[TEUNIT(dev)];

! 	a = dbtofsb(uio->uio_offset >> 9);
  	sc->sc_blkno = a;
  	sc->sc_nxrec = a + 1;
  }
diff -r -c /usr/src/oldsys/pdpuba/ts.c /usr/src/sys/pdpuba/ts.c
*** /usr/src/oldsys/pdpuba/ts.c	Fri Sep  2 21:07:06 1988
--- /usr/src/sys/pdpuba/ts.c	Tue Apr  3 09:55:25 1990
***************
*** 684,709 ****
  	return(0);
  }

! tsread(dev)
  	register dev_t	dev;
  {
  	register int error;

! 	error = tsphys(dev);
  	if (error)
  		return (error);
! 	return (physio(tsstrategy, &rtsbuf, dev, B_READ, BYTE));
  }

! tswrite(dev)
  	register dev_t	dev;
  {
  	register int error;

! 	error = tsphys(dev);
  	if (error)
  		return (error);
! 	return (physio(tsstrategy, &rtsbuf, dev, B_WRITE, BYTE));
  }

  /*
--- 684,711 ----
  	return(0);
  }

! tsread(dev, uio)
  	register dev_t	dev;
+ 	register struct uio *uio;
  {
  	register int error;

! 	error = tsphys(dev, uio);
  	if (error)
  		return (error);
! 	return (physio(tsstrategy, &rtsbuf, dev, B_READ, BYTE, uio));
  }

! tswrite(dev, uio)
  	register dev_t	dev;
+ 	register struct uio *uio;
  {
  	register int error;

! 	error = tsphys(dev, uio);
  	if (error)
  		return (error);
! 	return (physio(tsstrategy, &rtsbuf, dev, B_WRITE, BYTE, uio));
  }

  /*
***************
*** 712,719 ****
   * so that the tape will appear positioned correctly.
   */
  static
! tsphys(dev)
  	dev_t	dev;
  {
  	register int tsunit = TSUNIT(dev);
  	register struct ts_softc *sc;
--- 714,722 ----
   * so that the tape will appear positioned correctly.
   */
  static
! tsphys(dev, uio)
  	dev_t	dev;
+ 	register struct uio *uio;
  {
  	register int tsunit = TSUNIT(dev);
  	register struct ts_softc *sc;
***************
*** 722,728 ****
  	if (tsunit >= NTS)
  		return (ENXIO);
  	sc = &ts_softc[tsunit];
! 	a = dbtofsb(u.u_offset >> 9);
  	sc->sc_blkno = a;
  	sc->sc_nxrec = a + 1;
  	return (0);
--- 725,731 ----
  	if (tsunit >= NTS)
  		return (ENXIO);
  	sc = &ts_softc[tsunit];
! 	a = dbtofsb(uio->uio_offset >> 9);
  	sc->sc_blkno = a;
  	sc->sc_nxrec = a + 1;
  	return (0);
diff -r -c /usr/src/oldsys/pdpuba/xp.c /usr/src/sys/pdpuba/xp.c
*** /usr/src/oldsys/pdpuba/xp.c	Tue Sep 27 13:49:02 1988
--- /usr/src/sys/pdpuba/xp.c	Tue Apr  3 09:48:00 1990
***************
*** 881,896 ****
  	xpstart(xc);
  }

! xpread(dev)
  	dev_t	dev;
  {
! 	return (physio(xpstrategy, &rxpbuf[xpunit(dev)], dev, B_READ, WORD));
  }

! xpwrite(dev)
  	dev_t	dev;
  {
! 	return (physio(xpstrategy, &rxpbuf[xpunit(dev)], dev, B_WRITE, WORD));
  }


--- 881,898 ----
  	xpstart(xc);
  }

! xpread(dev, uio)
  	dev_t	dev;
+ 	struct uio *uio;
  {
! 	return (physio(xpstrategy, &rxpbuf[xpunit(dev)], dev, B_READ, WORD, uio));
  }

! xpwrite(dev, uio)
  	dev_t	dev;
+ 	struct uio *uio;
  {
! 	return (physio(xpstrategy, &rxpbuf[xpunit(dev)], dev, B_WRITE, WORD, uio));
  }


diff -r -c /usr/src/oldsys/sys/init_main.c /usr/src/sys/sys/init_main.c
*** /usr/src/oldsys/sys/init_main.c	Sat Feb  3 23:35:19 1990
--- /usr/src/sys/sys/init_main.c	Sat Apr  7 23:39:53 1990
***************
*** 62,67 ****
--- 62,69 ----

  	u.u_procp = p;			/* init user structure */
  	u.u_ap = u.u_arg;
+ 	u.u_nd.ni_iov = &u.u_nd.ni_iovec;
+ 	u.u_nd.ni_iovcnt = 1;
  	u.u_cmask = cmask;
  	u.u_lastfile = -1;
  	for (i = 1; i < NGROUPS; i++)
***************
*** 245,251 ****
   * memory and read the text+data into the memory.  Set up supervisor page
   * registers, SDSA6 and SDSA7 have already been set up in mch_start.s.
   */
! #define	NETNIX	"/netnix"
  static
  netinit()
  {
--- 247,255 ----
   * memory and read the text+data into the memory.  Set up supervisor page
   * registers, SDSA6 and SDSA7 have already been set up in mch_start.s.
   */
!
! static char NETNIX[] = "/netnix";
!
  static
  netinit()
  {
***************
*** 255,285 ****
  	struct inode *ip;
  	memaddr nettext;
  	long lsize;
! 	int initdata, netdsize, nettsize, ret, resid;
  	char oneclick[ctob(1)];

  	ret = 1;
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_dirp = NETNIX;
! 	if (!(ip = namei(LOOKUP | FOLLOW))) {
  		printf("%s: not found.\n", NETNIX);
  		goto leave;
  	}
  	if ((ip->i_mode & IFMT) != IFREG || !ip->i_size) {
! 		printf("%s: bad ip format.\n", NETNIX);
  		goto leave;
  	}
! 	u.u_base = (caddr_t)&ex;
! 	u.u_count = sizeof(ex);
! 	u.u_offset = 0;
! 	readi(ip);
! 	if (u.u_error || u.u_count) {
! 		printf("%s: u_error {%d} u_count {%d}.\n", NETNIX, u.u_error,
! 		    u.u_count);
  		goto leave;
  	}
  	if (ex.a_magic != A_MAGIC3) {
! 		printf("%s: bad magic, %o.\n", NETNIX, ex.a_magic);
  		goto leave;
  	}
  	lsize = (long)ex.a_data + (long)ex.a_bss;
--- 259,289 ----
  	struct inode *ip;
  	memaddr nettext;
  	long lsize;
! 	off_t	off;
! 	int initdata, netdsize, nettsize, ret, err, resid;
  	char oneclick[ctob(1)];
+ 	register struct	nameidata *ndp = &u.u_nd;

  	ret = 1;
! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_SYSSPACE;
! 	ndp->ni_dirp = NETNIX;
! 	if (!(ip = namei(ndp))) {
  		printf("%s: not found.\n", NETNIX);
  		goto leave;
  	}
  	if ((ip->i_mode & IFMT) != IFREG || !ip->i_size) {
! 		printf("%s: bad inode\n", NETNIX);
  		goto leave;
  	}
! 	err = rdwri(UIO_READ, ip, &ex, sizeof (ex), (off_t)0, UIO_SYSSPACE,
! 			&resid);
! 	if (err || resid) {
! 		printf("%s: header err %d\n", NETNIX, ret);
  		goto leave;
  	}
  	if (ex.a_magic != A_MAGIC3) {
! 		printf("%s: bad magic %o.\n", NETNIX, ex.a_magic);
  		goto leave;
  	}
  	lsize = (long)ex.a_data + (long)ex.a_bss;
***************
*** 292,325 ****
  	netdsize = btoc(ex.a_data + ex.a_bss);
  	netdata = (memaddr)malloc(coremap, netdsize);
  	initdata = ex.a_data >> 6;
! 	resid = ex.a_data & 077;
  	for (i = 0; i < nettsize; i++) {
! 		u.u_count = ctob(1);
! 		u.u_base = oneclick;
! 		readi(ip);
! 		if (u.u_error || u.u_count)
  			goto release;
  		mapseg5(nettext + i, 077406);
  		bcopy(oneclick, SEG5, ctob(1));
  		normalseg5();
  	}
  	for (i = 0; i < initdata; i++) {
! 		u.u_count = ctob(1);
! 		u.u_base = oneclick;
! 		readi(ip);
! 		if (u.u_error || u.u_count)
  			goto release;
  		mapseg5(netdata + i, 077406);
  		bcopy(oneclick, SEG5, ctob(1));
  		normalseg5();
  	}
! 	if (resid) {
! 		u.u_count = resid;
! 		u.u_base = oneclick;
! 		readi(ip);
! 		if (u.u_error || u.u_count) {
! release:		printf("%s: u_error {%d} u_count {%d}.\n",
! 			    NETNIX, u.u_error, u.u_count);
  			mfree(coremap, nettsize, nettext);
  			mfree(coremap, netdsize, netdata);
  			nettsize = netdsize = 0;
--- 296,327 ----
  	netdsize = btoc(ex.a_data + ex.a_bss);
  	netdata = (memaddr)malloc(coremap, netdsize);
  	initdata = ex.a_data >> 6;
! 	off = sizeof (ex);
  	for (i = 0; i < nettsize; i++) {
! 		err = rdwri(UIO_READ, ip, oneclick, ctob(1), off, UIO_SYSSPACE,
! 				&resid);
! 		if (err || resid)
  			goto release;
  		mapseg5(nettext + i, 077406);
  		bcopy(oneclick, SEG5, ctob(1));
+ 		off += ctob(1);
  		normalseg5();
  	}
  	for (i = 0; i < initdata; i++) {
! 		err = rdwri(UIO_READ, ip, oneclick, ctob(1), off, UIO_SYSSPACE,
! 				&resid);
! 		if (err || resid)
  			goto release;
  		mapseg5(netdata + i, 077406);
  		bcopy(oneclick, SEG5, ctob(1));
  		normalseg5();
+ 		off += ctob(1);
  	}
! 	if (ex.a_data & 077) {
! 		err = rdwri(UIO_READ, ip, oneclick, ex.a_data & 077, off,
! 				UIO_SYSSPACE, &resid);
! 		if (err || resid) {
! release:		printf("%s: err %d resid %d\n", NETNIX, err, resid);
  			mfree(coremap, nettsize, nettext);
  			mfree(coremap, netdsize, netdata);
  			nettsize = netdsize = 0;
***************
*** 327,333 ****
  			goto leave;
  		}
  		mapseg5(netdata + i, 077406);	/* i is set from above loop */
! 		bcopy(oneclick, SEG5, resid);
  		normalseg5();
  	}
  	for (i = 0, ap = SISA0, dp = SISD0; i < nettsize; i += stoc(1)) {
--- 329,335 ----
  			goto leave;
  		}
  		mapseg5(netdata + i, 077406);	/* i is set from above loop */
! 		bcopy(oneclick, SEG5, ex.a_data & 077);
  		normalseg5();
  	}
  	for (i = 0, ap = SISA0, dp = SISD0; i < nettsize; i += stoc(1)) {
***************
*** 351,367 ****
  leave:	if (ip)
  		iput(ip);
  	u.u_error = 0;
! 	u.u_offset = 0;
! 	u.u_count = 0;
! 	u.u_dirp = 0;
! 	u.u_base = 0;
! 	u.u_segflg = 0;
! 	u.ni_endoff = 0;
  	bzero(&u.u_ncache, sizeof(u.u_ncache));
! 	bzero(&u.u_dent, sizeof(u.u_dent));
! 	if (u.u_pdir) {
! 		iput(u.u_pdir);
! 		u.u_pdir = 0;
  	}
  	return(ret);
  }
--- 353,366 ----
  leave:	if (ip)
  		iput(ip);
  	u.u_error = 0;
! 	ndp->ni_dirp = 0;
! 	ndp->ni_segflg = 0;
! 	ndp->ni_endoff = 0;
  	bzero(&u.u_ncache, sizeof(u.u_ncache));
! 	bzero(&ndp->ni_dent, sizeof(ndp->ni_dent));
! 	if (ndp->ni_pdir) {
! 		iput(ndp->ni_pdir);
! 		ndp->ni_pdir = 0;
  	}
  	return(ret);
  }
diff -r -c /usr/src/oldsys/sys/init_sysent.c /usr/src/sys/sys/init_sysent.c
*** /usr/src/oldsys/sys/init_sysent.c	Wed May 20 18:42:31 1987
--- /usr/src/sys/sys/init_sysent.c	Sun Apr  8 00:38:48 1990
***************
*** 15,24 ****

  int	nosys();

- /* Unimplemented ... */
- #define	readv		nosys
- #define	writev		nosys
-
  /* 1.1 processes and protection */
  int	sethostid(),gethostid(),sethostname(),gethostname(),getpid();
  int	fork(),rexit(),execv(),execve(),wait();
--- 15,20 ----
diff -r -c /usr/src/oldsys/sys/kern_acct.c /usr/src/sys/sys/kern_acct.c
*** /usr/src/oldsys/sys/kern_acct.c	Fri Sep  2 21:10:13 1988
--- /usr/src/sys/sys/kern_acct.c	Sun Apr  8 00:45:42 1990
***************
*** 11,21 ****

  #include "systm.h"
  #include "fs.h"
  #include "inode.h"
  #include "user.h"
  #include "proc.h"
  #include "acct.h"
- #include "namei.h"
  #include "kernel.h"

  /*
--- 11,21 ----

  #include "systm.h"
  #include "fs.h"
+ #include "dir.h"
  #include "inode.h"
  #include "user.h"
  #include "proc.h"
  #include "acct.h"
  #include "kernel.h"

  /*
***************
*** 33,38 ****
--- 33,39 ----
  	register struct a {
  		char	*fname;
  	} *uap = (struct a *)u.u_ap;
+ 	register struct nameidata *ndp = &u.u_nd;

  	if (suser()) {
  		if (savacctp) {
***************
*** 46,54 ****
  			}
  			return;
  		}
! 		u.u_segflg = UIO_USERSPACE;
! 		u.u_dirp = uap->fname;
! 		ip = namei(LOOKUP | FOLLOW);
  		if (ip == NULL)
  			return;
  		if ((ip->i_mode&IFMT) != IFREG) {
--- 47,56 ----
  			}
  			return;
  		}
! 		ndp->ni_nameiop = LOOKUP | FOLLOW;
! 		ndp->ni_segflg = UIO_USERSPACE;
! 		ndp->ni_dirp = uap->fname;
! 		ip = namei(ndp);
  		if (ip == NULL)
  			return;
  		if ((ip->i_mode&IFMT) != IFREG) {
***************
*** 114,125 ****
  	acctbuf.ac_tty = u.u_ttyd;
  	acctbuf.ac_flag = u.u_acflag;
  	siz = ip->i_size;
! 	u.u_offset = siz;
! 	u.u_base = (caddr_t)&acctbuf;
! 	u.u_count = sizeof(acctbuf);
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_error = 0;
! 	writei(ip);
  	if (u.u_error)
  		itrunc(ip, (u_long)siz);
  	iunlock(ip);
--- 116,123 ----
  	acctbuf.ac_tty = u.u_ttyd;
  	acctbuf.ac_flag = u.u_acflag;
  	siz = ip->i_size;
! 	u.u_error = rdwri(UIO_WRITE, ip, &acctbuf, sizeof(acctbuf), siz,
! 			UIO_SYSSPACE, (int *)0);
  	if (u.u_error)
  		itrunc(ip, (u_long)siz);
  	iunlock(ip);
diff -r -c /usr/src/oldsys/sys/kern_descrip.c /usr/src/sys/sys/kern_descrip.c
*** /usr/src/oldsys/sys/kern_descrip.c	Tue Jul  5 15:40:47 1988
--- /usr/src/sys/sys/kern_descrip.c	Sat Apr  7 18:00:00 1990
***************
*** 76,82 ****
  	if (uap->i == uap->j)
  		return;
  	if (u.u_ofile[uap->j]) {
! 		closef(u.u_ofile[uap->j],0);
  		if (u.u_error)
  			return;
  	}
--- 76,82 ----
  	if (uap->i == uap->j)
  		return;
  	if (u.u_ofile[uap->j]) {
! 		closef(u.u_ofile[uap->j]);
  		if (u.u_error)
  			return;
  	}
***************
*** 162,168 ****
  }

  fset(fp, bit, value)
! 	struct file *fp;
  	int bit, value;
  {

--- 162,168 ----
  }

  fset(fp, bit, value)
! register struct file *fp;
  	int bit, value;
  {

***************
*** 171,177 ****
  	else
  		fp->f_flag &= ~bit;
  	return (fioctl(fp, (u_int)(bit == FNDELAY ? FIONBIO : FIOASYNC),
! 	    (caddr_t)&value));
  }

  fgetown(fp, valuep)
--- 171,177 ----
  	else
  		fp->f_flag &= ~bit;
  	return (fioctl(fp, (u_int)(bit == FNDELAY ? FIONBIO : FIOASYNC),
! 			(caddr_t)&value));
  }

  fgetown(fp, valuep)
***************
*** 186,192 ****
  		return (0);
  	}
  #endif
! 	error = ino_ioctl(fp, (u_int)TIOCGPGRP, (caddr_t)valuep);
  	*valuep = -*valuep;
  	return (error);
  }
--- 186,192 ----
  		return (0);
  	}
  #endif
! 	error = fioctl(fp, (u_int)TIOCGPGRP, (caddr_t)valuep);
  	*valuep = -*valuep;
  	return (error);
  }
***************
*** 209,227 ****
  		value = p->p_pgrp;
  	} else
  		value = -value;
! 	return (ino_ioctl(fp, (u_int)TIOCSPGRP, (caddr_t)&value));
  }

  fioctl(fp, cmd, value)
! 	struct file *fp;
  	int cmd;
  	caddr_t value;
  {
! #ifdef UCB_NET
! 	if (fp->f_type == DTYPE_SOCKET)
! 		return (SOO_IOCTL(fp, cmd, value));
! #endif
! 	return (ino_ioctl(fp, cmd, value));
  }

  close()
--- 209,226 ----
  		value = p->p_pgrp;
  	} else
  		value = -value;
! 	return (fioctl(fp, (u_int)TIOCSPGRP, (caddr_t)&value));
  }

+ extern	struct	fileops	*Fops[];
+
  fioctl(fp, cmd, value)
! register struct file *fp;
  	int cmd;
  	caddr_t value;
  {
!
! 	return ((*Fops[fp->f_type]->fo_ioctl)(fp, cmd, value));
  }

  close()
***************
*** 236,242 ****
  	u.u_ofile[i] = NULL;
  	while (u.u_lastfile >= 0 && u.u_ofile[u.u_lastfile] == NULL)
  		u.u_lastfile--;
! 	closef(fp,0);
  	/* WHAT IF u.u_error ? */
  }

--- 235,241 ----
  	u.u_ofile[i] = NULL;
  	while (u.u_lastfile >= 0 && u.u_ofile[u.u_lastfile] == NULL)
  		u.u_lastfile--;
! 	closef(fp);
  	/* WHAT IF u.u_error ? */
  }

***************
*** 365,373 ****
   * Internal form of close.
   * Decrement reference count on file structure.
   */
! closef(fp,nouser)
  	register struct file *fp;
- 	int nouser;
  {

  	if (fp == NULL)
--- 364,371 ----
   * Internal form of close.
   * Decrement reference count on file structure.
   */
! closef(fp)
  	register struct file *fp;
  {

  	if (fp == NULL)
***************
*** 376,397 ****
  		fp->f_count--;
  		return;
  	}
! 	switch (fp->f_type) {
! 		case DTYPE_PIPE:
! 		case DTYPE_INODE:
! 			ino_close(fp);
! 			break;
! #ifdef UCB_NET
! 		case DTYPE_SOCKET:
! 			u.u_error = 0;			/* XXX */
! 			SOCLOSE(fp->f_socket);
! 			if (nouser == 0 && u.u_error)
! 				return;
! 			fp->f_socket = 0;
! 			u.u_error = 0;
! 			break;
! #endif
! 	}
  	fp->f_count = 0;
  }

--- 374,380 ----
  		fp->f_count--;
  		return;
  	}
! 	(*Fops[fp->f_type]->fo_close)(fp);
  	fp->f_count = 0;
  }

diff -r -c /usr/src/oldsys/sys/kern_exec.c /usr/src/sys/sys/kern_exec.c
*** /usr/src/oldsys/sys/kern_exec.c	Tue Jul  5 15:41:23 1988
--- /usr/src/sys/sys/kern_exec.c	Sat Apr  7 20:07:25 1990
***************
*** 57,67 ****
  		char	ex_shell[SHSIZE];	/* #! and name of interpreter */
  		struct	exec ex_exec;
  	} exdata;
! 	int error;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = ((struct execa *)u.u_ap)->fname;
! 	if ((ip = namei(LOOKUP | FOLLOW)) == NULL)
  		return;
  	bno = 0;
  	bp = 0;
--- 57,69 ----
  		char	ex_shell[SHSIZE];	/* #! and name of interpreter */
  		struct	exec ex_exec;
  	} exdata;
! 	register struct	nameidata *ndp = &u.u_nd;
! 	int resid, error;

! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = ((struct execa *)u.u_ap)->fname;
! 	if ((ip = namei(ndp)) == NULL)
  		return;
  	bno = 0;
  	bp = 0;
***************
*** 102,116 ****
  	 * THE ASCII LINE.
  	 */
  	exdata.ex_shell[0] = '\0';	/* for zero length files */
! 	u.u_base = (caddr_t)&exdata;
! 	u.u_count = sizeof(exdata);
! 	u.u_offset = 0;
! 	u.u_segflg = UIO_SYSSPACE;
! 	readi(ip);
! 	u.u_segflg = UIO_USERSPACE;
  	if (u.u_error)
  		goto bad;
! 	if (u.u_count > sizeof(exdata) - sizeof(exdata.ex_exec) &&
  	    exdata.ex_shell[0] != '#') {
  		u.u_error = ENOEXEC;
  		goto bad;
--- 104,114 ----
  	 * THE ASCII LINE.
  	 */
  	exdata.ex_shell[0] = '\0';	/* for zero length files */
! 	u.u_error = rdwri(UIO_READ, ip, &exdata, sizeof(exdata), (off_t)0,
! 				UIO_SYSSPACE, &resid);
  	if (u.u_error)
  		goto bad;
! 	if (resid > sizeof(exdata) - sizeof(exdata.ex_exec) &&
  	    exdata.ex_shell[0] != '#') {
  		u.u_error = ENOEXEC;
  		goto bad;
***************
*** 150,156 ****
  		cp = &exdata.ex_shell[2];
  		while (*cp == ' ')
  			cp++;
! 		u.u_dirp = cp;
  		while (*cp && *cp != ' ')
  			cp++;
  		cfarg[0] = '\0';
--- 148,154 ----
  		cp = &exdata.ex_shell[2];
  		while (*cp == ' ')
  			cp++;
! 		ndp->ni_dirp = cp;
  		while (*cp && *cp != ' ')
  			cp++;
  		cfarg[0] = '\0';
***************
*** 163,174 ****
  		}
  		indir = 1;
  		iput(ip);
! 		u.u_segflg = UIO_SYSSPACE;
! 		ip = namei(LOOKUP | FOLLOW);
! 		u.u_segflg = UIO_USERSPACE;
  		if (ip == NULL)
  			return;
! 		bcopy((caddr_t)u.u_dent.d_name, (caddr_t)cfname, MAXCOMLEN);
  		cfname[MAXCOMLEN] = '\0';
  		goto again;
  	}
--- 161,172 ----
  		}
  		indir = 1;
  		iput(ip);
! 		ndp->ni_nameiop = LOOKUP | FOLLOW;
! 		ndp->ni_segflg = UIO_SYSSPACE;
! 		ip = namei(ndp);
  		if (ip == NULL)
  			return;
! 		bcopy((caddr_t)ndp->ni_dent.d_name, (caddr_t)cfname, MAXCOMLEN);
  		cfname[MAXCOMLEN] = '\0';
  		goto again;
  	}
***************
*** 355,361 ****
  	if (indir)
  		bcopy((caddr_t)cfname, (caddr_t)u.u_comm, MAXCOMLEN);
  	else
! 		bcopy((caddr_t)u.u_dent.d_name, (caddr_t)u.u_comm, MAXCOMLEN);
  bad:
  	if (bp) {
  		mapout(bp);
--- 353,359 ----
  	if (indir)
  		bcopy((caddr_t)cfname, (caddr_t)u.u_comm, MAXCOMLEN);
  	else
! 		bcopy((caddr_t)ndp->ni_dent.d_name, (caddr_t)u.u_comm, MAXCOMLEN);
  bad:
  	if (bp) {
  		mapout(bp);
***************
*** 430,436 ****

  	for (cnt = u.u_lastfile;cnt >= 0; cnt--, ofilep++, pofilep++)
  		if (*pofilep & UF_EXCLOSE) {
! 			closef(*ofilep,1);
  			*ofilep = NULL;
  			*pofilep = 0;
  		}
--- 428,434 ----

  	for (cnt = u.u_lastfile;cnt >= 0; cnt--, ofilep++, pofilep++)
  		if (*pofilep & UF_EXCLOSE) {
! 			closef(*ofilep);
  			*ofilep = NULL;
  			*pofilep = 0;
  		}
***************
*** 448,456 ****
  {
  	struct u_ovd sovdata;
  	long lsize;
  	u_int ds, ts, ss;
  	u_int ovhead[NOVL + 1];
! 	int sep, overlay, ovflag, ovmax;

  	overlay = sep = ovflag = 0;
  	switch(ep->a_magic) {
--- 446,455 ----
  {
  	struct u_ovd sovdata;
  	long lsize;
+ 	off_t	offset;
  	u_int ds, ts, ss;
  	u_int ovhead[NOVL + 1];
! 	int sep, overlay, ovflag, ovmax, resid;

  	overlay = sep = ovflag = 0;
  	switch(ep->a_magic) {
***************
*** 517,529 ****
  	u.u_ovdata.uo_ovbase = 0;
  	u.u_ovdata.uo_curov = 0;
  	if (ovflag) {
! 		u.u_base = (caddr_t)ovhead;
! 		u.u_count = sizeof(ovhead);
! 		u.u_offset = sizeof(struct exec);
! 		u.u_segflg = UIO_SYSSPACE;
! 		readi(ip);
! 		u.u_segflg = UIO_USERSPACE;
! 		if (u.u_count != 0)
  			u.u_error = ENOEXEC;
  		if (u.u_error) {
  			u.u_ovdata = sovdata;
--- 516,524 ----
  	u.u_ovdata.uo_ovbase = 0;
  	u.u_ovdata.uo_curov = 0;
  	if (ovflag) {
! 		u.u_error = rdwri(UIO_READ, ip, ovhead, sizeof(ovhead),
! 			(off_t)sizeof(struct exec), UIO_SYSSPACE, &resid);
! 		if (resid != 0)
  			u.u_error = ENOEXEC;
  		if (u.u_error) {
  			u.u_ovdata = sovdata;
***************
*** 607,622 ****
  		 * read in data segment
  		 */
  		estabur((u_int)0, ds, (u_int)0, 0, RO);
! 		u.u_base = 0;
! 		u.u_offset = sizeof(struct exec);
  		if (ovflag) {
! 			u.u_offset += sizeof(ovhead);
! 			u.u_offset += (((long)u.u_ovdata.uo_ov_offst[NOVL]) << 6);
  		}
  		else
! 			u.u_offset += ep->a_text;
! 		u.u_count = ep->a_data;
! 		readi(ip);

  		/*
  		 * set SUID/SGID protections, if no tracing
--- 602,616 ----
  		 * read in data segment
  		 */
  		estabur((u_int)0, ds, (u_int)0, 0, RO);
! 		offset = sizeof(struct exec);
  		if (ovflag) {
! 			offset += sizeof(ovhead);
! 			offset += (((long)u.u_ovdata.uo_ov_offst[NOVL]) << 6);
  		}
  		else
! 			offset += ep->a_text;
! 		rdwri(UIO_READ, ip, (caddr_t) 0, ep->a_data, offset,
! 			UIO_USERSPACE, 0);

  		/*
  		 * set SUID/SGID protections, if no tracing
diff -r -c /usr/src/oldsys/sys/kern_sig.c /usr/src/sys/sys/kern_sig.c
*** /usr/src/oldsys/sys/kern_sig.c	Wed Feb 28 13:19:53 1990
--- /usr/src/sys/sys/kern_sig.c	Sat Apr  7 22:39:58 1990
***************
*** 805,811 ****
  core()
  {
  	register struct inode *ip;
! 	register u_int s;

  	if (u.u_uid != u.u_ruid || u.u_gid != u.u_rgid)
  		return (0);
--- 805,811 ----
  core()
  {
  	register struct inode *ip;
! 	register struct	nameidata *ndp = &u.u_nd;

  	if (u.u_uid != u.u_ruid || u.u_gid != u.u_rgid)
  		return (0);
***************
*** 815,828 ****
  	if (u.u_procp->p_textp && access(u.u_procp->p_textp->x_iptr, IREAD))
  		return (0);
  	u.u_error = 0;
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_dirp = "core";
! 	ip = namei(CREATE | FOLLOW);
! 	u.u_segflg = UIO_USERSPACE;
  	if (ip == NULL) {
  		if (u.u_error)
  			return (0);
! 		ip = maknode(0644);
  		if (ip==NULL)
  			return (0);
  	}
--- 815,828 ----
  	if (u.u_procp->p_textp && access(u.u_procp->p_textp->x_iptr, IREAD))
  		return (0);
  	u.u_error = 0;
! 	ndp->ni_nameiop = CREATE | FOLLOW;
! 	ndp->ni_segflg = UIO_SYSSPACE;
! 	ndp->ni_dirp = "core";
! 	ip = namei(ndp);
  	if (ip == NULL) {
  		if (u.u_error)
  			return (0);
! 		ip = maknode(0644, ndp);
  		if (ip==NULL)
  			return (0);
  	}
***************
*** 834,860 ****
  	}
  	itrunc(ip, (u_long)0);
  	u.u_acflag |= ACORE;
! 	u.u_offset = 0;
! 	u.u_base = (caddr_t)&u;
! 	u.u_count = ctob(USIZE);
! 	u.u_segflg = UIO_SYSSPACE;
! 	writei(ip);
  	if (u.u_error)
  		goto out;

! 	s = u.u_dsize;
! 	estabur((u_int)0, s, u.u_ssize, 0, RO);
! 	u.u_base = 0;
! 	u.u_count = ctob(s);
! 	u.u_segflg = UIO_USERSPACE;
! 	writei(ip);
  	if (u.u_error)
  		goto out;

! 	s = u.u_ssize;
! 	u.u_base = (caddr_t)(-(ctob(s)));
! 	u.u_count = ctob(s);
! 	writei(ip);
  out:
  	iput(ip);
  	return (u.u_error == 0);
--- 834,853 ----
  	}
  	itrunc(ip, (u_long)0);
  	u.u_acflag |= ACORE;
! 	u.u_error = rdwri(UIO_WRITE, ip, &u, ctob(USIZE), (off_t)0,
! 			UIO_SYSSPACE, (int *)0);
  	if (u.u_error)
  		goto out;

! 	estabur((u_int)0, u.u_dsize, u.u_ssize, 0, RO);
! 	u.u_error = rdwri(UIO_WRITE, ip, 0, ctob(u.u_dsize), (off_t)ctob(USIZE),
! 			UIO_USERSPACE, (int *)0);
  	if (u.u_error)
  		goto out;

! 	u.u_error = rdwri(UIO_WRITE, ip, (caddr_t)(-(ctob(u.u_ssize))), ctob(u.u_ssize),
! 			(off_t)ctob(USIZE) + (off_t)ctob(u.u_dsize),
! 			 UIO_USERSPACE, (int *)0);
  out:
  	iput(ip);
  	return (u.u_error == 0);
diff -r -c /usr/src/oldsys/sys/kern_subr.c /usr/src/sys/sys/kern_subr.c
*** /usr/src/oldsys/sys/kern_subr.c	Tue Jul  5 16:09:58 1988
--- /usr/src/sys/sys/kern_subr.c	Wed Apr 11 09:49:25 1990
***************
*** 15,70 ****
  #include "uio.h"

  /* copied, for supervisory networking, to sys_net.c */
! uiomove(cp, n, rw)
! 	register caddr_t cp;
! 	register u_int n;
  	enum uio_rw rw;
  {
! 	register int error = 0;

! 	if (!n)
! 		return (0);
! 	switch (u.u_segflg) {

! 	case UIO_USERSPACE:
! 		if (n > 100 && cp + n < SEG6)
! 			error = uiofmove(cp, n, rw);
! 		else if ((n | (int)cp | (int)u.u_base) & 1)
! 			if (rw == UIO_READ)
! 				error = vcopyout(cp, u.u_base, n);
  			else
! 				error = vcopyin(u.u_base, cp, n);
! 		else {
  			if (rw == UIO_READ)
! 				error = copyout(cp, u.u_base, n);
  			else
! 				error = copyin(u.u_base, cp, n);
  		}
! 		if (error)
! 			return (error);
! 		break;
!
! 	case UIO_USERISPACE:
! 		if (n > 100 && cp + n < SEG6)
! 			error = uiofmove(cp, n, rw);
! 		else if (rw == UIO_READ)
! 			error = copyiout(cp, u.u_base, n);
! 		else
! 			error = copyiin(u.u_base, cp, n);
! 		if (error)
! 			return (error);
! 		break;
!
! 	case UIO_SYSSPACE:
! 		if (rw == UIO_READ)
! 			bcopy((caddr_t)cp, u.u_base, n);
! 		else
! 			bcopy(u.u_base, (caddr_t)cp, n);
! 		break;
  	}
- 	u.u_base += n;
- 	u.u_count -= n;
- 	u.u_offset += n;
  	return (error);
  }

--- 15,85 ----
  #include "uio.h"

  /* copied, for supervisory networking, to sys_net.c */
! uiomove(cp, n, rw, uio)
! 	caddr_t cp;
! 	u_int n;
  	enum uio_rw rw;
+ 	register struct uio *uio;
  {
! 	register struct iovec *iov;
! 	int error = 0;
! 	register u_int cnt;

! 	while (n > 0 && uio->uio_resid) {
! 		iov = uio->uio_iov;
! 		cnt = iov->iov_len;
! 		if (cnt == 0) {
! 			uio->uio_iov++;
! 			uio->uio_iovcnt--;
! 			continue;
! 		}
! 		if (cnt > n)
! 			cnt = n;
! 		switch (uio->uio_segflg) {

! 		case UIO_USERSPACE:
! 			if (cnt > 100 && cp + cnt < SEG6)
! 				error = uiofmove(cp, cnt, rw, uio, iov);
! 			else if ((cnt | (int)cp | (int)iov->iov_base) & 1)
! 				if (rw == UIO_READ)
! 					error = vcopyout(cp,iov->iov_base, cnt);
! 				else
! 					error = vcopyin(iov->iov_base, cp, cnt);
! 			else {
! 				if (rw == UIO_READ)
! 					error = copyout(cp, iov->iov_base, cnt);
! 				else
! 					error = copyin(iov->iov_base, cp, cnt);
! 			}
! 			if (error)
! 				return (error);
! 			break;
!
! 		case UIO_USERISPACE:
! 			if (cnt > 100 && cp + cnt < SEG6)
! 				error = uiofmove(cp, cnt, rw, uio, iov);
! 			else if (rw == UIO_READ)
! 				error = copyiout(cp, iov->iov_base, cnt);
  			else
! 				error = copyiin(iov->iov_base, cp, cnt);
! 			if (error)
! 				return (error);
! 			break;
!
! 		case UIO_SYSSPACE:
  			if (rw == UIO_READ)
! 				bcopy((caddr_t)cp, iov->iov_base, cnt);
  			else
! 				bcopy(iov->iov_base, (caddr_t)cp, cnt);
! 			break;
  		}
! 		iov->iov_base += cnt;
! 		iov->iov_len -= cnt;
! 		uio->uio_resid -= cnt;
! 		uio->uio_offset += cnt;
! 		cp += cnt;
! 		n -= cnt;
  	}
  	return (error);
  }

***************
*** 72,99 ****
  /*
   * Give next character to user as result of read.
   */
! ureadc(c)
  	register int c;
  {
! 	switch (u.u_segflg) {

  	case UIO_USERSPACE:
! 		if (subyte(u.u_base, c) < 0)
  			return (EFAULT);
  		break;

  	case UIO_SYSSPACE:
! 		*u.u_base = c;
  		break;

  	case UIO_USERISPACE:
! 		if (suibyte(u.u_base, c) < 0)
  			return (EFAULT);
  		break;
  	}
! 	u.u_base++;
! 	u.u_count--;
! 	u.u_offset++;
  	return (0);
  }

--- 87,127 ----
  /*
   * Give next character to user as result of read.
   */
! ureadc(c, uio)
  	register int c;
+ 	register struct uio *uio;
  {
! 	register struct iovec *iov;

+ again:
+ 	if (uio->uio_iovcnt == 0)
+ 		panic("ureadc");
+ 	iov = uio->uio_iov;
+ 	if (iov->iov_len == 0 || uio->uio_resid == 0) {
+ 		uio->uio_iovcnt--;
+ 		uio->uio_iov++;
+ 		goto again;
+ 	}
+ 	switch (uio->uio_segflg) {
+
  	case UIO_USERSPACE:
! 		if (subyte(iov->iov_base, c) < 0)
  			return (EFAULT);
  		break;

  	case UIO_SYSSPACE:
! 		*iov->iov_base = c;
  		break;

  	case UIO_USERISPACE:
! 		if (suibyte(iov->iov_base, c) < 0)
  			return (EFAULT);
  		break;
  	}
! 	iov->iov_base++;
! 	iov->iov_len--;
! 	uio->uio_resid--;
! 	uio->uio_offset++;
  	return (0);
  }

***************
*** 101,131 ****
  /*
   * Get next character written in by user from uio.
   */
! uwritec()
  {
  	register int c;

! 	if (!u.u_count)
  		return (-1);
! 	switch (u.u_segflg) {

  	case UIO_USERSPACE:
! 		c = fubyte(u.u_base);
  		break;

  	case UIO_SYSSPACE:
! 		c = *u.u_base & 0377;
  		break;

  	case UIO_USERISPACE:
! 		c = fuibyte(u.u_base);
  		break;
  	}
  	if (c < 0)
  		return (-1);
! 	u.u_base++;
! 	u.u_count--;
! 	u.u_offset++;
  	return (c & 0377);
  }

--- 129,172 ----
  /*
   * Get next character written in by user from uio.
   */
! uwritec(uio)
! 	register struct uio *uio;
  {
+ 	register struct iovec *iov;
  	register int c;

! 	if (uio->uio_resid == 0)
  		return (-1);
! again:
! 	if (uio->uio_iovcnt <= 0)
! 		panic("uwritec");
! 	iov = uio->uio_iov;
! 	if (iov->iov_len == 0) {
! 		uio->uio_iov++;
! 		if (--uio->uio_iovcnt == 0)
! 			return (-1);
! 		goto again;
! 	}
! 	switch (uio->uio_segflg) {

  	case UIO_USERSPACE:
! 		c = fubyte(iov->iov_base);
  		break;

  	case UIO_SYSSPACE:
! 		c = *iov->iov_base & 0377;
  		break;

  	case UIO_USERISPACE:
! 		c = fuibyte(iov->iov_base);
  		break;
  	}
  	if (c < 0)
  		return (-1);
! 	iov->iov_base++;
! 	iov->iov_len--;
! 	uio->uio_resid--;
! 	uio->uio_offset++;
  	return (c & 0377);
  }

***************
*** 135,144 ****
   * language helper routine, fmove, uses segment register 6 to map in the
   * user's memory.
   */
! uiofmove(cp, n, rw)
  	caddr_t cp;
  	register int n;
  	enum uio_rw rw;
  {
  	register short c;
  	short on;
--- 176,187 ----
   * language helper routine, fmove, uses segment register 6 to map in the
   * user's memory.
   */
! uiofmove(cp, n, rw, uio, iov)
  	caddr_t cp;
  	register int n;
  	enum uio_rw rw;
+ 	struct uio *uio;
+ 	struct iovec *iov;
  {
  	register short c;
  	short on;
***************
*** 151,157 ****
  	segd = UISD;
  	sega = UISA;
  #else
! 	if (u.u_segflg == UIO_USERSPACE && u.u_sep) {
  		segd = UDSD;
  		sega = UDSA;
  	}
--- 194,200 ----
  	segd = UISD;
  	sega = UISA;
  #else
! 	if (uio->uio_segflg == UIO_USERSPACE && u.u_sep) {
  		segd = UDSD;
  		sega = UDSA;
  	}
***************
*** 161,168 ****
  	}
  #endif

! 	segr = (short)u.u_base >> 13 & 07;
! 	on = (short)u.u_base & 017777;
  	c = MIN(n, 8192-on);
  	for (;;) {
  		if (rw == UIO_READ)
--- 204,211 ----
  	}
  #endif

! 	segr = (short)iov->iov_base >> 13 & 07;
! 	on = (short)iov->iov_base & 017777;
  	c = MIN(n, 8192-on);
  	for (;;) {
  		if (rw == UIO_READ)
diff -r -c /usr/src/oldsys/sys/quota_kern.c /usr/src/sys/sys/quota_kern.c
*** /usr/src/oldsys/sys/quota_kern.c	Mon Sep 26 21:25:28 1988
--- /usr/src/sys/sys/quota_kern.c	Sun Apr  8 02:32:28 1990
***************
*** 32,40 ****
  #include "fs.h"
  #include "mount.h"
  #include "uio.h"
- #ifdef BSD2_10
- #include "namei.h"
- #endif

  /*
   * Quota cache - hash chain headers.
--- 32,37 ----
***************
*** 409,415 ****
  		QUOTAUNMAP();
  		ILOCK(ip);
  		fail = rdwri(UIO_READ, ip, &xq, sizeof (xq),
! 		    (off_t)uid * sizeof (xq), UIO_SYSSPACE);
  		QUOTAMAP();
  		dq->dq_dqb = xq;
  	}
--- 406,412 ----
  		QUOTAUNMAP();
  		ILOCK(ip);
  		fail = rdwri(UIO_READ, ip, &xq, sizeof (xq),
! 		    (off_t)uid * sizeof (xq), UIO_SYSSPACE, (int *)0);
  		QUOTAMAP();
  		dq->dq_dqb = xq;
  	}
***************
*** 643,649 ****
  		QUOTAUNMAP();
  		ILOCK(ip);
  		(void)rdwri(UIO_WRITE, ip, &xq, sizeof (xq),
! 			(off_t)uid * sizeof (xq), UIO_SYSSPACE);
  		QUOTAMAP();
  	}
  #else
--- 640,646 ----
  		QUOTAUNMAP();
  		ILOCK(ip);
  		(void)rdwri(UIO_WRITE, ip, &xq, sizeof (xq),
! 			(off_t)uid * sizeof (xq), UIO_SYSSPACE, (int *)0);
  		QUOTAMAP();
  	}
  #else
***************
*** 700,724 ****
  	register struct inode *ip;
  	register struct quota *q;
  	struct dquot *dq;
- #ifndef BSD2_10
  	register struct nameidata *ndp = &u.u_nd;
- #endif
  	int i;

  	if (mp->m_qinod)
  		closedq(mp);
- #ifdef BSD2_10
  	QUOTAUNMAP();			/* paranoia */
- 	u.u_dirp = fname;
- 	u.u_segflg = UIO_USERSPACE;
- 	ip = namei(LOOKUP | FOLLOW);
- 	QUOTAMAP();
- #else
  	ndp->ni_nameiop = LOOKUP | FOLLOW;
  	ndp->ni_segflg = UIO_USERSPACE;
  	ndp->ni_dirp = fname;
  	ip = namei(ndp);
! #endif
  	if (ip == NULL)
  		return;
  	IUNLOCK(ip);
--- 697,713 ----
  	register struct inode *ip;
  	register struct quota *q;
  	struct dquot *dq;
  	register struct nameidata *ndp = &u.u_nd;
  	int i;

  	if (mp->m_qinod)
  		closedq(mp);
  	QUOTAUNMAP();			/* paranoia */
  	ndp->ni_nameiop = LOOKUP | FOLLOW;
  	ndp->ni_segflg = UIO_USERSPACE;
  	ndp->ni_dirp = fname;
  	ip = namei(ndp);
! 	QUOTAMAP();
  	if (ip == NULL)
  		return;
  	IUNLOCK(ip);
diff -r -c /usr/src/oldsys/sys/subr_log.c /usr/src/sys/sys/subr_log.c
*** /usr/src/oldsys/sys/subr_log.c	Mon Aug  7 21:57:20 1989
--- /usr/src/sys/sys/subr_log.c	Thu Apr  5 13:31:34 1990
***************
*** 81,87 ****
  	register int s;
  	int error = 0;
  #ifdef	pdp11
! 	char	buf[btoc(2)];
  #endif

  	s = splhigh();
--- 81,87 ----
  	register int s;
  	int error = 0;
  #ifdef	pdp11
! 	char	buf[ctob(2)];
  #endif

  	s = splhigh();
***************
*** 96,114 ****
  	splx(s);
  	logsoftc.sc_state &= ~LOG_RDWAIT;

! 	while (u.u_count > 0) {
  		l = msgbuf.msg_bufx - msgbuf.msg_bufr;
  		if (l < 0)
  			l = MSG_BSIZE - msgbuf.msg_bufr;
! 		l = MIN(l, u.u_count);
  		if (l == 0)
  			break;
! #ifdef	pdp11
  		l = MIN(l, sizeof buf);
  		mapseg5(msgbuf.msg_click, (btoc(MSG_BSIZE) << 8) | RW);
  		bcopy(&msgbuf.msg_bufc[msgbuf.msg_bufr], buf, l);
  		normalseg5();
! 		error = uiomove(buf, l, UIO_READ);
  #else
  		error = uiomove((caddr_t)&msgbuf.msg_bufc[msgbuf.msg_bufr],
  			(int)l, UIO_READ, uio);
--- 96,114 ----
  	splx(s);
  	logsoftc.sc_state &= ~LOG_RDWAIT;

! 	while (uio->uio_resid) {
  		l = msgbuf.msg_bufx - msgbuf.msg_bufr;
  		if (l < 0)
  			l = MSG_BSIZE - msgbuf.msg_bufr;
! 		l = MIN(l, uio->uio_resid);
  		if (l == 0)
  			break;
! #ifdef	BSD2_10
  		l = MIN(l, sizeof buf);
  		mapseg5(msgbuf.msg_click, (btoc(MSG_BSIZE) << 8) | RW);
  		bcopy(&msgbuf.msg_bufc[msgbuf.msg_bufr], buf, l);
  		normalseg5();
! 		error = uiomove(buf, l, UIO_READ, uio);
  #else
  		error = uiomove((caddr_t)&msgbuf.msg_bufc[msgbuf.msg_bufr],
  			(int)l, UIO_READ, uio);
diff -r -c /usr/src/oldsys/sys/sys_generic.c /usr/src/sys/sys/sys_generic.c
*** /usr/src/oldsys/sys/sys_generic.c	Mon Sep  5 17:50:47 1988
--- /usr/src/sys/sys/sys_generic.c	Sat Apr  7 22:58:48 1990
***************
*** 20,99 ****
  #include "kernel.h"
  #include "systm.h"

  read()
  {
! 	rwuio(FREAD);
  }

  write()
  {
! 	rwuio(FWRITE);
  }

! rwuio(mode)
! 	int mode;
  {
  	register struct a {
! 		int fdes;
! 		char *cbuf;
! 		u_int count;
  	} *uap = (struct a *)u.u_ap;
! 	register struct file *fp;
! 	register struct inode *ip;

! 	GETF(fp,uap->fdes);
! 	if (!(fp->f_flag & mode)) {
  		u.u_error = EBADF;
  		return;
  	}
! 	u.u_base = (caddr_t)uap->cbuf;
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_count = uap->count;
  	if (setjmp(&u.u_qsave)) {
! 		if (u.u_count == uap->count) {
  			if ((u.u_sigintr & sigmask(u.u_procp->p_cursig)) != 0)
  				u.u_error = EINTR;
  			else
  				u.u_eosys = RESTARTSYS;
  		}
! 	}
! 	else switch(fp->f_type) {
! 		case DTYPE_INODE:
! 			ip = (struct inode *)fp->f_data;
! 			u.u_offset = fp->f_offset;
! 			if ((ip->i_mode&IFMT) == IFREG)
! 				ILOCK(ip);
! 			if (mode == FREAD)
! 				readi(ip);
! 			else {
! 				if (fp->f_flag&FAPPEND)
! 					u.u_offset = fp->f_offset = ip->i_size;
! 				writei(ip);
! 			}
! 			if ((ip->i_mode&IFMT) == IFREG)
! 				IUNLOCK(ip);
! 			fp->f_offset += uap->count - u.u_count;
! 			break;
! 		case DTYPE_PIPE:
! 			if (mode == FREAD)
! 				readp(fp);
! 			else
! 				writep(fp);
! 			break;
! #ifdef UCB_NET
! 		case DTYPE_SOCKET:
! 			if (mode == FREAD)
! 				u.u_error =
! 				    SORECEIVE((struct socket *)fp->f_socket,
! 				    0, 0, 0);
! 			else
! 				u.u_error =
! 				    SOSEND((struct socket *)fp->f_socket,
! 				    0, 0, 0);
! 			break;
! #endif
! 	}
! 	u.u_r.r_val1 = uap->count - u.u_count;
  }

  /*
--- 20,178 ----
  #include "kernel.h"
  #include "systm.h"

+ /*
+  * this is consolidated here rather than being scattered all over the
+  * place.  the socketops table has to be in kernel space, but since
+  * networking might not be defined an appropriate error has to be set
+ */
+
+ 	int	sorw(), soctl(), sosel(), socls();
+ 	struct	fileops	socketops =
+ 		{ sorw, soctl, sosel, socls };
+ extern	struct	fileops	inodeops, pipeops;
+ 	struct	fileops	*Fops[] = { NULL, &inodeops, &socketops, &pipeops };
+
+ /*
+  * Read system call.
+  */
  read()
  {
! 	register struct a {
! 		int	fdes;
! 		char	*cbuf;
! 		unsigned count;
! 	} *uap = (struct a *)u.u_ap;
! 	struct uio auio;
! 	struct iovec aiov;
!
! 	aiov.iov_base = (caddr_t)uap->cbuf;
! 	aiov.iov_len = uap->count;
! 	auio.uio_iov = &aiov;
! 	auio.uio_iovcnt = 1;
! 	rwuio(&auio, UIO_READ);
  }

+ readv()
+ {
+ 	register struct a {
+ 		int	fdes;
+ 		struct	iovec *iovp;
+ 		unsigned iovcnt;
+ 	} *uap = (struct a *)u.u_ap;
+ 	struct uio auio;
+ 	struct iovec aiov[16];		/* XXX */
+
+ 	if (uap->iovcnt > sizeof(aiov)/sizeof(aiov[0])) {
+ 		u.u_error = EINVAL;
+ 		return;
+ 	}
+ 	auio.uio_iov = aiov;
+ 	auio.uio_iovcnt = uap->iovcnt;
+ 	u.u_error = copyin((caddr_t)uap->iovp, (caddr_t)aiov,
+ 	    uap->iovcnt * sizeof (struct iovec));
+ 	if (u.u_error)
+ 		return;
+ 	rwuio(&auio, UIO_READ);
+ }
+
+ /*
+  * Write system call
+  */
  write()
  {
! 	register struct a {
! 		int	fdes;
! 		char	*cbuf;
! 		unsigned count;
! 	} *uap = (struct a *)u.u_ap;
! 	struct uio auio;
! 	struct iovec aiov;
!
! 	auio.uio_iov = &aiov;
! 	auio.uio_iovcnt = 1;
! 	aiov.iov_base = uap->cbuf;
! 	aiov.iov_len = uap->count;
! 	rwuio(&auio, UIO_WRITE);
  }

! writev()
  {
  	register struct a {
! 		int	fdes;
! 		struct	iovec *iovp;
! 		unsigned iovcnt;
  	} *uap = (struct a *)u.u_ap;
! 	struct uio auio;
! 	struct iovec aiov[16];		/* XXX */

! 	if (uap->iovcnt > sizeof(aiov)/sizeof(aiov[0])) {
! 		u.u_error = EINVAL;
! 		return;
! 	}
! 	auio.uio_iov = aiov;
! 	auio.uio_iovcnt = uap->iovcnt;
! 	u.u_error = copyin((caddr_t)uap->iovp, (caddr_t)aiov,
! 	    uap->iovcnt * sizeof (struct iovec));
! 	if (u.u_error)
! 		return;
! 	rwuio(&auio, UIO_WRITE);
! }
!
! rwuio(uio, rw)
! 	register struct uio *uio;
! 	enum uio_rw rw;
! {
! 	struct a {
! 		int	fdes;
! 	};
! 	struct file *fp;
! 	register struct iovec *iov;
! 	u_int i, count;
! 	off_t	total;
!
! 	GETF(fp, ((struct a *)u.u_ap)->fdes);
! 	if ((fp->f_flag&(rw==UIO_READ ? FREAD : FWRITE)) == 0) {
  		u.u_error = EBADF;
  		return;
  	}
! 	total =(off_t)0;
! 	uio->uio_resid = 0;
! 	uio->uio_segflg = UIO_USERSPACE;
! 	iov = uio->uio_iov;
! 	for (i = 0; i < uio->uio_iovcnt; i++) {
! #ifdef	BSD2_10
! 		total += iov->iov_len;
! #else
! 		if (iov->iov_len < 0) {
! 			u.u_error = EINVAL;
! 			return;
! 		}
! 		uio->uio_resid += iov->iov_len;
! 		if (uio->uio_resid < 0) {
! 			u.u_error = EINVAL;
! 			return;
! 		}
! #endif
! 		iov++;
! 	}
! #ifdef	BSD2_10
! 	uio->uio_resid = total;
! 	if (uio->uio_resid != total) {	/* check wraparound */
! 		u.u_error = EINVAL;
! 		return;
! 	}
! #endif
! 	count = uio->uio_resid;
  	if (setjmp(&u.u_qsave)) {
! 		if (uio->uio_resid == count) {
  			if ((u.u_sigintr & sigmask(u.u_procp->p_cursig)) != 0)
  				u.u_error = EINTR;
  			else
  				u.u_eosys = RESTARTSYS;
  		}
! 	} else
! 		u.u_error = (*Fops[fp->f_type]->fo_rw)(fp, rw, uio);
! 	u.u_r.r_val1 = count - uio->uio_resid;
  }

  /*
***************
*** 181,192 ****
  		u.u_error = fgetown(fp, (int *)data);
  		return;
  	}
! #ifdef UCB_NET
! 	if (fp->f_type == DTYPE_SOCKET)
! 		u.u_error = SOO_IOCTL(fp, k_com, data);
! 	else
! #endif
! 	u.u_error = ino_ioctl(fp, k_com, data);
  	/*
  	 * Copy any data to user, size was
  	 * already set and checked above.
--- 260,266 ----
  		u.u_error = fgetown(fp, (int *)data);
  		return;
  	}
! 	u.u_error = (*Fops[fp->f_type]->fo_ioctl)(fp, k_com, data);
  	/*
  	 * Copy any data to user, size was
  	 * already set and checked above.
***************
*** 349,375 ****
  					u.u_error = EBADF;
  					break;
  				}
! 				switch(fp->f_type) {
! 				case DTYPE_INODE:
! 					if (ino_select(fp, flag)) {
! 						FD_SET(i + j, &obits[which]);
! 						n++;
! 					}
! 					break;
! 				case DTYPE_PIPE:
! 					if (pipe_select(fp, flag)) {
! 						FD_SET(i + j, &obits[which]);
! 						n++;
! 					}
! 					break;
! #ifdef UCB_NET
! 				case DTYPE_SOCKET:
! 					if (SOO_SELECT(fp, flag)) {
! 						FD_SET(i + j, &obits[which]);
! 						n++;
! 					}
! 					break;
! #endif
  				}
  			}
  		}
--- 423,431 ----
  					u.u_error = EBADF;
  					break;
  				}
! 				if ((*Fops[fp->f_type]->fo_select)(fp,flag)) {
! 					FD_SET(i + j, &obits[which]);
! 					n++;
  				}
  			}
  		}
***************
*** 409,412 ****
--- 465,515 ----
  		splx(s);
  	}
  	restormap(map);
+ }
+
+ sorw(fp, rw, uio)
+ 	register struct file *fp;
+ 	register enum uio_rw rw;
+ 	register struct uio *uio;
+ {
+ #ifdef	UCB_NET
+ 	if (rw == UIO_READ)
+ 		return(SORECEIVE((struct socket *)fp->f_socket, 0, uio, 0, 0));
+ 	return(SOSEND((struct socket *)fp->f_socket, 0, uio, 0, 0));
+ #else
+ 	return (EOPNOTSUPP);
+ #endif
+ }
+
+ soctl(fp, com, data)
+ 	register struct file *fp;
+ 	register u_int	com;
+ 	register char	*data;
+ 	{
+ #ifdef	UCB_NET
+ 	return (SOO_IOCTL(fp, com, data));
+ #else
+ 	return (EOPNOTSUPP);
+ #endif
+ }
+
+ sosel(fp, flag)
+ 	register struct file *fp;
+ 	register int	flag;
+ {
+ #ifdef	UCB_NET
+ 	return (SOO_SELECT(fp, flag));
+ #else
+ 	return (EOPNOTSUPP);
+ #endif
+ }
+
+ socls(fp)
+ 	register struct file *fp;
+ {
+ #ifdef	UCB_NET
+ 	return (SOCLOSE((struct socket *)fp->f_socket));
+ #else
+ 	return (EOPNOTSUPP);
+ #endif
  }
diff -r -c /usr/src/oldsys/sys/sys_inode.c /usr/src/sys/sys/sys_inode.c
*** /usr/src/oldsys/sys/sys_inode.c	Fri Sep  2 21:12:50 1988
--- /usr/src/sys/sys/sys_inode.c	Wed Apr 11 09:49:22 1990
***************
*** 14,25 ****
  #include "inode.h"
  #include "buf.h"
  #include "fs.h"
- #include "ioctl.h"
  #include "file.h"
  #include "stat.h"
  #include "mount.h"
  #include "conf.h"
  #include "uio.h"
  #include "kernel.h"
  #include "systm.h"
  #ifdef QUOTA
--- 14,26 ----
  #include "inode.h"
  #include "buf.h"
  #include "fs.h"
  #include "file.h"
  #include "stat.h"
  #include "mount.h"
  #include "conf.h"
  #include "uio.h"
+ #include "ioctl.h"
+ #include "tty.h"
  #include "kernel.h"
  #include "systm.h"
  #ifdef QUOTA
***************
*** 26,247 ****
  #include "quota.h"
  #endif

! readi(ip)
! 	register struct inode *ip;
  {
! 	register struct buf *bp;
! 	register int n;
! 	daddr_t lbn, bn;
! 	off_t diff;
! 	dev_t dev;
! 	int on, type;

! 	if (!u.u_count)
! 		return;
! 	if (u.u_offset < 0) {
! 		u.u_error = EINVAL;
! 		return;
! 	}
! 	ip->i_flag |= IACC;
! 	dev = ip->i_rdev;
! 	type = ip->i_mode&IFMT;
! 	if (type == IFCHR) {
! 		u.u_error = (*cdevsw[major(dev)].d_read)(dev);
! 		return;
! 	}
! 	do {
! 		lbn = bn = lblkno(u.u_offset);
! 		on = blkoff(u.u_offset);
! 		n = MIN((u_int)(DEV_BSIZE - on), u.u_count);
! 		if (type != IFBLK) {
! 			diff = ip->i_size - u.u_offset;
! 			if (diff <= 0)
! 				return;
! 			if (diff < n)
! 				n = diff;
! 			bn = bmap(ip, bn, B_READ, 0);
! 			if (u.u_error)
! 				return;
! 			dev = ip->i_dev;
! 		} else
! 			rablock = bn+1;
! 		if (bn < 0) {
! 			bp = geteblk();
! 			bp->b_resid = 0;
! 			clrbuf(bp);
! 		}
! 		else {
! 			if (ip->i_lastr + 1 == lbn)
! 				bp = breada(dev, bn, rablock);
! 			else
! 				bp = bread(dev, bn);
! 			if (bp->b_flags & B_ERROR) {
! 				u.u_error = EIO;
! 				brelse(bp);
! 				return;
! 			}
! 		}
! 		ip->i_lastr = lbn;
! 		n = MIN((u_int)n, DEV_BSIZE - bp->b_resid);
! 		if (n != 0) {
! 			u.u_error = uiomove(mapin(bp) + on, n, UIO_READ);
! 			mapout(bp);
! 		}
! 		if (n + on == DEV_BSIZE || u.u_offset == ip->i_size) {
! 			if (ip->i_flag & IPIPE)
! 				bp->b_flags &= ~B_DELWRI;
! 			bp->b_flags |= B_AGE;
! 		}
! 		brelse(bp);
! 	} while (!u.u_error && u.u_count && n > 0);
  }

! writei(ip)
  	register struct inode *ip;
  {
! 	register struct buf *bp;
! 	register int on;
! 	daddr_t bn;
! 	dev_t dev;
! 	int n, type;

! 	if (u.u_offset < 0) {
! 		u.u_error = EINVAL;
! 		return;
! 	}
! 	dev = ip->i_rdev;
  	type = ip->i_mode&IFMT;
- 	/*
- 	 * technically, next three lines should probably be done *after*
- 	 * the write has been attempted.  If you move them, make sure you
- 	 * set the IUPD|ICHG before calling the cdevsw routine.
- 	 */
- 	if (u.u_ruid != 0)		/* clear set-uid/gid unless root */
- 		ip->i_mode &= ~(ISUID|ISGID);
- 	ip->i_flag |= IUPD|ICHG;
  	if (type == IFCHR) {
! 		u.u_error = (*cdevsw[major(dev)].d_write)(dev);
! 		return;
  	}
! 	if (!u.u_count)
! 		return;
! 	if (type == IFREG && u.u_offset + u.u_count >
  	      u.u_rlimit[RLIMIT_FSIZE].rlim_cur) {
  		psignal(u.u_procp, SIGXFSZ);
! 		u.u_error = EFBIG;
! 		return;
  	}
! #ifdef QUOTA
  	/*
  	 * we do bytes, see the comment on 'blocks' in ino_stat().
- 	 * sure hope we never try to extend the quota file and exceed
- 	 * RLIMIT_FSIZE, yuck!
  	 *
! 	 * we make the simplifying assumption that the entire write will
  	 * succeed, otherwise we have to check the quota on each block.
! 	 * can you say slow?  i knew you could.
! 	 *
! 	 * SMS
! 	 */
! 	if (type == IFREG || type == IFDIR || type == IFLNK) {
! 		if (u.u_offset + u.u_count > ip->i_size) {
  			QUOTAMAP();
! 			u.u_error = chkdq(ip,
! 			    u.u_offset + u.u_count - ip->i_size, 0);
  			QUOTAUNMAP();
! 			if (u.u_error)
! 				return;
  		}
  	}
  #endif
  	do {
! 		bn = lblkno(u.u_offset);
! 		on = blkoff(u.u_offset);
! 		n = MIN((u_int)(DEV_BSIZE - on), u.u_count);
  		if (type != IFBLK) {
! 			bn = bmap(ip, bn, B_WRITE, n == DEV_BSIZE ? 0 : 1);
! 			if (bn < 0)
! 				return;
! 			dev = ip->i_dev;
! 		}
! 		if (n == DEV_BSIZE)
! 			bp = getblk(dev, bn);
! 		else {
! 			bp = bread(dev, bn);
! 			if (bp->b_flags & B_ERROR) {
! 				u.u_error = EIO;
! 				brelse(bp);
! 				return;
  			}
! 			/*
! 			 * Tape drivers don't clear buffers on end-of-tape
! 			 * any longer (clrbuf can't be called from interrupt).
! 			 */
  			if (bp->b_resid == DEV_BSIZE) {
  				bp->b_resid = 0;
! 				clrbuf(bp);
  			}
  		}
! 		u.u_error = uiomove(mapin(bp) + on, n, UIO_WRITE);
  		mapout(bp);
! 		if (u.u_error)
  			brelse(bp);
! 		else if ((ip->i_mode&IFMT) == IFDIR)
! 			bwrite(bp);
! 		else if (n + on == DEV_BSIZE && !(ip->i_flag & IPIPE)) {
! 			bp->b_flags |= B_AGE;
! 			bawrite(bp);
! 		} else
! 			bdwrite(bp);
! 		if (u.u_offset > ip->i_size &&
! 		    (type == IFDIR || type == IFREG || type == IFLNK))
! 			ip->i_size = u.u_offset;
! 	} while (!u.u_error && u.u_count);
  }

- #ifdef QUOTA
- /*
-  * Following is the quota system's interface into readi/writei, we don't
-  * have the luxury of simply creating a new uio structure and letting
-  * fly.  The residual argument is not implemented since the 4.3bsd quota
-  * system didn't use it.
-  */
- rdwri(rw, ip, base, len, offset, segflg)
- 	struct inode *ip;
- 	caddr_t base;
- 	int len, segflg;
- 	off_t offset;
- 	enum uio_rw rw;
- {
- 	struct uio savu;
- 	struct iovec iov;
- 	register int saverr, reterr;

- 	iov.iov_len = u.u_count;
- 	iov.iov_base = u.u_base;
- 	savu.uio_offset = u.u_offset;
- 	savu.uio_segflg = u.u_segflg;
- 	saverr = u.u_error;
- 	u.u_offset = offset;
- 	u.u_count = len;
- 	u.u_base = base;
- 	u.u_segflg = segflg;
- 	if (rw == UIO_READ)
- 		readi(ip);
- 	else if (rw == UIO_WRITE)
- 		writei(ip);
- 	else
- 		panic("rdwri");
- 	reterr = u.u_error;
- 	u.u_error = saverr;
- 	u.u_count = iov.iov_len;
- 	u.u_base = iov.iov_base;
- 	u.u_segflg = savu.uio_segflg;
- 	u.u_offset = savu.uio_offset;
- 	return(reterr);
- }
- #endif
-
  ino_ioctl(fp, com, data)
  	struct file *fp;
  	register u_int com;
--- 27,232 ----
  #include "quota.h"
  #endif

! int	ino_rw(), ino_ioctl(), ino_select(), ino_close();
! struct 	fileops inodeops =
! 	{ ino_rw, ino_ioctl, ino_select, ino_close };
!
! ino_rw(fp, rw, uio)
! 	struct file *fp;
! 	enum uio_rw rw;
! register struct uio *uio;
  {
! 	register struct inode *ip = (struct inode *)fp->f_data;
! 	u_int count, error;

! 	if ((ip->i_mode&IFMT) != IFCHR)
! 		ILOCK(ip);
! 	if ((ip->i_mode&IFMT) == IFREG &&
! 	    (fp->f_flag&FAPPEND) &&
! 	    rw == UIO_WRITE)
! 		fp->f_offset = ip->i_size;
! 	uio->uio_offset = fp->f_offset;
! 	count = uio->uio_resid;
! 	error = rwip(ip, uio, rw);
! 	fp->f_offset += count - uio->uio_resid;
! 	if ((ip->i_mode&IFMT) != IFCHR)
! 		IUNLOCK(ip);
! 	return (error);
  }

! rdwri(rw, ip, base, len, offset, segflg, aresid)
! 	struct inode *ip;
! 	caddr_t base;
! 	int len, segflg;
! 	off_t offset;
! register int *aresid;
! 	enum uio_rw rw;
! {
! 	struct uio auio;
! 	struct iovec aiov;
! register int error;
!
! 	auio.uio_iov = &aiov;
! 	auio.uio_iovcnt = 1;
! 	aiov.iov_base = base;
! 	aiov.iov_len = len;
! 	auio.uio_resid = len;
! 	auio.uio_offset = offset;
! 	auio.uio_segflg = segflg;
! 	error = rwip(ip, &auio, rw);
! 	if (aresid)
! 		*aresid = auio.uio_resid;
! 	else
! 		if (auio.uio_resid)
! 			error = EIO;
! 	return (error);
! }
!
! rwip(ip, uio, rw)
  	register struct inode *ip;
+ 	register struct uio *uio;
+ 	enum uio_rw rw;
  {
! 	dev_t dev = (dev_t)ip->i_rdev;
! 	struct buf *bp;
! 	daddr_t lbn, bn;
! 	register int n, on, type;
! 	int error = 0;

! #ifdef	DIAGNOSTIC
! 	if (rw != UIO_READ && rw != UIO_WRITE)
! 		panic("rwip");
! #endif
! 	if (rw == UIO_READ && uio->uio_resid == 0)
! 		return (0);
! 	if (uio->uio_offset < 0)
! 		return (EINVAL);
! 	if (rw == UIO_READ)
! 		ip->i_flag |= IACC;
  	type = ip->i_mode&IFMT;
  	if (type == IFCHR) {
! 		if (rw == UIO_READ)
! 			error = (*cdevsw[major(dev)].d_read)(dev, uio);
! 		else {
! 			ip->i_flag |= IUPD|ICHG;
! 			error = (*cdevsw[major(dev)].d_write)(dev, uio);
! 		}
! 		return (error);
  	}
! 	if (uio->uio_resid == 0)
! 		return (0);
! 	if (rw == UIO_WRITE && type == IFREG &&
! 	    uio->uio_offset + uio->uio_resid >
  	      u.u_rlimit[RLIMIT_FSIZE].rlim_cur) {
  		psignal(u.u_procp, SIGXFSZ);
! 		return (EFBIG);
  	}
! #ifdef	QUOTA
  	/*
  	 * we do bytes, see the comment on 'blocks' in ino_stat().
  	 *
! 	 * the simplfying assumption is made that the entire write will
  	 * succeed, otherwise we have to check the quota on each block.
! 	 * can you say slow?  i knew you could.  SMS
! 	*/
! 	if (type == IFREG || type == IFDIR || type == IFLNK &&
! 	    rw == UIO_WRITE && !(ip->i_flag & IPIPE)) {
! 		if (uio->uio_offset + uio->uio_resid > ip->i_size) {
  			QUOTAMAP();
! 			error = chkdq(ip,
! 				uio->uio_offset+uio->uio_resid - ip->i_size,0);
  			QUOTAUNMAP();
! 			if (error)
! 				return (error);
  		}
  	}
  #endif
+ 	if (type != IFBLK)
+ 		dev = ip->i_dev;
  	do {
! 		lbn = lblkno(uio->uio_offset);
! 		on = blkoff(uio->uio_offset);
! 		n = MIN((u_int)(DEV_BSIZE - on), uio->uio_resid);
  		if (type != IFBLK) {
! 			if (rw == UIO_READ) {
! 				off_t diff = ip->i_size - uio->uio_offset;
! 				if (diff <= 0)
! 					return (0);
! 				if (diff < n)
! 					n = diff;
! 			bn = bmap(ip, lbn, B_READ, 0);
  			}
! 			else
! 				bn = bmap(ip,lbn,B_WRITE,n == DEV_BSIZE ? 0: 1);
! 			if (u.u_error || rw == UIO_WRITE && (long)bn<0)
! 				return (u.u_error);
! 			if (rw == UIO_WRITE && uio->uio_offset + n > ip->i_size &&
! 			   (type == IFDIR || type == IFREG || type == IFLNK))
! 				ip->i_size = uio->uio_offset + n;
! 		} else {
! 			bn = lbn;
! 			rablock = bn + 1;
! 		}
! 		if (rw == UIO_READ) {
! 			if ((long)bn<0) {
! 				bp = geteblk();
! 				clrbuf(bp);
! 			} else if (ip->i_lastr + 1 == lbn)
! 				bp = breada(dev, bn, rablock);
! 			else
! 				bp = bread(dev, bn);
! 			ip->i_lastr = lbn;
! 		} else {
! 			if (n == DEV_BSIZE)
! 				bp = getblk(dev, bn);
! 			else
! 				bp = bread(dev, bn);
! /*
!  * 4.3 didn't do this, but 2.10 did.  not sure why.
!  * something about tape drivers don't clear buffers on end-of-tape
!  * any longer (clrbuf can't be called from interrupt).
! */
  			if (bp->b_resid == DEV_BSIZE) {
  				bp->b_resid = 0;
! 			clrbuf(bp);
  			}
  		}
! 		n = MIN(n, DEV_BSIZE - bp->b_resid);
! 		if (bp->b_flags & B_ERROR) {
! 			error = EIO;
! 			brelse(bp);
! 			goto bad;
! 		}
! 		u.u_error =
! 		    uiomove(mapin(bp)+on, n, rw, uio);
  		mapout(bp);
! 		if (rw == UIO_READ) {
! 			if (n + on == DEV_BSIZE || uio->uio_offset == ip->i_size) {
! 				bp->b_flags |= B_AGE;
! 				if (ip->i_flag & IPIPE)
! 					bp->b_flags &= ~B_DELWRI;
! 			}
  			brelse(bp);
! 		} else {
! 			if ((ip->i_mode&IFMT) == IFDIR)
! 				bwrite(bp);
! 			else if (n + on == DEV_BSIZE && !(ip->i_flag & IPIPE)) {
! 				bp->b_flags |= B_AGE;
! 				bawrite(bp);
! 			} else
! 				bdwrite(bp);
! 			ip->i_flag |= IUPD|ICHG;
! 			if (u.u_ruid != 0)
! 				ip->i_mode &= ~(ISUID|ISGID);
! 		}
! 	} while (u.u_error == 0 && uio->uio_resid && n != 0);
! 	if (error == 0)				/* XXX */
! 		error = u.u_error;		/* XXX */
! bad:
! 	return (error);
  }


  ino_ioctl(fp, com, data)
  	struct file *fp;
  	register u_int com;
***************
*** 593,596 ****
--- 578,620 ----
  		return ((*bdevsw[maj].d_open)(dev, mode));
  	}
  	return (0);
+ }
+
+ /*
+  * Revoke access the current tty by all processes.
+  * Used only by the super-user in init
+  * to give ``clean'' terminals at login.
+  */
+ vhangup()
+ {
+
+ 	if (!suser())
+ 		return;
+ 	if (u.u_ttyp == NULL)
+ 		return;
+ 	forceclose(u.u_ttyd);
+ 	if ((u.u_ttyp->t_state) & TS_ISOPEN)
+ 		gsignal(u.u_ttyp->t_pgrp, SIGHUP);
+ }
+
+ forceclose(dev)
+ 	register dev_t dev;
+ {
+ 	register struct file *fp;
+ 	register struct inode *ip;
+
+ 	for (fp = file; fp < fileNFILE; fp++) {
+ 		if (fp->f_count == 0)
+ 			continue;
+ 		if (fp->f_type != DTYPE_INODE)
+ 			continue;
+ 		ip = (struct inode *)fp->f_data;
+ 		if (ip == 0)
+ 			continue;
+ 		if ((ip->i_mode & IFMT) != IFCHR)
+ 			continue;
+ 		if (ip->i_rdev != dev)
+ 			continue;
+ 		fp->f_flag &= ~(FREAD|FWRITE);
+ 	}
  }
Only in /usr/src/oldsys/sys: sys_inode2.c
diff -r -c /usr/src/oldsys/sys/sys_kern.c /usr/src/sys/sys/sys_kern.c
*** /usr/src/oldsys/sys/sys_kern.c	Tue Jul  5 16:15:43 1988
--- /usr/src/sys/sys/sys_kern.c	Sat Apr  7 18:14:18 1990
***************
*** 100,117 ****
  	register struct inode *ip;
  	char pth[MLEN];
  	int error;

  	bcopy(path, pth, len);
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_dirp = pth;
! 	u.u_dirp[len - 2] = 0;
  	*ipp = 0;
! 	ip = namei(CREATE|FOLLOW);
  	if (ip) {
  		iput(ip);
  		return(EADDRINUSE);
  	}
! 	if (u.u_error || !(ip = maknode(IFSOCK | 0777))) {
  		error = u.u_error;
  		u.u_error = 0;
  		return(error);
--- 100,119 ----
  	register struct inode *ip;
  	char pth[MLEN];
  	int error;
+ 	register struct	nameidata *ndp = &u.u_nd;

  	bcopy(path, pth, len);
! 	ndp->ni_nameiop = CREATE | FOLLOW;
! 	ndp->ni_segflg = UIO_SYSSPACE;
! 	ndp->ni_dirp = pth;
! 	ndp->ni_dirp[len - 2] = 0;
  	*ipp = 0;
! 	ip = namei(ndp);
  	if (ip) {
  		iput(ip);
  		return(EADDRINUSE);
  	}
! 	if (u.u_error || !(ip = maknode(IFSOCK | 0777, ndp))) {
  		error = u.u_error;
  		u.u_error = 0;
  		return(error);
***************
*** 131,144 ****
  	register struct inode *ip;
  	char pth[MLEN];
  	int error;

  	bcopy(path, pth, len);
  	if (!len)
  		return(EINVAL);		/* paranoia */
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_dirp = pth;
! 	u.u_dirp[len - 2] = 0;
! 	ip = namei(LOOKUP | FOLLOW);
  	*ipp = ip;
  	if (!ip || access(ip, IWRITE)) {
  		error = u.u_error;
--- 133,148 ----
  	register struct inode *ip;
  	char pth[MLEN];
  	int error;
+ 	register struct	nameidata *ndp = &u.u_nd;

  	bcopy(path, pth, len);
  	if (!len)
  		return(EINVAL);		/* paranoia */
! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_SYSSPACE;
! 	ndp->ni_dirp = pth;
! 	ndp->ni_dirp[len - 2] = 0;
! 	ip = namei(ndp);
  	*ipp = ip;
  	if (!ip || access(ip, IWRITE)) {
  		error = u.u_error;
diff -r -c /usr/src/oldsys/sys/sys_net.c /usr/src/sys/sys/sys_net.c
*** /usr/src/oldsys/sys/sys_net.c	Fri Jan  6 09:57:57 1989
--- /usr/src/sys/sys/sys_net.c	Sat Apr  7 20:11:43 1990
***************
*** 213,327 ****
   * exist in supervisor space.  Note, we assume that all transfers will
   * be to/from user D space.  Probably safe, until someone decides to
   * put NFS into the kernel.
   */
! uiomove(cp, n, rw)
! 	register caddr_t cp;
! 	register u_int n;
  	enum uio_rw rw;
  {
! 	if (!n)
! 		return (0);
  #ifdef DIAGNOSTIC
! 	if (u.u_segflg != UIO_USERSPACE)
! 		panic("segflag != UIO_USERSPACE");
  #endif
! 	if ((n | (int)cp | (int)u.u_base)&01) {
! 		if (rw == UIO_READ) {
! 			do {
! 				if (ureadc(*cp++) < 0)
! 					return(EFAULT);
! 			} while (--n);
  		}
  		else {
! 			register int ch;
!
! 			do {
! 				if ((ch = uwritec()) < 0)
! 					return(EFAULT);
! 				*cp++ = ch;
! 			} while (--n);
  		}
  	}
- 	else {
- 		register int error;
-
- 		if (rw == UIO_READ)
- 			error = copyout(cp, u.u_base, n);
- 		else
- 			error = copyin(u.u_base, cp, n);
- 		if (error)
- 			return(error);
- 		u.u_base += n;
- 		u.u_count -= n;
- 		u.u_offset += n;
- 	}
- 	return(0);
- }
-
- /* copied from kern_subr.c */
- ureadc(c)
- 	register int c;
- {
- #ifdef notdef
- 	switch (u.u_segflg) {
-
- 	case UIO_USERSPACE:
- 		if (subyte(u.u_base, c) < 0)
- 			return (EFAULT);
- 		break;
-
- 	case UIO_SYSSPACE:
- 		*u.u_base = c;
- 		break;
-
- 	case UIO_USERISPACE:
- 		if (suibyte(u.u_base, c) < 0)
- 			return (EFAULT);
- 		break;
- 	}
- #else
- 	if (subyte(u.u_base, c) < 0)
- 		return (EFAULT);
- #endif
- 	u.u_base++;
- 	u.u_count--;
- 	u.u_offset++;
  	return (0);
  }

- /* copied from kern_subr.c */
- uwritec()
- {
- 	register int c;
-
- 	if (!u.u_count)
- 		return (-1);
- #ifdef notdef
- 	switch (u.u_segflg) {
-
- 	case UIO_USERSPACE:
- 		c = fubyte(u.u_base);
- 		break;
-
- 	case UIO_SYSSPACE:
- 		c = *u.u_base & 0377;
- 		break;
-
- 	case UIO_USERISPACE:
- 		c = fuibyte(u.u_base);
- 		break;
- 	}
- #else
- 	c = fubyte(u.u_base);
- #endif
- 	if (c < 0)
- 		return (-1);
- 	u.u_base++;
- 	u.u_count--;
- 	u.u_offset++;
- 	return (c & 0377);
- }
-
  #define TOCONS	0x1
  #define TOTTY	0x2
  #define TOLOG	0x4
--- 213,280 ----
   * exist in supervisor space.  Note, we assume that all transfers will
   * be to/from user D space.  Probably safe, until someone decides to
   * put NFS into the kernel.
+  *
+  * The 4.3BSD uio/iovec paradigm adopted, ureadc() and uwritec() inlined
+  * at that time to speed things up. 3/90 sms
   */
! uiomove(cp, n, rw, uio)
! 	caddr_t cp;
! 	u_int n;
  	enum uio_rw rw;
+ 	register struct uio *uio;
  {
! 	register struct iovec *iov;
! 	int error, count, ch;
! 	register u_int cnt;
!
  #ifdef DIAGNOSTIC
! 	if (uio->uio_segflg != UIO_USERSPACE)
! 		panic("net uiomove");
  #endif
! 	while (n && uio->uio_resid) {
! 		iov = uio->uio_iov;
! 		cnt = iov->iov_len;
! 		if (cnt == 0) {
! 			uio->uio_iov++;
! 			uio->uio_iovcnt--;
! 			continue;
  		}
+ 		if (cnt > n)
+ 			cnt = n;
+ 		count = cnt;
+ 		if ((cnt | (int)cp | (int)iov->iov_base) & 1) {
+ 			if (rw == UIO_READ) {
+ 				while (cnt--)
+ 					if (subyte(iov->iov_base++, *cp++) < 0)
+ 						return (EFAULT);
+ 			}
+ 			else {
+ 				while (cnt--) {
+ 					if ((ch = fubyte(iov->iov_base++)) < 0)
+ 						return (EFAULT);
+ 					*cp++ = ch;
+ 			 	}
+ 			}
+ 		cnt = count;	/* use register */
+ 		}
  		else {
! 			if (rw == UIO_READ)
! 				error = copyout(cp, iov->iov_base, cnt);
! 			else
! 				error = copyin(iov->iov_base, cp, cnt);
! 			if (error)
! 				return (error);
! 			iov->iov_base += cnt;
! 			cp += cnt;
  		}
+ 	iov->iov_len -= cnt;
+ 	uio->uio_resid -= cnt;
+ 	uio->uio_offset += cnt;
+ 	n -= cnt;
  	}
  	return (0);
  }

  #define TOCONS	0x1
  #define TOTTY	0x2
  #define TOLOG	0x4
***************
*** 335,342 ****
  	prf(fmt, &x1, TOCONS | TOLOG);
  }

- #define	putchar(c, flags)	cnputc(c)
-
  /* copied from subr_prf.c */
  prf(fmt, adx, flags)
  	register char *fmt;
--- 288,293 ----
***************
*** 352,358 ****
  	while ((c = *fmt++) != '%') {
  		if (c == '\0')
  			return;
! 		putchar(c, flags);
  	}
  	c = *fmt++;
  	switch (c) {
--- 303,309 ----
  	while ((c = *fmt++) != '%') {
  		if (c == '\0')
  			return;
! 		_pchar(c, flags);
  	}
  	c = *fmt++;
  	switch (c) {
***************
*** 370,378 ****
  				b = 8;
  				goto lnumber;
  			default:
! 				putchar('%', flags);
! 				putchar('l', flags);
! 				putchar(c, flags);
  		}
  		break;
  	case 'X':
--- 321,329 ----
  				b = 8;
  				goto lnumber;
  			default:
! 				_pchar('%', flags);
! 				_pchar('l', flags);
! 				_pchar(c, flags);
  		}
  		break;
  	case 'X':
***************
*** 398,404 ****
  number:		printn((long)*adx, b, flags);
  		break;
  	case 'c':
! 		putchar(*adx, flags);
  		break;
  	case 'b':
  		b = *adx++;
--- 349,355 ----
  number:		printn((long)*adx, b, flags);
  		break;
  	case 'c':
! 		_pchar(*adx, flags);
  		break;
  	case 'b':
  		b = *adx++;
***************
*** 408,436 ****
  		if (b) {
  			while (i = *s++) {
  				if (b & (1 << (i - 1))) {
! 					putchar(any? ',' : '<', flags);
  					any = 1;
  					for (; (c = *s) > 32; s++)
! 						putchar(c, flags);
  				} else
  					for (; *s > 32; s++)
  						;
  			}
  			if (any)
! 				putchar('>', flags);
  		}
  		break;
  	case 's':
  		s = (char *)*adx;
  		while (c = *s++)
! 			putchar(c, flags);
  		break;
  	case '%':
! 		putchar(c, flags);
  		break;
  	default:
! 		putchar('%', flags);
! 		putchar(c, flags);
  		break;
  	}
  	adx++;
--- 359,387 ----
  		if (b) {
  			while (i = *s++) {
  				if (b & (1 << (i - 1))) {
! 					_pchar(any? ',' : '<', flags);
  					any = 1;
  					for (; (c = *s) > 32; s++)
! 						_pchar(c, flags);
  				} else
  					for (; *s > 32; s++)
  						;
  			}
  			if (any)
! 				_pchar('>', flags);
  		}
  		break;
  	case 's':
  		s = (char *)*adx;
  		while (c = *s++)
! 			_pchar(c, flags);
  		break;
  	case '%':
! 		_pchar(c, flags);
  		break;
  	default:
! 		_pchar('%', flags);
! 		_pchar(c, flags);
  		break;
  	}
  	adx++;
***************
*** 454,460 ****
  			n++;
  			break;
  		case 10:
! 			putchar('-', flags);
  			n = -n;
  			break;
  		}
--- 405,411 ----
  			n++;
  			break;
  		case 10:
! 			_pchar('-', flags);
  			n = -n;
  			break;
  		}
***************
*** 462,493 ****
  		*cp++ = "0123456789ABCDEF"[offset + n%b];
  	} while (n = n/b);	/* Avoid  n /= b, since that requires alrem */
  	do
! 		putchar(*--cp, flags);
  	while (cp > prbuf);
  }

! /* copied from cons.c */
! cnputc(c)
! 	int c;
! {
! 	register struct dldevice *cnaddr = (struct dldevice *)0177560;
! 	register int s, timo;

! 	timo = 30000;
! 	/*
! 	 * Try waiting for the console tty to come ready,
! 	 * otherwise give up after a reasonable time.
! 	 */
! 	while ((cnaddr->dlxcsr & DLXCSR_TRDY) == 0)
! 		if (--timo == 0)
! 			break;
! 	if (c == 0)
! 		return;
! 	s = cnaddr->dlxcsr;
! 	cnaddr->dlxcsr = 0;
! 	cnaddr->dlxbuf = c&0xff;
! 	if (c == '\n')
! 		cnputc('\r');
! 	cnputc(0);
! 	cnaddr->dlxcsr = s;
! }
--- 413,426 ----
  		*cp++ = "0123456789ABCDEF"[offset + n%b];
  	} while (n = n/b);	/* Avoid  n /= b, since that requires alrem */
  	do
! 		_pchar(*--cp, flags);
  	while (cp > prbuf);
  }

! extern int putchar();

! _pchar(c, flg)
! 	int c, flg;
! 	{
! 	return(SKcall(putchar, sizeof(int)+sizeof(int), c, flg));
! 	}
diff -r -c /usr/src/oldsys/sys/sys_pipe.c /usr/src/sys/sys/sys_pipe.c
*** /usr/src/oldsys/sys/sys_pipe.c	Mon Aug  8 21:12:04 1988
--- /usr/src/sys/sys/sys_pipe.c	Fri Apr  6 20:02:36 1990
***************
*** 17,22 ****
--- 17,27 ----
  #include "fs.h"
  #include "mount.h"

+ extern	int	ino_ioctl(), ino_close();
+ 	int	pipe_rw(), pipe_select();
+ 	struct	fileops	pipeops =
+ 		{ pipe_rw, ino_ioctl, pipe_select, ino_close };
+
  /*
   * The sys-pipe entry.
   * Allocate an inode on the root device.  Allocate 2
***************
*** 82,91 ****
  	ip->i_flag = IACC|IUPD|ICHG|IPIPE;
  }

! readp(fp)
  	register struct file *fp;
  {
  	register struct inode *ip;

  	ip = (struct inode *)fp->f_data;
  loop:
--- 87,109 ----
  	ip->i_flag = IACC|IUPD|ICHG|IPIPE;
  }

! pipe_rw(fp, rw, uio)
  	register struct file *fp;
+ 	register enum uio_rw rw;
+ 	register struct uio *uio;
  {
+
+ 	if (rw == UIO_READ)
+ 		return (readp(fp, uio));
+ 	return (writep(fp, uio));
+ }
+
+ readp(fp, uio)
+ 	register struct file *fp;
+ 	register struct	uio *uio;
+ {
  	register struct inode *ip;
+ 	int error;

  	ip = (struct inode *)fp->f_data;
  loop:
***************
*** 100,110 ****
  		 */
  		IUNLOCK(ip);
  		if (ip->i_count != 2)
! 			return;
! 		if (fp->f_flag & FNDELAY) {
! 			u.u_error = EWOULDBLOCK;
! 			return;
! 		}
  		ip->i_mode |= IREAD;
  		sleep((caddr_t)ip+2, PPIPE);
  		goto loop;
--- 118,126 ----
  		 */
  		IUNLOCK(ip);
  		if (ip->i_count != 2)
! 			return (0);
! 		if (fp->f_flag & FNDELAY)
! 			return (EWOULDBLOCK);
  		ip->i_mode |= IREAD;
  		sleep((caddr_t)ip+2, PPIPE);
  		goto loop;
***************
*** 111,119 ****
  	}

  	/* Read and return */
! 	u.u_offset = fp->f_offset;
! 	readi(ip);
! 	fp->f_offset = u.u_offset;

  	/*
  	 * If reader has caught up with writer, reset
--- 127,135 ----
  	}

  	/* Read and return */
! 	uio->uio_offset = fp->f_offset;
! 	error = rwip(ip, uio, UIO_READ);
! 	fp->f_offset = uio->uio_offset;

  	/*
  	 * If reader has caught up with writer, reset
***************
*** 133,157 ****
  		}
  	}
  	IUNLOCK(ip);
  }

! writep(fp)
! 	register struct file *fp;
  {
  	register struct inode *ip;
  	register int c;

  	ip = (struct inode *)fp->f_data;
! 	c = u.u_count;
  	ILOCK(ip);
  	if ((fp->f_flag & FNDELAY) && ip->i_size + c >= MAXPIPSIZ) {
! 		u.u_error = EWOULDBLOCK;
  		goto done;
  	}
  loop:
  	/* If all done, return. */
  	if (c == 0) {
! 		u.u_count = 0;
  		goto done;
  	}

--- 149,176 ----
  		}
  	}
  	IUNLOCK(ip);
+ 	return (error);
  }

! writep(fp, uio)
! 	struct file *fp;
! 	register struct	uio *uio;
  {
  	register struct inode *ip;
  	register int c;
+ 	int error = 0;

  	ip = (struct inode *)fp->f_data;
! 	c = uio->uio_resid;
  	ILOCK(ip);
  	if ((fp->f_flag & FNDELAY) && ip->i_size + c >= MAXPIPSIZ) {
! 		error = EWOULDBLOCK;
  		goto done;
  	}
  loop:
  	/* If all done, return. */
  	if (c == 0) {
! 		uio->uio_resid = 0;
  		goto done;
  	}

***************
*** 160,169 ****
  	 * return error and signal too.
  	 */
  	if (ip->i_count != 2) {
- 		u.u_error = EPIPE;
  		psignal(u.u_procp, SIGPIPE);
  done:		IUNLOCK(ip);
! 		return;
  	}

  	/*
--- 179,188 ----
  	 * return error and signal too.
  	 */
  	if (ip->i_count != 2) {
  		psignal(u.u_procp, SIGPIPE);
+ 		error = EPIPE;
  done:		IUNLOCK(ip);
! 		return (error);
  	}

  	/*
***************
*** 184,193 ****
  	 * One can therefore get a file > MAXPIPSIZ if write
  	 * sizes do not divide MAXPIPSIZ.
  	 */
! 	u.u_offset = ip->i_size;
! 	u.u_count = MIN((u_int)c, (u_int)MAXPIPSIZ);
! 	c -= u.u_count;
! 	writei(ip);
  	if (ip->i_mode&IREAD) {
  		ip->i_mode &= ~IREAD;
  		wakeup((caddr_t)ip+2);
--- 203,212 ----
  	 * One can therefore get a file > MAXPIPSIZ if write
  	 * sizes do not divide MAXPIPSIZ.
  	 */
! 	uio->uio_offset = ip->i_size;
! 	uio->uio_resid = MIN((u_int)c, (u_int)MAXPIPSIZ);
! 	c -= uio->uio_resid;
! 	error = rwip(ip, uio, UIO_WRITE);
  	if (ip->i_mode&IREAD) {
  		ip->i_mode &= ~IREAD;
  		wakeup((caddr_t)ip+2);
diff -r -c /usr/src/oldsys/sys/tty.c /usr/src/sys/sys/tty.c
*** /usr/src/oldsys/sys/tty.c	Fri Sep  2 21:17:40 1988
--- /usr/src/sys/sys/tty.c	Wed Apr 11 09:49:13 1990
***************
*** 131,137 ****
  	register int s = spltty();

  	while ((tp->t_outq.c_cc || tp->t_state&TS_BUSY) &&
! 	    tp->t_state&TS_CARR_ON) {
  		(*tp->t_oproc)(tp);
  		tp->t_state |= TS_ASLEEP;
  		sleep((caddr_t)&tp->t_outq, TTOPRI);
--- 131,137 ----
  	register int s = spltty();

  	while ((tp->t_outq.c_cc || tp->t_state&TS_BUSY) &&
! 	    tp->t_state&TS_CARR_ON && tp->t_oproc) {
  		(*tp->t_oproc)(tp);
  		tp->t_state |= TS_ASLEEP;
  		sleep((caddr_t)&tp->t_outq, TTOPRI);
***************
*** 188,194 ****
  	 * Current input > threshold AND input is available to user program
  	 */
  	if (x >= TTYHOG/2 &&
! 	    ((tp->t_flags & (RAW|CBREAK)) || (tp->t_canq.c_cc > 0))) {
  		if (putc(tp->t_stopc, &tp->t_outq)==0) {
  			tp->t_state |= TS_TBLOCK;
  			ttstart(tp);
--- 188,195 ----
  	 * Current input > threshold AND input is available to user program
  	 */
  	if (x >= TTYHOG/2 &&
! 	    ((tp->t_flags & (RAW|CBREAK)) || (tp->t_canq.c_cc > 0)) &&
! 	    (tp->t_state&TS_TBLOCK) == 0) {
  		if (putc(tp->t_stopc, &tp->t_outq)==0) {
  			tp->t_state |= TS_TBLOCK;
  			ttstart(tp);
***************
*** 476,482 ****
  	 */
  	case TIOCSPGRP: {
  		struct proc *p;
! 		int pgrp = *(int *)data;

  		if (u.u_uid && (flag & FREAD) == 0)
  			return (EPERM);
--- 477,483 ----
  	 */
  	case TIOCSPGRP: {
  		struct proc *p;
! 		short pgrp = *(int *)data;

  		if (u.u_uid && (flag & FREAD) == 0)
  			return (EPERM);
***************
*** 1144,1151 ****
   * Called from device's read routine after it has
   * calculated the tty-structure given as argument.
   */
! ttread(tp)
  	register struct tty *tp;
  {
  	register struct clist *qp;
  	register c;
--- 1145,1153 ----
   * Called from device's read routine after it has
   * calculated the tty-structure given as argument.
   */
! ttread(tp, uio)
  	register struct tty *tp;
+ 	struct uio *uio;
  {
  	register struct clist *qp;
  	register c;
***************
*** 1196,1203 ****
  			goto loop;
  		}
  		splx(s);
!  		while (!error && tp->t_rawq.c_cc && u.u_count)
!  			error = ureadc(getc(&tp->t_rawq));
  		goto checktandem;
  	}

--- 1198,1205 ----
  			goto loop;
  		}
  		splx(s);
!  		while (!error && tp->t_rawq.c_cc && uio->uio_resid)
!  			error = ureadc(getc(&tp->t_rawq), uio);
  		goto checktandem;
  	}

***************
*** 1251,1260 ****
  		/*
  		 * Give user character.
  		 */
!  		error = ureadc(t_flags&PASS8 ? c : c & 0177);
  		if (error)
  			break;
!  		if (u.u_count == 0)
  			break;
  		/*
  		 * In cooked mode check for a "break character"
--- 1253,1262 ----
  		/*
  		 * Give user character.
  		 */
!  		error = ureadc(t_flags&PASS8 ? c : c & 0177, uio);
  		if (error)
  			break;
!  		if (uio->uio_resid == 0)
  			break;
  		/*
  		 * In cooked mode check for a "break character"
***************
*** 1270,1276 ****
  	 * Look to unblock output now that (presumably)
  	 * the input queue has gone down.
  	 */
! 	if (tp->t_state&TS_TBLOCK && tp->t_rawq.c_cc < TTYHOG/5)
  		if (putc(tp->t_startc, &tp->t_outq) == 0) {
  			tp->t_state &= ~TS_TBLOCK;
  			ttstart(tp);
--- 1272,1280 ----
  	 * Look to unblock output now that (presumably)
  	 * the input queue has gone down.
  	 */
! 	if (tp->t_state&TS_TBLOCK &&
! 	    (tp->t_rawq.c_cc+tp->t_canq.c_cc < TTYHOG/5 ||
! 	    (t_flags&(RAW|CBREAK)) == 0 && tp->t_canq.c_cc == 0))
  		if (putc(tp->t_startc, &tp->t_outq) == 0) {
  			tp->t_state &= ~TS_TBLOCK;
  			ttstart(tp);
***************
*** 1291,1299 ****
  	int wait;
  {
  	int hiwat, s, oldsig;
- #ifdef BSD2_10
  	int	wakeup();
- #endif

  	hiwat = TTHIWAT(tp);
  	s = spltty();
--- 1295,1301 ----
***************
*** 1305,1311 ****
  			splx(s);
  			return (0);
  		}
! 		timeout(wakeup, (caddr_t)&tp->t_outq, LINEHZ);
  		tp->t_state |= TS_ASLEEP;
  		sleep((caddr_t)&tp->t_outq, PZERO - 1);
  	}
--- 1307,1313 ----
  			splx(s);
  			return (0);
  		}
! 		timeout(wakeup, (caddr_t)&tp->t_outq, hz);
  		tp->t_state |= TS_ASLEEP;
  		sleep((caddr_t)&tp->t_outq, PZERO - 1);
  	}
***************
*** 1317,1332 ****
   * Called from the device's write routine after it has
   * calculated the tty-structure given as argument.
   */
! ttwrite(tp)
  	register struct tty *tp;
  {
! 	register char *cp;
  	register int cc, ce, c;
  	int i, hiwat, cnt, error, s;
  	char obuf[OBUFSIZ];

  	hiwat = TTHIWAT(tp);
! 	cnt = u.u_count;
  	error = 0;
  loop:
  	if ((tp->t_state&TS_CARR_ON) == 0)
--- 1319,1335 ----
   * Called from the device's write routine after it has
   * calculated the tty-structure given as argument.
   */
! ttwrite(tp, uio)
  	register struct tty *tp;
+ 	register struct uio *uio;
  {
! 	char *cp;
  	register int cc, ce, c;
  	int i, hiwat, cnt, error, s;
  	char obuf[OBUFSIZ];

  	hiwat = TTHIWAT(tp);
! 	cnt = uio->uio_resid;
  	error = 0;
  loop:
  	if ((tp->t_state&TS_CARR_ON) == 0)
***************
*** 1350,1364 ****
  	 * mark, sleep on overflow awaiting device aid
  	 * in acquiring new space.
  	 */
! 	while (u.u_count > 0) {
  		/*
  		 * Grab a hunk of data from the user.
  		 */
! 		cc = u.u_count;
  		if ((u_int)cc > OBUFSIZ)
  			cc = OBUFSIZ;
  		cp = obuf;
! 		error = uiomove(cp, cc, UIO_WRITE);
  		if (error)
  			break;
  		if (tp->t_outq.c_cc > hiwat)
--- 1353,1374 ----
  	 * mark, sleep on overflow awaiting device aid
  	 * in acquiring new space.
  	 */
! 	while (uio->uio_resid) {
  		/*
  		 * Grab a hunk of data from the user.
  		 */
! 		cc = uio->uio_iov->iov_len;
! 		if (cc == 0) {
! 			uio->uio_iovcnt--;
! 			uio->uio_iov++;
! 			if (uio->uio_iovcnt <= 0)
! 				panic("ttwrite");
! 			continue;
! 		}
  		if ((u_int)cc > OBUFSIZ)
  			cc = OBUFSIZ;
  		cp = obuf;
! 		error = uiomove(cp, cc, UIO_WRITE, uio);
  		if (error)
  			break;
  		if (tp->t_outq.c_cc > hiwat)
***************
*** 1380,1388 ****
  					sleep((caddr_t)&lbolt, TTOPRI);
  					tp->t_rocount = 0;
  					if (cc != 0) {
! 						u.u_base -= cc;
! 						u.u_count += cc;
! 						u.u_offset -= cc;
  					}
  					goto loop;
  				}
--- 1390,1399 ----
  					sleep((caddr_t)&lbolt, TTOPRI);
  					tp->t_rocount = 0;
  					if (cc != 0) {
! 					        uio->uio_iov->iov_base -= cc;
! 						uio->uio_iov->iov_len += cc;
! 						uio->uio_resid += cc;
! 						uio->uio_offset -= cc;
  					}
  					goto loop;
  				}
***************
*** 1418,1426 ****
  					    ttstart(tp);
  					    sleep((caddr_t)&lbolt, TTOPRI);
  					    if (cc != 0) {
! 					        u.u_base -= cc;
! 					        u.u_count += cc;
! 						u.u_offset -= cc;
  					    }
  					    goto loop;
  					}
--- 1429,1438 ----
  					    ttstart(tp);
  					    sleep((caddr_t)&lbolt, TTOPRI);
  					    if (cc != 0) {
! 					        uio->uio_iov->iov_base -= cc;
! 						uio->uio_iov->iov_len += cc;
! 						uio->uio_resid += cc;
! 						uio->uio_offset -= cc;
  					    }
  					    goto loop;
  					}
***************
*** 1451,1459 ****
  				/* out of c-lists, wait a bit */
  				ttstart(tp);
  				sleep((caddr_t)&lbolt, TTOPRI);
! 				u.u_base -= cc;
! 				u.u_count += cc;
! 				u.u_offset -= cc;
  				goto loop;
  			}
  			if (tp->t_flags&FLUSHO || tp->t_outq.c_cc > hiwat)
--- 1463,1472 ----
  				/* out of c-lists, wait a bit */
  				ttstart(tp);
  				sleep((caddr_t)&lbolt, TTOPRI);
! 				uio->uio_iov->iov_base -= cc;
! 				uio->uio_iov->iov_len += cc;
! 				uio->uio_resid += cc;
! 				uio->uio_offset -= cc;
  				goto loop;
  			}
  			if (tp->t_flags&FLUSHO || tp->t_outq.c_cc > hiwat)
***************
*** 1466,1474 ****
  ovhiwat:
  	s = spltty();
  	if (cc != 0) {
! 		u.u_base -= cc;
! 		u.u_count += cc;
! 		u.u_offset -= cc;
  	}
  	/*
  	 * This can only occur if FLUSHO
--- 1479,1488 ----
  ovhiwat:
  	s = spltty();
  	if (cc != 0) {
! 		uio->uio_iov->iov_base -= cc;
! 		uio->uio_iov->iov_len += cc;
! 		uio->uio_resid += cc;
! 		uio->uio_offset -= cc;
  	}
  	/*
  	 * This can only occur if FLUSHO
***************
*** 1481,1487 ****
  	ttstart(tp);
  	if (tp->t_state&TS_NBIO) {
  		splx(s);
! 		if (u.u_count == cnt)
  			return (EWOULDBLOCK);
  		return (0);
  	}
--- 1495,1501 ----
  	ttstart(tp);
  	if (tp->t_state&TS_NBIO) {
  		splx(s);
! 		if (uio->uio_resid == cnt)
  			return (EWOULDBLOCK);
  		return (0);
  	}

sms@wlv.imsd.contel.com (Steven M. Schultz) (04/14/90)

Subject: readv/writev/rdwri/namei-encapsulation/f_ops (part 2 of 2)
Index:	sys/many 2.10BSD

Description:
	Under 2.10.1BSD the writev() and readv() functionality is provided
	by an emulation routine using normal read(2) and write(2) syscalls.

	Also, the kernel's I/O interface was still the readi()/writei()
	from earlier versions of pdp-11 Unix rather than the rdwri()
	method from 4.3BSD

	And, the namei encapsulation of arguments into the u.u_nd structure
	was not present.

Repeat-By:
	Examination of the sources.  Or optionally, "diff" the kernel sources
	from a 2.10.1BSD system against those from a 4.3BSD system.

Fix:
	This is part 2 of 2

	The patches below bring the 2.10.1BSD kernel sources much closer to
	those of 4.3BSD as well as directly implementing readv and writev.

diff -r -c /usr/src/oldsys/sys/tty_pty.c /usr/src/sys/sys/tty_pty.c
*** /usr/src/oldsys/sys/tty_pty.c	Sat Apr 30 16:14:53 1988
--- /usr/src/sys/sys/tty_pty.c	Wed Apr 11 09:49:18 1990
***************
*** 94,101 ****
  	ptcwakeup(tp, FREAD|FWRITE);
  }

! ptsread(dev)
  	dev_t dev;
  {
  	register struct tty *tp = &pt_tty[minor(dev)];
  	register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
--- 94,102 ----
  	ptcwakeup(tp, FREAD|FWRITE);
  }

! ptsread(dev, uio)
  	dev_t dev;
+ 	register struct uio *uio;
  {
  	register struct tty *tp = &pt_tty[minor(dev)];
  	register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
***************
*** 117,124 ****
  			sleep((caddr_t)&tp->t_canq, TTIPRI);
  			goto again;
  		}
! 		while (tp->t_canq.c_cc > 1 && u.u_count > 0)
! 			if (ureadc(getc(&tp->t_canq)) < 0) {
  				error = EFAULT;
  				break;
  			}
--- 118,125 ----
  			sleep((caddr_t)&tp->t_canq, TTIPRI);
  			goto again;
  		}
! 		while (tp->t_canq.c_cc > 1 && uio->uio_resid)
! 			if (ureadc(getc(&tp->t_canq), uio) < 0) {
  				error = EFAULT;
  				break;
  			}
***************
*** 128,134 ****
  			return (error);
  	} else
  		if (tp->t_oproc)
! 			error = (*linesw[tp->t_line].l_read)(tp);
  	ptcwakeup(tp, FWRITE);
  	return (error);
  }
--- 129,135 ----
  			return (error);
  	} else
  		if (tp->t_oproc)
! 			error = (*linesw[tp->t_line].l_read)(tp, uio);
  	ptcwakeup(tp, FWRITE);
  	return (error);
  }
***************
*** 138,145 ****
   * Wakeups of controlling tty will happen
   * indirectly, when tty driver calls ptsstart.
   */
! ptswrite(dev)
  	dev_t dev;
  {
  	register struct tty *tp;

--- 139,147 ----
   * Wakeups of controlling tty will happen
   * indirectly, when tty driver calls ptsstart.
   */
! ptswrite(dev, uio)
  	dev_t dev;
+ 	register struct uio *uio;
  {
  	register struct tty *tp;

***************
*** 146,152 ****
  	tp = &pt_tty[minor(dev)];
  	if (tp->t_oproc == 0)
  		return (EIO);
! 	return ((*linesw[tp->t_line].l_write)(tp));
  }

  /*
--- 148,154 ----
  	tp = &pt_tty[minor(dev)];
  	if (tp->t_oproc == 0)
  		return (EIO);
! 	return ((*linesw[tp->t_line].l_write)(tp, uio));
  }

  /*
***************
*** 205,211 ****
  		return (EIO);
  	tp->t_oproc = ptsstart;
  	(void)(*linesw[tp->t_line].l_modem)(tp, 1);
- 	tp->t_state |= TS_CARR_ON;
  	pti = &pt_ioctl[minor(dev)];
  	pti->pt_flags = 0;
  	pti->pt_send = 0;
--- 207,212 ----
***************
*** 220,230 ****

  	tp = &pt_tty[minor(dev)];
  	(void)(*linesw[tp->t_line].l_modem)(tp, 0);
  	tp->t_oproc = 0;		/* mark closed */
  }

! ptcread(dev)
  	dev_t dev;
  {
  	register struct tty *tp = &pt_tty[minor(dev)];
  	struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
--- 221,233 ----

  	tp = &pt_tty[minor(dev)];
  	(void)(*linesw[tp->t_line].l_modem)(tp, 0);
+ 	tp->t_state &= ~TS_CARR_ON;
  	tp->t_oproc = 0;		/* mark closed */
  }

! ptcread(dev, uio)
  	dev_t dev;
+ 	register struct uio *uio;
  {
  	register struct tty *tp = &pt_tty[minor(dev)];
  	struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
***************
*** 240,246 ****
  	for (;;) {
  		if (tp->t_state&TS_ISOPEN) {
  			if (pti->pt_flags&PF_PKT && pti->pt_send) {
! 				error = ureadc((int)pti->pt_send);
  				if (error)
  					return (error);
  				pti->pt_send = 0;
--- 243,249 ----
  	for (;;) {
  		if (tp->t_state&TS_ISOPEN) {
  			if (pti->pt_flags&PF_PKT && pti->pt_send) {
! 				error = ureadc((int)pti->pt_send, uio);
  				if (error)
  					return (error);
  				pti->pt_send = 0;
***************
*** 247,253 ****
  				return (0);
  			}
  			if (pti->pt_flags&PF_UCNTL && pti->pt_ucntl) {
! 				error = ureadc((int)pti->pt_ucntl);
  				if (error)
  					return (error);
  				pti->pt_ucntl = 0;
--- 250,256 ----
  				return (0);
  			}
  			if (pti->pt_flags&PF_UCNTL && pti->pt_ucntl) {
! 				error = ureadc((int)pti->pt_ucntl, uio);
  				if (error)
  					return (error);
  				pti->pt_ucntl = 0;
***************
*** 263,274 ****
  		sleep((caddr_t)&tp->t_outq.c_cf, TTIPRI);
  	}
  	if (pti->pt_flags & (PF_PKT|PF_UCNTL))
! 		error = ureadc(0);
! 	while (u.u_count > 0 && error == 0) {
! 		cc = q_to_b(&tp->t_outq, buf, MIN(u.u_count, BUFSIZ));
  		if (cc <= 0)
  			break;
! 		error = uiomove(buf, cc, UIO_READ);
  	}
  	if (tp->t_outq.c_cc <= TTLOWAT(tp)) {
  		if (tp->t_state&TS_ASLEEP) {
--- 266,277 ----
  		sleep((caddr_t)&tp->t_outq.c_cf, TTIPRI);
  	}
  	if (pti->pt_flags & (PF_PKT|PF_UCNTL))
! 		error = ureadc(0, uio);
! 	while (uio->uio_resid && error == 0) {
! 		cc = q_to_b(&tp->t_outq, buf, MIN(uio->uio_resid, BUFSIZ));
  		if (cc <= 0)
  			break;
! 		error = uiomove(buf, cc, UIO_READ, uio);
  	}
  	if (tp->t_outq.c_cc <= TTLOWAT(tp)) {
  		if (tp->t_state&TS_ASLEEP) {
***************
*** 368,377 ****
  	return (0);
  }

! ptcwrite(dev)
  	dev_t dev;
  {
  	register struct tty *tp = &pt_tty[minor(dev)];
  	register char *cp;
  	register int cc = 0;
  	char locbuf[BUFSIZ];
--- 371,382 ----
  	return (0);
  }

! ptcwrite(dev, uio)
  	dev_t dev;
+ 	register struct uio *uio;
  {
  	register struct tty *tp = &pt_tty[minor(dev)];
+ 	register struct iovec *iov;
  	register char *cp;
  	register int cc = 0;
  	char locbuf[BUFSIZ];
***************
*** 385,396 ****
  	if (pti->pt_flags & PF_REMOTE) {
  		if (tp->t_canq.c_cc)
  			goto block;
! 		while (u.u_count > 0 && tp->t_canq.c_cc < TTYHOG - 1) {
  			if (cc == 0) {
! 				cc = MIN(u.u_count, BUFSIZ);
  				cc = MIN(cc, TTYHOG - 1 - tp->t_canq.c_cc);
  				cp = locbuf;
! 				error = uiomove(cp, cc, UIO_WRITE);
  				if (error)
  					return (error);
  				/* check again for safety */
--- 390,407 ----
  	if (pti->pt_flags & PF_REMOTE) {
  		if (tp->t_canq.c_cc)
  			goto block;
! 		while (uio->uio_iovcnt > 0 && tp->t_canq.c_cc < TTYHOG - 1) {
! 			iov = uio->uio_iov;
! 			if (iov->iov_len == 0) {
! 				uio->uio_iovcnt--;
! 				uio->uio_iov++;
! 				continue;
! 			}
  			if (cc == 0) {
! 				cc = MIN(iov->iov_len, BUFSIZ);
  				cc = MIN(cc, TTYHOG - 1 - tp->t_canq.c_cc);
  				cp = locbuf;
! 				error = uiomove(cp, cc, UIO_WRITE, uio);
  				if (error)
  					return (error);
  				/* check again for safety */
***************
*** 406,416 ****
  		wakeup((caddr_t)&tp->t_canq);
  		return (0);
  	}
! 	while (u.u_count > 0) {
  		if (cc == 0) {
! 			cc = MIN(u.u_count, BUFSIZ);
  			cp = locbuf;
! 			error = uiomove(cp, cc, UIO_WRITE);
  			if (error)
  				return (error);
  			/* check again for safety */
--- 417,433 ----
  		wakeup((caddr_t)&tp->t_canq);
  		return (0);
  	}
! 	while (uio->uio_iovcnt > 0) {
! 		iov = uio->uio_iov;
  		if (cc == 0) {
! 			if (iov->iov_len == 0) {
! 				uio->uio_iovcnt--;
! 				uio->uio_iov++;
! 				continue;
! 			}
! 			cc = MIN(iov->iov_len, BUFSIZ);
  			cp = locbuf;
! 			error = uiomove(cp, cc, UIO_WRITE, uio);
  			if (error)
  				return (error);
  			/* check again for safety */
***************
*** 439,447 ****
  	if ((tp->t_state&TS_CARR_ON) == 0)
  		return (EIO);
  	if (pti->pt_flags & PF_NBIO) {
! 		u.u_base -= cc;
! 		u.u_count += cc;
! 		u.u_offset -= cc;
  		if (cnt == 0)
  			return (EWOULDBLOCK);
  		return (0);
--- 456,465 ----
  	if ((tp->t_state&TS_CARR_ON) == 0)
  		return (EIO);
  	if (pti->pt_flags & PF_NBIO) {
! 		iov->iov_base -= cc;
! 		iov->iov_len += cc;
! 		uio->uio_resid += cc;
! 		uio->uio_offset -= cc;
  		if (cnt == 0)
  			return (EWOULDBLOCK);
  		return (0);
diff -r -c /usr/src/oldsys/sys/tty_tb.c /usr/src/sys/sys/tty_tb.c
*** /usr/src/oldsys/sys/tty_tb.c	Tue Jul  5 16:46:01 1988
--- /usr/src/sys/sys/tty_tb.c	Sat Apr  7 21:42:00 1990
***************
*** 120,127 ****
   * Read from a tablet line.
   * Characters have been buffered in a buffer and decoded.
   */
! tbread(tp)
  	register struct tty *tp;
  {
  	register struct tb *tbp = (struct tb *)tp->T_LINEP;
  	register struct tbconf *tc = &tbconf[tbp->tbflags & TBTYPE];
--- 120,128 ----
   * Read from a tablet line.
   * Characters have been buffered in a buffer and decoded.
   */
! tbread(tp, uio)
  	register struct tty *tp;
+ 	struct uio *uio;
  {
  	register struct tb *tbp = (struct tb *)tp->T_LINEP;
  	register struct tbconf *tc = &tbconf[tbp->tbflags & TBTYPE];
***************
*** 129,135 ****

  	if ((tp->t_state&TS_CARR_ON) == 0)
  		return (EIO);
! 	ret = uiomove(&tbp->rets, tc->tbc_uiosize, UIO_READ);
  	if (tc->tbc_flags&TBF_POL)
  		tbp->rets.polpos.p_key = ' ';
  	return (ret);
--- 130,136 ----

  	if ((tp->t_state&TS_CARR_ON) == 0)
  		return (EIO);
! 	ret = uiomove(&tbp->rets, tc->tbc_uiosize, UIO_READ, uio);
  	if (tc->tbc_flags&TBF_POL)
  		tbp->rets.polpos.p_key = ' ';
  	return (ret);
diff -r -c /usr/src/oldsys/sys/tty_tty.c /usr/src/sys/sys/tty_tty.c
*** /usr/src/oldsys/sys/tty_tty.c	Sat Sep  5 10:04:53 1987
--- /usr/src/sys/sys/tty_tty.c	Sat Apr  7 21:27:51 1990
***************
*** 28,48 ****
  }

  /*ARGSUSED*/
! syread(dev)
  	dev_t dev;
  {
  	if (u.u_ttyp == NULL)
  		return (ENXIO);
! 	return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd));
  }

  /*ARGSUSED*/
! sywrite(dev)
  	dev_t dev;
  {
  	if (u.u_ttyp == NULL)
  		return (ENXIO);
! 	return ((*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd));
  }

  /*ARGSUSED*/
--- 28,50 ----
  }

  /*ARGSUSED*/
! syread(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
  	if (u.u_ttyp == NULL)
  		return (ENXIO);
! 	return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd, uio));
  }

  /*ARGSUSED*/
! sywrite(dev, uio)
  	dev_t dev;
+ 	struct uio *uio;
  {
  	if (u.u_ttyp == NULL)
  		return (ENXIO);
! 	return ((*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd, uio));
  }

  /*ARGSUSED*/
diff -r -c /usr/src/oldsys/sys/ufs_alloc.c /usr/src/sys/sys/ufs_alloc.c
*** /usr/src/oldsys/sys/ufs_alloc.c	Sat Apr 30 16:14:52 1988
--- /usr/src/sys/sys/ufs_alloc.c	Sun Apr  8 03:12:13 1990
***************
*** 10,15 ****
--- 10,16 ----
  #include "../machine/seg.h"

  #include "fs.h"
+ #include "dir.h"
  #include "inode.h"
  #include "buf.h"
  #include "user.h"
diff -r -c /usr/src/oldsys/sys/ufs_bmap.c /usr/src/sys/sys/ufs_bmap.c
*** /usr/src/oldsys/sys/ufs_bmap.c	Wed May 20 05:30:35 1987
--- /usr/src/sys/sys/ufs_bmap.c	Sun Apr  8 03:03:57 1990
***************
*** 11,16 ****
--- 11,17 ----

  #include "systm.h"
  #include "conf.h"
+ #include "dir.h"
  #include "inode.h"
  #include "user.h"
  #include "buf.h"
diff -r -c /usr/src/oldsys/sys/ufs_fio.c /usr/src/sys/sys/ufs_fio.c
*** /usr/src/oldsys/sys/ufs_fio.c	Tue Jul  5 16:21:52 1988
--- /usr/src/sys/sys/ufs_fio.c	Sat Apr  7 18:11:43 1990
***************
*** 106,115 ****
  	int follow;
  {
  	register struct inode *ip;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = fname;
! 	ip = namei(LOOKUP | follow);
  	if (ip == NULL)
  		return (NULL);
  	if (u.u_uid == ip->i_uid)
--- 106,117 ----
  	int follow;
  {
  	register struct inode *ip;
+ 	register struct	nameidata *ndp = &u.u_nd;

! 	ndp->ni_nameiop = LOOKUP | follow;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = fname;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return (NULL);
  	if (u.u_uid == ip->i_uid)
diff -r -c /usr/src/oldsys/sys/ufs_inode.c /usr/src/sys/sys/ufs_inode.c
*** /usr/src/oldsys/sys/ufs_inode.c	Mon Jan 29 21:39:24 1990
--- /usr/src/sys/sys/ufs_inode.c	Fri Apr  6 20:01:41 1990
***************
*** 21,26 ****
--- 21,27 ----
  #ifdef QUOTA
  #include "quota.h"
  #endif
+ #include "syslog.h"

  #ifdef SMALL
  #define	INOHSZ	16		/* must be power of two */
diff -r -c /usr/src/oldsys/sys/ufs_mount.c /usr/src/sys/sys/ufs_mount.c
*** /usr/src/oldsys/sys/ufs_mount.c	Mon Jan 29 21:32:17 1990
--- /usr/src/sys/sys/ufs_mount.c	Sat Apr  7 18:07:25 1990
***************
*** 32,45 ****
  	dev_t dev;
  	register struct inode *ip;
  	register struct fs *fs;
  	u_int len;

  	u.u_error = getmdev(&dev, uap->fspec);
  	if (u.u_error)
  		return;
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = (caddr_t)uap->freg;
! 	ip = namei(LOOKUP | FOLLOW);
  	if (ip == NULL)
  		return;
  	if (ip->i_count != 1) {
--- 32,47 ----
  	dev_t dev;
  	register struct inode *ip;
  	register struct fs *fs;
+ 	register struct	nameidata *ndp = &u.u_nd;
  	u_int len;

  	u.u_error = getmdev(&dev, uap->fspec);
  	if (u.u_error)
  		return;
! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = (caddr_t)uap->freg;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return;
  	if (ip->i_count != 1) {
***************
*** 201,212 ****
  {
  	register dev_t dev;
  	register struct inode *ip;

  	if (!suser())
  		return (u.u_error);
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = fname;
! 	ip = namei(LOOKUP | FOLLOW);
  	if (ip == NULL) {
  		if (u.u_error == ENOENT)
  			return (ENODEV); /* needs translation */
--- 203,216 ----
  {
  	register dev_t dev;
  	register struct inode *ip;
+ 	register struct	nameidata *ndp = &u.u_nd;

  	if (!suser())
  		return (u.u_error);
! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = fname;
! 	ip = namei(ndp);
  	if (ip == NULL) {
  		if (u.u_error == ENOENT)
  			return (ENODEV); /* needs translation */
diff -r -c /usr/src/oldsys/sys/ufs_namei.c /usr/src/sys/sys/ufs_namei.c
*** /usr/src/oldsys/sys/ufs_namei.c	Wed Jan 31 22:59:39 1990
--- /usr/src/sys/sys/ufs_namei.c	Sun Apr  8 23:21:50 1990
***************
*** 9,14 ****
--- 9,15 ----
  #include "../machine/seg.h"

  #include "systm.h"
+ #include "dir.h"
  #include "inode.h"
  #include "fs.h"
  #include "mount.h"
***************
*** 81,87 ****
   * dirloop:
   *	check accessibility of directory
   * dirloop2:
!  *	copy next component of name to u.u_dent.d_name
   *	handle degenerate case where name is null string
   *	look for name in cache, if found, then if at end of path
   *	  and deleting or creating, drop it, else to haveino
--- 82,88 ----
   * dirloop:
   *	check accessibility of directory
   * dirloop2:
!  *	copy next component of name to ndp->ni_dent
   *	handle degenerate case where name is null string
   *	look for name in cache, if found, then if at end of path
   *	  and deleting or creating, drop it, else to haveino
***************
*** 105,112 ****
   *	 but unlocked.
   */
  struct inode *
! namei(nameiop)
! 	int nameiop;
  {
  	register char *cp;		/* pointer into pathname argument */
  /* these variables refer to things which must be freed or unlocked */
--- 106,113 ----
   *	 but unlocked.
   */
  struct inode *
! namei(ndp)
! 	register struct nameidata *ndp;
  {
  	register char *cp;		/* pointer into pathname argument */
  /* these variables refer to things which must be freed or unlocked */
***************
*** 122,133 ****
  	off_t endsearch;		/* offset to end directory search */
  	int nlink = 0;			/* number of symbolic links taken */
  	struct inode *pdp;		/* saved dp during symlink work */
! register int error, i;
  	int lockparent;
  	int docache;			/* == 0 do not cache last component */
  	int makeentry;			/* != 0 if name to be added to cache */
  	unsigned hash;			/* value of name hash for entry */
! 	union nchash *nhp;		/* cace chain head for entry */
  	int isdotdot;			/* != 0 if current name is ".." */
  	int flag;			/* op ie, LOOKUP, CREATE, or DELETE */
  	off_t enduseful;		/* pointer past last used dir slot */
--- 123,135 ----
  	off_t endsearch;		/* offset to end directory search */
  	int nlink = 0;			/* number of symbolic links taken */
  	struct inode *pdp;		/* saved dp during symlink work */
! register int i;
! 	int error;
  	int lockparent;
  	int docache;			/* == 0 do not cache last component */
  	int makeentry;			/* != 0 if name to be added to cache */
  	unsigned hash;			/* value of name hash for entry */
! 	union nchash *nhp;		/* cache chain head for entry */
  	int isdotdot;			/* != 0 if current name is ".." */
  	int flag;			/* op ie, LOOKUP, CREATE, or DELETE */
  	off_t enduseful;		/* pointer past last used dir slot */
***************
*** 135,153 ****
  	int	namelen;		/* length of last component */
  	segm	seg5;			/* save area for kernel seg5 */

! 	lockparent = nameiop & LOCKPARENT;
! 	docache = (nameiop & NOCACHE) ^ NOCACHE;
! 	flag = nameiop &~ (LOCKPARENT|NOCACHE|FOLLOW);
  	if (flag == DELETE || lockparent)
  		docache = 0;
  	/*
  	 * Copy the name into the buffer.
  	 */
! 	if (u.u_segflg == UIO_SYSSPACE)
! 		error = copystr(u.u_dirp, path, MAXPATHLEN,
  		    (u_int *)0);
  	else
! 		error = copyinstr(u.u_dirp, path, MAXPATHLEN,
  		    (u_int *)0);
  	if (error) {
  		u.u_error = error;
--- 137,155 ----
  	int	namelen;		/* length of last component */
  	segm	seg5;			/* save area for kernel seg5 */

! 	lockparent = ndp->ni_nameiop & LOCKPARENT;
! 	docache = (ndp->ni_nameiop & NOCACHE) ^ NOCACHE;
! 	flag = ndp->ni_nameiop &~ (LOCKPARENT|NOCACHE|FOLLOW);
  	if (flag == DELETE || lockparent)
  		docache = 0;
  	/*
  	 * Copy the name into the buffer.
  	 */
! 	if (ndp->ni_segflg == UIO_SYSSPACE)
! 		error = copystr(ndp->ni_dirp, path, MAXPATHLEN,
  		    (u_int *)0);
  	else
! 		error = copyinstr(ndp->ni_dirp, path, MAXPATHLEN,
  		    (u_int *)0);
  	if (error) {
  		u.u_error = error;
***************
*** 168,174 ****
  	fs = dp->i_fs;
  	ILOCK(dp);
  	dp->i_count++;
! 	u.ni_endoff = 0;

  	/*
  	 * We come to dirloop to search a new directory.
--- 170,176 ----
  	fs = dp->i_fs;
  	ILOCK(dp);
  	dp->i_count++;
! 	ndp->ni_endoff = 0;

  	/*
  	 * We come to dirloop to search a new directory.
***************
*** 188,198 ****

  dirloop2:
  	/*
! 	 * Copy next component of name to u.u_dent.d_name.
  	 */
  	hash = 0;
  	for (i = 0; *cp != 0 && *cp != '/'; cp++) {
! 		if (i == MAXNAMLEN) {
  #ifdef NO_FILE_NAME_MAPPING
  			u.u_error = ENAMETOOLONG;
  			goto bad;
--- 190,200 ----

  dirloop2:
  	/*
! 	 * Copy next component of name to ndp->ni_dent.
  	 */
  	hash = 0;
  	for (i = 0; *cp != 0 && *cp != '/'; cp++) {
! 		if (i >= MAXNAMLEN) {
  #ifdef NO_FILE_NAME_MAPPING
  			u.u_error = ENAMETOOLONG;
  			goto bad;
***************
*** 206,219 ****
  				u.u_error = EINVAL;
  				goto bad;
  			}
! 		u.u_dent.d_name[i++] = *cp;
  		hash += (unsigned char)*cp * i;
  	}
  	namelen = i;
  	while (i < MAXNAMLEN)
! 		u.u_dent.d_name[i++] = '\0';
! 	isdotdot = (u.u_dent.d_name[0] == '.' &&
! 		u.u_dent.d_name[1] == '.' && u.u_dent.d_name[2] == '\0');
  	makeentry = 1;
  	if (*cp == '\0' && docache == 0)
  		makeentry = 0;
--- 208,221 ----
  				u.u_error = EINVAL;
  				goto bad;
  			}
! 		ndp->ni_dent.d_name[i++] = *cp;
  		hash += (unsigned char)*cp * i;
  	}
  	namelen = i;
  	while (i < MAXNAMLEN)
! 		ndp->ni_dent.d_name[i++] = '\0';
! 	isdotdot = (ndp->ni_dent.d_name[0] == '.' &&
! 		ndp->ni_dent.d_name[1] == '.' && ndp->ni_dent.d_name[2] == '\0');
  	makeentry = 1;
  	if (*cp == '\0' && docache == 0)
  		makeentry = 0;
***************
*** 223,229 ****
  	 * which is a way of talking about a directory,
  	 * e.g. like "/." or ".".
  	 */
! 	 if (u.u_dent.d_name[0] == '\0') {
  		if (flag != LOOKUP || lockparent) {
  			u.u_error = EISDIR;
  			goto bad;
--- 225,231 ----
  	 * which is a way of talking about a directory,
  	 * e.g. like "/." or ".".
  	 */
! 	 if (ndp->ni_dent.d_name[0] == '\0') {
  		if (flag != LOOKUP || lockparent) {
  			u.u_error = EISDIR;
  			goto bad;
***************
*** 253,259 ****
  			if (ncp->nc_ino == dp->i_number &&
  			    ncp->nc_dev == dp->i_dev &&
  			    ncp->nc_nlen == namelen &&
! 			    !bcmp(ncp->nc_name, u.u_dent.d_name,
  				(unsigned)ncp->nc_nlen))
  				break;
  		}
--- 255,261 ----
  			if (ncp->nc_ino == dp->i_number &&
  			    ncp->nc_dev == dp->i_dev &&
  			    ncp->nc_nlen == namelen &&
! 			    !bcmp(ncp->nc_name, ndp->ni_dent.d_name,
  				(unsigned)ncp->nc_nlen))
  				break;
  		}
***************
*** 319,325 ****
  					dp = pdp;
  					nchstats.ncs_falsehits++;
  				} else {
! 					u.u_dent.d_ino = dp->i_number;
  					/* ni_dent.d_reclen is garbage ... */
  					nchstats.ncs_goodhits++;
  					restorseg5(seg5);
--- 321,327 ----
  					dp = pdp;
  					nchstats.ncs_falsehits++;
  				} else {
! 					ndp->ni_dent.d_ino = dp->i_number;
  					/* ni_dent.d_reclen is garbage ... */
  					nchstats.ncs_goodhits++;
  					restorseg5(seg5);
***************
*** 364,370 ****
  	 */
  	if (flag != LOOKUP || dp->i_number != u.u_ncache.nc_inumber ||
  		dp->i_dev != u.u_ncache.nc_dev) {
! 			u.u_offset = 0;
  			numdirpasses = 1;
  	} else {
  		register int entryoffsetinblock;
--- 366,372 ----
  	 */
  	if (flag != LOOKUP || dp->i_number != u.u_ncache.nc_inumber ||
  		dp->i_dev != u.u_ncache.nc_dev) {
! 			ndp->ni_offset = 0;
  			numdirpasses = 1;
  	} else {
  		register int entryoffsetinblock;
***************
*** 371,381 ****

  		if (u.u_ncache.nc_prevoffset > dp->i_size)
  			u.u_ncache.nc_prevoffset = 0;
! 		u.u_offset = u.u_ncache.nc_prevoffset;
! 		entryoffsetinblock = blkoff(u.u_offset);
  		if (entryoffsetinblock != 0) {
  			bp = bread(dp->i_dev,
! 			   bmap(dp,lblkno(u.u_offset),B_READ,0));
  			if (bp->b_flags & B_ERROR) {
  				brelse(bp);
  				bp = NULL;
--- 373,383 ----

  		if (u.u_ncache.nc_prevoffset > dp->i_size)
  			u.u_ncache.nc_prevoffset = 0;
! 		ndp->ni_offset = u.u_ncache.nc_prevoffset;
! 		entryoffsetinblock = blkoff(ndp->ni_offset);
  		if (entryoffsetinblock != 0) {
  			bp = bread(dp->i_dev,
! 			   bmap(dp,lblkno(ndp->ni_offset),B_READ,0));
  			if (bp->b_flags & B_ERROR) {
  				brelse(bp);
  				bp = NULL;
***************
*** 392,410 ****
  	slotoffset = -1;

  searchloop:
! 	while (u.u_offset < endsearch) {
  		/*
  		 * If offset is on a block boundary,
  		 * read the next directory block.
  		 * Release previous if it exists.
  		 */
! 		if (blkoff(u.u_offset) == 0) {
  			if (bp != NULL) {
  				mapout(bp);
  				brelse(bp);
  			}
  			bp = bread(dp->i_dev,
! 			    bmap(dp,lblkno(u.u_offset),B_READ,0));
  			if (bp->b_flags & B_ERROR) {
  				brelse(bp);
  				bp = NULL;
--- 394,412 ----
  	slotoffset = -1;

  searchloop:
! 	while (ndp->ni_offset < endsearch) {
  		/*
  		 * If offset is on a block boundary,
  		 * read the next directory block.
  		 * Release previous if it exists.
  		 */
! 		if (blkoff(ndp->ni_offset) == 0) {
  			if (bp != NULL) {
  				mapout(bp);
  				brelse(bp);
  			}
  			bp = bread(dp->i_dev,
! 			    bmap(dp,lblkno(ndp->ni_offset),B_READ,0));
  			if (bp->b_flags & B_ERROR) {
  				brelse(bp);
  				bp = NULL;
***************
*** 419,425 ****
  		 * slotoffset for possible create.
  		 */
  		if (ep->d_ino) {
! 			register short	*p1 = (short *)u.u_dent.d_name,
  					*p2 = (short *)ep->d_name;

  			if (*p1++ == *p2++ && *p1++ == *p2++ &&
--- 421,427 ----
  		 * slotoffset for possible create.
  		 */
  		if (ep->d_ino) {
! 			register short	*p1 = (short *)ndp->ni_dent.d_name,
  					*p2 = (short *)ep->d_name;

  			if (*p1++ == *p2++ && *p1++ == *p2++ &&
***************
*** 429,438 ****
  				goto found;
  		}
  		else if (slotoffset == -1)
! 			slotoffset = u.u_offset;
! 		u.u_offset += sizeof(struct v7direct);
  		if (ep->d_ino)
! 			enduseful = u.u_offset;
  		++ep;
  	}
  /* notfound: */
--- 431,440 ----
  				goto found;
  		}
  		else if (slotoffset == -1)
! 			slotoffset = ndp->ni_offset;
! 		ndp->ni_offset += sizeof(struct v7direct);
  		if (ep->d_ino)
! 			enduseful = ndp->ni_offset;
  		++ep;
  	}
  /* notfound: */
***************
*** 442,448 ****
  	 */
  	if (numdirpasses == 2) {
  		numdirpasses--;
! 		u.u_offset = 0;
  		endsearch = u.u_ncache.nc_prevoffset;
  		goto searchloop;
  	}
--- 444,450 ----
  	 */
  	if (numdirpasses == 2) {
  		numdirpasses--;
! 		ndp->ni_offset = 0;
  		endsearch = u.u_ncache.nc_prevoffset;
  		goto searchloop;
  	}
***************
*** 451,457 ****
  	 * directory has not been removed, then can consider
  	 * allowing file to be created.
  	 */
! 	if (flag == CREATE && *cp == '\0' && dp->i_nlink != 0) {
  		/*
  		 * Access for write is interpreted as allowing
  		 * creation of files in the directory.
--- 453,459 ----
  	 * directory has not been removed, then can consider
  	 * allowing file to be created.
  	 */
! 	if (flag == CREATE && *cp == 0 && dp->i_nlink != 0) {
  		/*
  		 * Access for write is interpreted as allowing
  		 * creation of files in the directory.
***************
*** 461,478 ****
  		/*
  		 * Return an indication of where the new directory
  		 * entry should be put.  If we didn't find a slot,
! 		 * then u.u_offset is already correct.  If we found
! 		 * a slot, then set u.u_offset to reflect it.
  		 */
  		if (slotoffset == -1)
! 			u.ni_endoff = 0;
  		else {
! 			u.u_offset = slotoffset;
  			if (enduseful < slotoffset + sizeof(struct v7direct))
! 				u.ni_endoff =
  				    slotoffset + sizeof(struct v7direct);
  			else
! 				u.ni_endoff = enduseful;
  		}
  		dp->i_flag |= IUPD|ICHG;
  		if (bp) {
--- 463,480 ----
  		/*
  		 * Return an indication of where the new directory
  		 * entry should be put.  If we didn't find a slot,
! 		 * then ndp->ni_offset is already correct.  If we found
! 		 * a slot, then set ndp->ni_offset to reflect it.
  		 */
  		if (slotoffset == -1)
! 			ndp->ni_endoff = 0;
  		else {
! 			ndp->ni_offset = slotoffset;
  			if (enduseful < slotoffset + sizeof(struct v7direct))
! 				ndp->ni_endoff =
  				    slotoffset + sizeof(struct v7direct);
  			else
! 				ndp->ni_endoff = enduseful;
  		}
  		dp->i_flag |= IUPD|ICHG;
  		if (bp) {
***************
*** 485,493 ****
  		 * valid if we actually decide to do a direnter().
  		 * We return NULL to indicate that the entry doesn't
  		 * currently exist, leaving a pointer to the (locked)
! 		 * directory inode in u.u_pdir.
  		 */
! 		u.u_pdir = dp;
  		return (NULL);
  	}
  	u.u_error = ENOENT;
--- 487,495 ----
  		 * valid if we actually decide to do a direnter().
  		 * We return NULL to indicate that the entry doesn't
  		 * currently exist, leaving a pointer to the (locked)
! 		 * directory inode in ndp->ni_pdir.
  		 */
! 		ndp->ni_pdir = dp;
  		return (NULL);
  	}
  	u.u_error = ENOENT;
***************
*** 501,511 ****
  	 * in the cache as to where the entry was found.
  	 */
  	if (*cp == '\0' && flag == LOOKUP) {
! 		u.u_ncache.nc_prevoffset = u.u_offset;
  		u.u_ncache.nc_inumber = dp->i_number;
  		u.u_ncache.nc_dev = dp->i_dev;
  	}
! 	u.u_dent.d_ino = ep->d_ino;
  	mapout(bp);
  	brelse(bp);
  	bp = NULL;
--- 503,513 ----
  	 * in the cache as to where the entry was found.
  	 */
  	if (*cp == '\0' && flag == LOOKUP) {
! 		u.u_ncache.nc_prevoffset = ndp->ni_offset;
  		u.u_ncache.nc_inumber = dp->i_number;
  		u.u_ncache.nc_dev = dp->i_dev;
  	}
! 	ndp->ni_dent.d_ino = ep->d_ino;
  	mapout(bp);
  	brelse(bp);
  	bp = NULL;
***************
*** 514,520 ****
  	 * If deleting, and at end of pathname, return
  	 * parameters which can be used to remove file.
  	 * If the lockparent flag isn't set, we return only
! 	 * the directory (in u.u_pdir), otherwise we go
  	 * on and lock the inode, being careful with ".".
  	 */
  	if (flag == DELETE && *cp == 0) {
--- 516,522 ----
  	 * If deleting, and at end of pathname, return
  	 * parameters which can be used to remove file.
  	 * If the lockparent flag isn't set, we return only
! 	 * the directory (in ndp->ni_pdir), otherwise we go
  	 * on and lock the inode, being careful with ".".
  	 */
  	if (flag == DELETE && *cp == 0) {
***************
*** 523,540 ****
  		 */
  		if (access(dp, IWRITE))
  			goto bad;
! 		u.u_pdir = dp;		/* for dirremove() */
  		/*
! 		 * Return pointer to current entry in u.u_offset.
! 		 * Save directory inode pointer in u.u_pdir for dirremove().
  		 */
  		if (lockparent) {
! 			if (dp->i_number == u.u_dent.d_ino)
  				dp->i_count++;
  			else {
! 				dp = iget(dp->i_dev, fs, u.u_dent.d_ino);
  				if (dp == NULL) {
! 					iput(u.u_pdir);
  					goto bad;
  				}
  				/*
--- 525,542 ----
  		 */
  		if (access(dp, IWRITE))
  			goto bad;
! 		ndp->ni_pdir = dp;		/* for dirremove() */
  		/*
! 		 * Return pointer to current entry in ndp->ni_offset.
! 		 * Save directory inode pointer in ndp->ni_pdir for dirremove().
  		 */
  		if (lockparent) {
! 			if (dp->i_number == ndp->ni_dent.d_ino)
  				dp->i_count++;
  			else {
! 				dp = iget(dp->i_dev, fs, ndp->ni_dent.d_ino);
  				if (dp == NULL) {
! 					iput(ndp->ni_pdir);
  					goto bad;
  				}
  				/*
***************
*** 543,553 ****
  				 * may not delete it (unless he's root). This
  				 * implements append-only directories.
  				 */
! 				if ((u.u_pdir->i_mode & ISVTX) &&
  				    u.u_uid != 0 &&
! 				    u.u_uid != u.u_pdir->i_uid &&
  				    dp->i_uid != u.u_uid) {
! 					iput(u.u_pdir);
  					u.u_error = EPERM;
  					goto bad;
  				}
--- 545,555 ----
  				 * may not delete it (unless he's root). This
  				 * implements append-only directories.
  				 */
! 				if ((ndp->ni_pdir->i_mode & ISVTX) &&
  				    u.u_uid != 0 &&
! 				    u.u_uid != ndp->ni_pdir->i_uid &&
  				    dp->i_uid != u.u_uid) {
! 					iput(ndp->ni_pdir);
  					u.u_error = EPERM;
  					goto bad;
  				}
***************
*** 563,571 ****
  	 */
  	if (isdotdot) {
  		if (dp == u.u_rdir) {
! 			u.u_dent.d_ino = dp->i_number;
  			makeentry = 0;
! 		} else if (u.u_dent.d_ino == ROOTINO &&
  		    dp->i_number == ROOTINO) {
  			register struct mount *mp;
  			register dev_t d;
--- 565,573 ----
  	 */
  	if (isdotdot) {
  		if (dp == u.u_rdir) {
! 			ndp->ni_dent.d_ino = dp->i_number;
  			makeentry = 0;
! 		} else if (ndp->ni_dent.d_ino == ROOTINO &&
  		    dp->i_number == ROOTINO) {
  			register struct mount *mp;
  			register dev_t d;
***************
*** 593,610 ****
  	if ((flag == CREATE && lockparent) && *cp == 0) {
  		if (access(dp, IWRITE))
  			goto bad;
! 		u.u_pdir = dp;		/* for dirrewrite() */
  		/*
  		 * Careful about locking second inode.
  		 * This can only occur if the target is ".".
  		 */
! 		if (dp->i_number == u.u_dent.d_ino) {
  			u.u_error = EISDIR;		/* XXX */
  			goto bad;
  		}
! 		dp = iget(dp->i_dev, fs, u.u_dent.d_ino);
  		if (dp == NULL) {
! 			iput(u.u_pdir);
  			goto bad;
  		}
  		return (dp);
--- 595,612 ----
  	if ((flag == CREATE && lockparent) && *cp == 0) {
  		if (access(dp, IWRITE))
  			goto bad;
! 		ndp->ni_pdir = dp;		/* for dirrewrite() */
  		/*
  		 * Careful about locking second inode.
  		 * This can only occur if the target is ".".
  		 */
! 		if (dp->i_number == ndp->ni_dent.d_ino) {
  			u.u_error = EISDIR;		/* XXX */
  			goto bad;
  		}
! 		dp = iget(dp->i_dev, fs, ndp->ni_dent.d_ino);
  		if (dp == NULL) {
! 			iput(ndp->ni_pdir);
  			goto bad;
  		}
  		return (dp);
***************
*** 633,645 ****
  	pdp = dp;
  	if (isdotdot) {
  		IUNLOCK(pdp);	/* race to get the inode */
! 		dp = iget(dp->i_dev, dp->i_fs, u.u_dent.d_ino);
  		if (dp == NULL)
  			goto bad2;
! 	} else if (dp->i_number == u.u_dent.d_ino) {
  		dp->i_count++;	/* we want ourself, ie "." */
  	} else {
! 		dp = iget(dp->i_dev, dp->i_fs, u.u_dent.d_ino);
  		IUNLOCK(pdp);
  		if (dp == NULL)
  			goto bad2;
--- 635,647 ----
  	pdp = dp;
  	if (isdotdot) {
  		IUNLOCK(pdp);	/* race to get the inode */
! 		dp = iget(dp->i_dev, dp->i_fs, ndp->ni_dent.d_ino);
  		if (dp == NULL)
  			goto bad2;
! 	} else if (dp->i_number == ndp->ni_dent.d_ino) {
  		dp->i_count++;	/* we want ourself, ie "." */
  	} else {
! 		dp = iget(dp->i_dev, dp->i_fs, ndp->ni_dent.d_ino);
  		IUNLOCK(pdp);
  		if (dp == NULL)
  			goto bad2;
***************
*** 672,678 ****
  			ncp->nc_idev = dp->i_dev;	/* our device */
  			ncp->nc_id = nmi_i_id[dp - inode];	/* identifier */
  			ncp->nc_nlen = namelen;
! 			bcopy(u.u_dent.d_name, ncp->nc_name,
  			    (unsigned)ncp->nc_nlen);
  			/* link at end of lru chain */
  			ncp->nc_nxt = NULL;
--- 674,680 ----
  			ncp->nc_idev = dp->i_dev;	/* our device */
  			ncp->nc_id = nmi_i_id[dp - inode];	/* identifier */
  			ncp->nc_nlen = namelen;
! 			bcopy(ndp->ni_dent.d_name, ncp->nc_name,
  			    (unsigned)ncp->nc_nlen);
  			/* link at end of lru chain */
  			ncp->nc_nxt = NULL;
***************
*** 692,698 ****
  	 * Check for symbolic link
  	 */
  	if ((dp->i_mode & IFMT) == IFLNK &&
! 	    ((nameiop & FOLLOW) || *cp == '/')) {
  		register int pathlen = strlen(cp) + 1;

  		if (dp->i_size + pathlen >= MAXPATHLEN - 1) {
--- 694,700 ----
  	 * Check for symbolic link
  	 */
  	if ((dp->i_mode & IFMT) == IFLNK &&
! 	    ((ndp->ni_nameiop & FOLLOW) || *cp == '/')) {
  		register int pathlen = strlen(cp) + 1;

  		if (dp->i_size + pathlen >= MAXPATHLEN - 1) {
***************
*** 748,754 ****
  		goto dirloop;
  	}
  	if (lockparent)
! 		u.u_pdir = pdp;
  	else
  		irele(pdp);
  	return (dp);
--- 750,756 ----
  		goto dirloop;
  	}
  	if (lockparent)
! 		ndp->ni_pdir = pdp;
  	else
  		irele(pdp);
  	return (dp);
***************
*** 768,786 ****
   * Write a directory entry with parameters left as side effects
   * to a call to namei.
   */
! direnter(ip)
! 	struct inode *ip;
  {

! 	u.u_dent.d_ino = ip->i_number;
! 	u.u_count = sizeof(struct v7direct);
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_base = (caddr_t)&u.u_dent;
! 	writei(u.u_pdir);
! 	if (u.ni_endoff &&
! 	    u.u_pdir->i_size - u.ni_endoff > sizeof(struct v7direct) * 10)
! 		itrunc(u.u_pdir, (u_long)u.ni_endoff);
! 	iput(u.u_pdir);
  	return(u.u_error);
  }

--- 770,788 ----
   * Write a directory entry with parameters left as side effects
   * to a call to namei.
   */
! direnter(ip, ndp)
! register struct inode *ip;
! register struct nameidata *ndp;
  {

! 	ndp->ni_dent.d_ino = ip->i_number;
! 	u.u_error = rdwri(UIO_WRITE, ndp->ni_pdir, &ndp->ni_dent,
! 			sizeof(struct v7direct), ndp->ni_offset,
! 			UIO_SYSSPACE, (int *)0);
! 	if (ndp->ni_endoff &&
! 	    ndp->ni_pdir->i_size - ndp->ni_endoff > sizeof(struct v7direct) * 10)
! 		itrunc(ndp->ni_pdir, (u_long)ndp->ni_endoff);
! 	iput(ndp->ni_pdir);
  	return(u.u_error);
  }

***************
*** 787,802 ****
  /*
   * Remove a directory entry after a call to namei, using the
   * parameters which it left in the u. area.  The u. entry
!  * u_offset contains the offset into the directory of the
   * entry to be eliminated.
   */
! dirremove()
  {
! 	u.u_dent.d_ino = 0;
! 	u.u_count = sizeof(struct v7direct);
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_base = (caddr_t)&u.u_dent;
! 	writei(u.u_pdir);
  	return(u.u_error);
  }

--- 789,804 ----
  /*
   * Remove a directory entry after a call to namei, using the
   * parameters which it left in the u. area.  The u. entry
!  * ni_offset contains the offset into the directory of the
   * entry to be eliminated.
   */
! dirremove(ndp)
! register struct nameidata *ndp;
  {
! 	ndp->ni_dent.d_ino = 0;
! 	u.u_error = rdwri(UIO_WRITE, ndp->ni_pdir, &ndp->ni_dent,
! 			sizeof(struct v7direct), ndp->ni_offset,
! 			UIO_SYSSPACE, (int *)0);
  	return(u.u_error);
  }

***************
*** 805,819 ****
   * supplied.  The parameters describing the directory entry are
   * set up by a call to namei.
   */
! dirrewrite(dp, ip)
  	register struct inode *dp;
  	struct inode *ip;
  {
! 	u.u_dent.d_ino = ip->i_number;
! 	u.u_count = sizeof(struct v7direct);
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_base = (caddr_t)&u.u_dent;
! 	writei(dp);
  	iput(dp);
  }

--- 807,820 ----
   * supplied.  The parameters describing the directory entry are
   * set up by a call to namei.
   */
! dirrewrite(dp, ip, ndp)
  	register struct inode *dp;
  	struct inode *ip;
+ 	register struct nameidata *ndp;
  {
! 	ndp->ni_dent.d_ino = ip->i_number;
! 	u.u_error = rdwri(UIO_WRITE, dp, &ndp->ni_dent, sizeof(struct v7direct),
! 			ndp->ni_offset, UIO_SYSSPACE, (int *)0);
  	iput(dp);
  }

***************
*** 886,901 ****
  	if (ip->i_number == ROOTINO)
  		goto out;

- 	u.u_segflg = UIO_SYSSPACE;
  	for (;;) {
  		if ((ip->i_mode&IFMT) != IFDIR) {
  			error = ENOTDIR;
  			break;
  		}
! 		u.u_base = (caddr_t)&dirbuf;
! 		u.u_count = sizeof(struct dirtemplate);
! 		u.u_offset = 0;
! 		readi(ip);
  		if (u.u_error != 0) {
  			error = u.u_error;
  			break;
--- 887,899 ----
  	if (ip->i_number == ROOTINO)
  		goto out;

  	for (;;) {
  		if ((ip->i_mode&IFMT) != IFDIR) {
  			error = ENOTDIR;
  			break;
  		}
! 		u.u_error = rdwri(UIO_READ, ip, &dirbuf,
! 			sizeof(struct dirtemplate), (off_t)0, UIO_SYSSPACE,0);
  		if (u.u_error != 0) {
  			error = u.u_error;
  			break;
diff -r -c /usr/src/oldsys/sys/ufs_syscalls.c /usr/src/sys/sys/ufs_syscalls.c
*** /usr/src/oldsys/sys/ufs_syscalls.c	Mon Jan 29 21:22:25 1990
--- /usr/src/sys/sys/ufs_syscalls.c	Sun Apr  8 01:32:01 1990
***************
*** 50,59 ****
  	register struct a {
  		char	*fname;
  	} *uap = (struct a *)u.u_ap;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->fname;
! 	ip = namei(LOOKUP | FOLLOW);
  	if (ip == NULL)
  		return;
  	if ((ip->i_mode&IFMT) != IFDIR) {
--- 50,61 ----
  	register struct a {
  		char	*fname;
  	} *uap = (struct a *)u.u_ap;
+ 	register struct	nameidata *ndp = &u.u_nd;

! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->fname;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return;
  	if ((ip->i_mode&IFMT) != IFDIR) {
***************
*** 111,116 ****
--- 113,119 ----
  {
  	register struct inode *ip;
  	register struct file *fp;
+ 	register struct	nameidata *ndp = &u.u_nd;
  	int indx;

  	fp = falloc();
***************
*** 117,130 ****
  	if (fp == NULL)
  		return;
  	indx = u.u_r.r_val1;
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = fname;
  	if (mode&FCREAT) {
! 		ip = namei(mode & FEXCL ? CREATE : CREATE | FOLLOW);
  		if (ip == NULL) {
  			if (u.u_error)
  				goto bad1;
! 			ip = maknode(arg&07777&(~ISVTX));
  			if (ip == NULL)
  				goto bad1;
  			mode &= ~FTRUNC;
--- 120,137 ----
  	if (fp == NULL)
  		return;
  	indx = u.u_r.r_val1;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = fname;
  	if (mode&FCREAT) {
! 		if (mode & FEXCL)
! 			ndp->ni_nameiop = CREATE;
! 		else
! 			ndp->ni_nameiop = CREATE | FOLLOW;
! 		ip = namei(ndp);
  		if (ip == NULL) {
  			if (u.u_error)
  				goto bad1;
! 			ip = maknode(arg&07777&(~ISVTX), ndp);
  			if (ip == NULL)
  				goto bad1;
  			mode &= ~FTRUNC;
***************
*** 136,142 ****
  			mode &= ~FCREAT;
  		}
  	} else {
! 		ip = namei(LOOKUP | FOLLOW);
  		if (ip == NULL)
  			goto bad1;
  	}
--- 143,150 ----
  			mode &= ~FCREAT;
  		}
  	} else {
! 		ndp->ni_nameiop = LOOKUP | FOLLOW;
! 		ip = namei(ndp);
  		if (ip == NULL)
  			goto bad1;
  	}
***************
*** 167,173 ****
  		if (u.u_error == 0)
  			u.u_error = EINTR;
  		u.u_ofile[indx] = NULL;
! 		closef(fp,0);
  		return;
  	}
  	u.u_error = openi(ip, mode);
--- 175,181 ----
  		if (u.u_error == 0)
  			u.u_error = EINTR;
  		u.u_ofile[indx] = NULL;
! 		closef(fp);
  		return;
  	}
  	u.u_error = openi(ip, mode);
***************
*** 192,203 ****
  		int	fmode;
  		u_int	dev;
  	} *uap = (struct a *)u.u_ap;

  	if (!suser())
  		return;
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->fname;
! 	ip = namei(CREATE | NOFOLLOW);
  	if (ip != NULL) {
  		u.u_error = EEXIST;
  		goto out;
--- 200,213 ----
  		int	fmode;
  		u_int	dev;
  	} *uap = (struct a *)u.u_ap;
+ 	register struct	nameidata *ndp = &u.u_nd;

  	if (!suser())
  		return;
! 	ndp->ni_nameiop = CREATE;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->fname;
! 	ip = namei(ndp);
  	if (ip != NULL) {
  		u.u_error = EEXIST;
  		goto out;
***************
*** 204,210 ****
  	}
  	if (u.u_error)
  		return;
! 	ip = maknode(uap->fmode);
  	if (ip == NULL)
  		return;
  	switch (ip->i_mode & IFMT) {
--- 214,220 ----
  	}
  	if (u.u_error)
  		return;
! 	ip = maknode(uap->fmode, ndp);
  	if (ip == NULL)
  		return;
  	switch (ip->i_mode & IFMT) {
***************
*** 237,246 ****
  		char	*target;
  		char	*linkname;
  	} *uap = (struct a *)u.u_ap;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->target;
! 	ip = namei(LOOKUP | FOLLOW);
  	if (ip == NULL)
  		return;
  	if ((ip->i_mode&IFMT) == IFDIR && !suser()) {
--- 247,258 ----
  		char	*target;
  		char	*linkname;
  	} *uap = (struct a *)u.u_ap;
+ 	register struct	nameidata *ndp = &u.u_nd;

! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->target;
! 	ip = namei(ndp);	/* well, this routine is doomed anyhow */
  	if (ip == NULL)
  		return;
  	if ((ip->i_mode&IFMT) == IFDIR && !suser()) {
***************
*** 251,259 ****
  	ip->i_flag |= ICHG;
  	iupdat(ip, &time, &time, 1);
  	IUNLOCK(ip);
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = (caddr_t)uap->linkname;
! 	xp = namei(CREATE | NOFOLLOW);
  	if (xp != NULL) {
  		u.u_error = EEXIST;
  		iput(xp);
--- 263,272 ----
  	ip->i_flag |= ICHG;
  	iupdat(ip, &time, &time, 1);
  	IUNLOCK(ip);
! 	ndp->ni_nameiop = CREATE;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = (caddr_t)uap->linkname;
! 	xp = namei(ndp);
  	if (xp != NULL) {
  		u.u_error = EEXIST;
  		iput(xp);
***************
*** 261,272 ****
  	}
  	if (u.u_error)
  		goto out;
! 	if (u.u_pdir->i_dev != ip->i_dev) {
! 		iput(u.u_pdir);
  		u.u_error = EXDEV;
  		goto out;
  	}
! 	u.u_error = direnter(ip);
  out:
  	if (u.u_error) {
  		ip->i_nlink--;
--- 274,285 ----
  	}
  	if (u.u_error)
  		goto out;
! 	if (ndp->ni_pdir->i_dev != ip->i_dev) {
! 		iput(ndp->ni_pdir);
  		u.u_error = EXDEV;
  		goto out;
  	}
! 	u.u_error = direnter(ip, ndp);
  out:
  	if (u.u_error) {
  		ip->i_nlink--;
***************
*** 287,292 ****
--- 300,306 ----
  	register struct inode *ip;
  	register char *tp;
  	register c, nc;
+ 	register struct	nameidata *ndp = &u.u_nd;

  	tp = uap->target;
  	nc = 0;
***************
*** 298,306 ****
  		tp++;
  		nc++;
  	}
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->linkname;
! 	ip = namei(CREATE);
  	if (ip) {
  		iput(ip);
  		u.u_error = EEXIST;
--- 312,321 ----
  		tp++;
  		nc++;
  	}
! 	ndp->ni_nameiop = CREATE;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->linkname;
! 	ip = namei(ndp);
  	if (ip) {
  		iput(ip);
  		u.u_error = EEXIST;
***************
*** 308,321 ****
  	}
  	if (u.u_error)
  		return;
! 	ip = maknode(IFLNK | 0777);
  	if (ip == NULL)
  		return;
! 	u.u_base = uap->target;
! 	u.u_count = nc;
! 	u.u_offset = 0;
! 	u.u_segflg = UIO_USERSPACE;
! 	writei(ip);
  	iput(ip);
  }

--- 323,333 ----
  	}
  	if (u.u_error)
  		return;
! 	ip = maknode(IFLNK | 0777, ndp);
  	if (ip == NULL)
  		return;
! 	u.u_error = rdwri(UIO_WRITE, ip, uap->target, nc, (off_t)0,
! 			UIO_USERSPACE, (int *)0);
  	iput(ip);
  }

***************
*** 330,342 ****
  		char	*fname;
  	} *uap = (struct a *)u.u_ap;
  	register struct inode *ip, *dp;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->fname;
! 	ip = namei(DELETE | LOCKPARENT);
  	if (ip == NULL)
  		return;
! 	dp = u.u_pdir;
  	if ((ip->i_mode&IFMT) == IFDIR && !suser())
  		goto out;
  	/*
--- 342,356 ----
  		char	*fname;
  	} *uap = (struct a *)u.u_ap;
  	register struct inode *ip, *dp;
+ 	register struct	nameidata *ndp = &u.u_nd;

! 	ndp->ni_nameiop = DELETE | LOCKPARENT;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->fname;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return;
! 	dp = ndp->ni_pdir;
  	if ((ip->i_mode&IFMT) == IFDIR && !suser())
  		goto out;
  	/*
***************
*** 348,354 ****
  	}
  	if (ip->i_flag&ITEXT)
  		xuntext(ip->i_text);	/* try once to free text */
! 	if (!dirremove()) {
  		ip->i_nlink--;
  		ip->i_flag |= ICHG;
  	}
--- 362,368 ----
  	}
  	if (ip->i_flag&ITEXT)
  		xuntext(ip->i_text);	/* try once to free text */
! 	if (!dirremove(ndp)) {
  		ip->i_nlink--;
  		ip->i_flag |= ICHG;
  	}
***************
*** 409,422 ****
  		char	*fname;
  		int	fmode;
  	} *uap = (struct a *)u.u_ap;

  	svuid = u.u_uid;
  	svgid = u.u_gid;
  	u.u_uid = u.u_ruid;
  	u.u_gid = u.u_rgid;
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->fname;
! 	ip = namei(LOOKUP | FOLLOW);
  	if (ip != NULL) {
  		if ((uap->fmode&R_OK) && access(ip, IREAD))
  			goto done;
--- 423,438 ----
  		char	*fname;
  		int	fmode;
  	} *uap = (struct a *)u.u_ap;
+ 	register struct	nameidata *ndp = &u.u_nd;

  	svuid = u.u_uid;
  	svgid = u.u_gid;
  	u.u_uid = u.u_ruid;
  	u.u_gid = u.u_rgid;
! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->fname;
! 	ip = namei(ndp);
  	if (ip != NULL) {
  		if ((uap->fmode&R_OK) && access(ip, IREAD))
  			goto done;
***************
*** 458,467 ****
  		struct stat *ub;
  	} *uap = (struct a *)u.u_ap;
  	struct stat sb;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->fname;
! 	ip = namei(LOOKUP | follow);
  	if (ip == NULL)
  		return;
  	(void) ino_stat(ip, &sb);
--- 474,485 ----
  		struct stat *ub;
  	} *uap = (struct a *)u.u_ap;
  	struct stat sb;
+ 	register struct	nameidata *ndp = &u.u_nd;

! 	ndp->ni_nameiop = LOOKUP | follow;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->fname;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return;
  	(void) ino_stat(ip, &sb);
***************
*** 480,489 ****
  		char	*buf;
  		int	count;
  	} *uap = (struct a *)u.u_ap;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->name;
! 	ip = namei(LOOKUP | NOFOLLOW);
  	if (ip == NULL)
  		return;
  	if ((ip->i_mode&IFMT) != IFLNK) {
--- 498,510 ----
  		char	*buf;
  		int	count;
  	} *uap = (struct a *)u.u_ap;
+ 	register struct	nameidata *ndp = &u.u_nd;
+ 	int resid;

! 	ndp->ni_nameiop = LOOKUP;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->name;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return;
  	if ((ip->i_mode&IFMT) != IFLNK) {
***************
*** 490,503 ****
  		u.u_error = EINVAL;
  		goto out;
  	}
! 	u.u_offset = 0;
! 	u.u_base = uap->buf;
! 	u.u_count = uap->count;
! 	u.u_segflg = UIO_USERSPACE;
! 	readi(ip);
  out:
  	iput(ip);
! 	u.u_r.r_val1 = uap->count - u.u_count;
  }

  /*
--- 511,521 ----
  		u.u_error = EINVAL;
  		goto out;
  	}
! 	u.u_error = rdwri(UIO_READ, ip, uap->buf, uap->count, (off_t)0,
! 			UIO_USERSPACE, &resid);
  out:
  	iput(ip);
! 	u.u_r.r_val1 = uap->count - resid;
  }

  /*
***************
*** 576,585 ****
  		int	uid;
  		int	gid;
  	} *uap = (struct a *)u.u_ap;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->fname;
! 	ip = namei(LOOKUP | NOFOLLOW);
  	if (ip == NULL)
  		return;
  	u.u_error = chown1(ip, uap->uid, uap->gid);
--- 594,605 ----
  		int	uid;
  		int	gid;
  	} *uap = (struct a *)u.u_ap;
+ 	register struct	nameidata *ndp = &u.u_nd;

! 	ndp->ni_nameiop = LOOKUP | NOFOLLOW;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->fname;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return;
  	u.u_error = chown1(ip, uap->uid, uap->gid);
***************
*** 702,711 ****
  		off_t	length;
  	} *uap = (struct a *)u.u_ap;
  	register struct inode *ip;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->fname;
! 	ip = namei(LOOKUP | FOLLOW);
  	if (ip == NULL)
  		return;
  	if (access(ip, IWRITE))
--- 722,733 ----
  		off_t	length;
  	} *uap = (struct a *)u.u_ap;
  	register struct inode *ip;
+ 	register struct	nameidata *ndp = &u.u_nd;

! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->fname;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return;
  	if (access(ip, IWRITE))
***************
*** 800,817 ****
  	register struct inode *ip, *xp, *dp;
  	struct dirtemplate dirbuf;
  	int doingdirectory = 0, oldparent = 0, newparent = 0;
  	int error = 0;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->from;
! 	ip = namei(DELETE | LOCKPARENT);
  	if (ip == NULL)
  		return;
! 	dp = u.u_pdir;
  	if ((ip->i_mode&IFMT) == IFDIR) {
  		register struct v7direct *d;

! 		d = &u.u_dent;
  		/*
  		 * Avoid ".", "..", and aliases of "." for obvious reasons.
  		 */
--- 822,841 ----
  	register struct inode *ip, *xp, *dp;
  	struct dirtemplate dirbuf;
  	int doingdirectory = 0, oldparent = 0, newparent = 0;
+ 	register struct nameidata *ndp = &u.u_nd;
  	int error = 0;

! 	ndp->ni_nameiop = DELETE | LOCKPARENT;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->from;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return;
! 	dp = ndp->ni_pdir;
  	if ((ip->i_mode&IFMT) == IFDIR) {
  		register struct v7direct *d;

! 		d = &ndp->ni_dent;
  		/*
  		 * Avoid ".", "..", and aliases of "." for obvious reasons.
  		 */
***************
*** 847,859 ****
  	 * When the target exists, both the directory
  	 * and target inodes are returned locked.
  	 */
! 	u.u_dirp = (caddr_t)uap->to;
! 	xp = namei(CREATE | LOCKPARENT | NOCACHE);
  	if (u.u_error) {
  		error = u.u_error;
  		goto out;
  	}
! 	dp = u.u_pdir;
  	/*
  	 * If ".." must be changed (ie the directory gets a new
  	 * parent) then the source directory must not be in the
--- 871,884 ----
  	 * When the target exists, both the directory
  	 * and target inodes are returned locked.
  	 */
! 	ndp->ni_nameiop = CREATE | LOCKPARENT | NOCACHE;
! 	ndp->ni_dirp = (caddr_t)uap->to;
! 	xp = namei(ndp);
  	if (u.u_error) {
  		error = u.u_error;
  		goto out;
  	}
! 	dp = ndp->ni_pdir;
  	/*
  	 * If ".." must be changed (ie the directory gets a new
  	 * parent) then the source directory must not be in the
***************
*** 869,895 ****
  	if (doingdirectory && newparent) {
  		if (access(ip, IWRITE))
  			goto bad;
! 		for (;;) {
! 			dev_t	sdev;
! 			ino_t	sino;
!
! 			sdev = u.u_pdir->i_dev;
! 			sino = u.u_pdir->i_number;
  			if (xp != NULL)
  				iput(xp);
! 			u.u_error = checkpath(ip, u.u_pdir);
  			if (u.u_error)
  				goto out;
! 			u.u_segflg = UIO_USERSPACE;
! 			xp = namei(CREATE | LOCKPARENT);
  			if (u.u_error) {
  				error = u.u_error;
  				goto out;
  			}
! 			dp = u.u_pdir;
! 			if (sdev == dp->i_dev && sino == dp->i_number)
! 				break;
! 		}
  	}
  	/*
  	 * 2) If target doesn't exist, link the target
--- 894,912 ----
  	if (doingdirectory && newparent) {
  		if (access(ip, IWRITE))
  			goto bad;
! 		do {
! 			dp = ndp->ni_pdir;
  			if (xp != NULL)
  				iput(xp);
! 			u.u_error = checkpath(ip, dp);
  			if (u.u_error)
  				goto out;
! 			xp = namei(ndp);
  			if (u.u_error) {
  				error = u.u_error;
  				goto out;
  			}
! 		} while (dp != ndp->ni_pdir);
  	}
  	/*
  	 * 2) If target doesn't exist, link the target
***************
*** 913,919 ****
  			dp->i_flag |= ICHG;
  			iupdat(dp, &time, &time, 1);
  		}
! 		error = direnter(ip);
  		if (error)
  			goto out;
  	} else {
--- 930,936 ----
  			dp->i_flag |= ICHG;
  			iupdat(dp, &time, &time, 1);
  		}
! 		error = direnter(ip, ndp);
  		if (error)
  			goto out;
  	} else {
***************
*** 958,964 ****
  			error = EISDIR;
  			goto bad;
  		}
! 		dirrewrite(dp, ip);
  		if (u.u_error) {
  			error = u.u_error;
  			goto bad1;
--- 975,981 ----
  			error = EISDIR;
  			goto bad;
  		}
! 		dirrewrite(dp, ip, ndp);
  		if (u.u_error) {
  			error = u.u_error;
  			goto bad1;
***************
*** 987,997 ****
  	/*
  	 * 3) Unlink the source.
  	 */
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->from;
! 	xp = namei(DELETE | LOCKPARENT);
  	if (xp != NULL)
! 		dp = u.u_pdir;
  	else
  		dp = NULL;
  	/*
--- 1004,1015 ----
  	/*
  	 * 3) Unlink the source.
  	 */
! 	ndp->ni_nameiop = DELETE | LOCKPARENT;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->from;
! 	xp = namei(ndp);
  	if (xp != NULL)
! 		dp = ndp->ni_pdir;
  	else
  		dp = NULL;
  	/*
***************
*** 1015,1030 ****
  		 * and ".." set to point to the new parent.
  		 */
  		if (doingdirectory && newparent) {
- 			off_t saved_offset;
-
- 			saved_offset = u.u_offset;
  			dp->i_nlink--;
  			dp->i_flag |= ICHG;
! 			u.u_base = (caddr_t)&dirbuf;
! 			u.u_count = sizeof(struct dirtemplate);
! 			u.u_offset = 0;
! 			u.u_segflg = UIO_SYSSPACE;
! 			readi(xp);
  			if (u.u_error == 0) {
  				if (dirbuf.dotdot_name[2] ||
  				    dirbuf.dotdot_name[0] != '.' ||
--- 1033,1044 ----
  		 * and ".." set to point to the new parent.
  		 */
  		if (doingdirectory && newparent) {
  			dp->i_nlink--;
  			dp->i_flag |= ICHG;
! 			u.u_error = rdwri(UIO_READ, xp, &dirbuf,
! 					sizeof(struct dirtemplate),
! 					(off_t)0, UIO_SYSSPACE, (int *)0);
!
  			if (u.u_error == 0) {
  				if (dirbuf.dotdot_name[2] ||
  				    dirbuf.dotdot_name[0] != '.' ||
***************
*** 1031,1047 ****
  				    dirbuf.dotdot_name[1] != '.') {
  					printf("rename: mangled dir\n");
  				} else {
- 					u.u_base = (caddr_t)&dirbuf;
- 					u.u_count = sizeof(struct dirtemplate);
- 					u.u_offset = 0;
  					dirbuf.dotdot_ino = newparent;
! 					(void) writei(xp);
  					cacheinval(dp);
  				}
  			}
- 			u.u_offset = saved_offset;
  		}
! 		if (!dirremove()) {
  			xp->i_nlink--;
  			xp->i_flag |= ICHG;
  		}
--- 1045,1059 ----
  				    dirbuf.dotdot_name[1] != '.') {
  					printf("rename: mangled dir\n");
  				} else {
  					dirbuf.dotdot_ino = newparent;
! 					rdwri(UIO_WRITE, xp, &dirbuf,
! 					       sizeof(struct dirtemplate),
! 					       (off_t)0, UIO_SYSSPACE,(int *)0);
  					cacheinval(dp);
  				}
  			}
  		}
! 		if (!dirremove(ndp)) {
  			xp->i_nlink--;
  			xp->i_flag |= ICHG;
  		}
***************
*** 1075,1085 ****
   * Make a new file.
   */
  struct inode *
! maknode(mode)
  	int mode;
  {
  	register struct inode *ip;
! 	register struct inode *pdir = u.u_pdir;

  	ip = ialloc(pdir);
  	if (ip == NULL) {
--- 1087,1098 ----
   * Make a new file.
   */
  struct inode *
! maknode(mode, ndp)
  	int mode;
+ register struct nameidata *ndp;
  {
  	register struct inode *ip;
! 	register struct inode *pdir = ndp->ni_pdir;

  	ip = ialloc(pdir);
  	if (ip == NULL) {
***************
*** 1109,1115 ****
  	 * Make sure inode goes to disk before directory entry.
  	 */
  	iupdat(ip, &time, &time, 1);
! 	u.u_error = direnter(ip);
  	if (u.u_error) {
  		/*
  		 * Write error occurred trying to update directory
--- 1122,1128 ----
  	 * Make sure inode goes to disk before directory entry.
  	 */
  	iupdat(ip, &time, &time, 1);
! 	u.u_error = direnter(ip, ndp);
  	if (u.u_error) {
  		/*
  		 * Write error occurred trying to update directory
***************
*** 1142,1151 ****
  	} *uap = (struct a *)u.u_ap;
  	register struct inode *ip, *dp;
  	struct dirtemplate dirtemplate;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->name;
! 	ip = namei(CREATE);
  	if (u.u_error)
  		return;
  	if (ip != NULL) {
--- 1155,1166 ----
  	} *uap = (struct a *)u.u_ap;
  	register struct inode *ip, *dp;
  	struct dirtemplate dirtemplate;
+ 	register struct nameidata *ndp = &u.u_nd;

! 	ndp->ni_nameiop = CREATE;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->name;
! 	ip = namei(ndp);
  	if (u.u_error)
  		return;
  	if (ip != NULL) {
***************
*** 1153,1159 ****
  		u.u_error = EEXIST;
  		return;
  	}
! 	dp = u.u_pdir;
  	uap->dmode &= 0777;
  	uap->dmode |= IFDIR;
  	/*
--- 1168,1174 ----
  		u.u_error = EEXIST;
  		return;
  	}
! 	dp = ndp->ni_pdir;
  	uap->dmode &= 0777;
  	uap->dmode |= IFDIR;
  	/*
***************
*** 1201,1217 ****
  	dirtemplate = mastertemplate;
  	dirtemplate.dot_ino = ip->i_number;
  	dirtemplate.dotdot_ino = dp->i_number;
! 	{
! 		off_t saved_offset;
!
! 		u.u_base = (caddr_t)&dirtemplate;
! 		u.u_count = sizeof(struct dirtemplate);
! 		u.u_segflg = UIO_SYSSPACE;
! 		saved_offset = u.u_offset;
! 		u.u_offset = 0;
! 		writei(ip);
! 		u.u_offset = saved_offset;
! 	}
  	if (u.u_error) {
  		dp->i_nlink--;
  		dp->i_flag |= ICHG;
--- 1216,1224 ----
  	dirtemplate = mastertemplate;
  	dirtemplate.dot_ino = ip->i_number;
  	dirtemplate.dotdot_ino = dp->i_number;
! 	u.u_error = rdwri(UIO_WRITE, ip, &dirtemplate,
! 			sizeof(struct dirtemplate), (off_t)0,
! 			UIO_SYSSPACE, (int *)0);
  	if (u.u_error) {
  		dp->i_nlink--;
  		dp->i_flag |= ICHG;
***************
*** 1222,1233 ****
  	 * install the entry for it in
  	 * the parent directory.
  	 */
! 	u.u_error = direnter(ip);
  	dp = NULL;
  	if (u.u_error) {
! 		u.u_segflg = UIO_USERSPACE;
! 		u.u_dirp = uap->name;
! 		dp = namei(LOOKUP | NOCACHE);
  		if (dp) {
  			dp->i_nlink--;
  			dp->i_flag |= ICHG;
--- 1229,1241 ----
  	 * install the entry for it in
  	 * the parent directory.
  	 */
! 	u.u_error = direnter(ip, ndp);
  	dp = NULL;
  	if (u.u_error) {
! 		ndp->ni_nameiop = LOOKUP | NOCACHE;
! 		ndp->ni_segflg = UIO_USERSPACE;
! 		ndp->ni_dirp = uap->name;
! 		dp = namei(ndp);
  		if (dp) {
  			dp->i_nlink--;
  			dp->i_flag |= ICHG;
***************
*** 1257,1269 ****
  		char	*name;
  	} *uap = (struct a *)u.u_ap;
  	register struct inode *ip, *dp;

! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_dirp = uap->name;
! 	ip = namei(DELETE | LOCKPARENT);
  	if (ip == NULL)
  		return;
! 	dp = u.u_pdir;
  	/*
  	 * No rmdir "." please.
  	 */
--- 1265,1279 ----
  		char	*name;
  	} *uap = (struct a *)u.u_ap;
  	register struct inode *ip, *dp;
+ 	register struct	nameidata *ndp = &u.u_nd;

! 	ndp->ni_nameiop = DELETE | LOCKPARENT;
! 	ndp->ni_segflg = UIO_USERSPACE;
! 	ndp->ni_dirp = uap->name;
! 	ip = namei(ndp);
  	if (ip == NULL)
  		return;
! 	dp = ndp->ni_pdir;
  	/*
  	 * No rmdir "." please.
  	 */
***************
*** 1300,1306 ****
  	 * inode.  If we crash in between, the directory
  	 * will be reattached to lost+found,
  	 */
! 	if (dirremove())
  		goto out;
  	dp->i_nlink--;
  	dp->i_flag |= ICHG;
--- 1310,1316 ----
  	 * inode.  If we crash in between, the directory
  	 * will be reattached to lost+found,
  	 */
! 	if (dirremove(ndp))
  		goto out;
  	dp->i_nlink--;
  	dp->i_flag |= ICHG;
diff -r -c /usr/src/oldsys/sys/uipc_socket.c /usr/src/sys/sys/uipc_socket.c
*** /usr/src/oldsys/sys/uipc_socket.c	Sat Apr 30 16:14:39 1988
--- /usr/src/sys/sys/uipc_socket.c	Sat Apr  7 20:14:18 1990
***************
*** 177,183 ****
  	so->so_state |= SS_NOFDREF;
  	sofree(so);
  	splx(s);
! 	return(u.u_error = error);
  }

  /*
--- 177,183 ----
  	so->so_state |= SS_NOFDREF;
  	sofree(so);
  	splx(s);
! 	return(error);
  }

  /*
***************
*** 300,308 ****
   * inform user that this would block and do nothing.
   * Otherwise, if nonblocking, send as much as possible.
   */
! sosend(so, nam, flags, rights)
  	register struct socket *so;
  	struct mbuf *nam;
  	int flags;
  	struct mbuf *rights;
  {
--- 300,309 ----
   * inform user that this would block and do nothing.
   * Otherwise, if nonblocking, send as much as possible.
   */
! sosend(so, nam, uio, flags, rights)
  	register struct socket *so;
  	struct mbuf *nam;
+ 	register struct uio *uio;
  	int flags;
  	struct mbuf *rights;
  {
***************
*** 311,317 ****
  	register int space;
  	int len, rlen = 0, error = 0, s, dontroute, first = 1;

! 	if (sosendallatonce(so) && u.u_count > so->so_snd.sb_hiwat)
  		return (EMSGSIZE);
  	dontroute =
  	    (flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 &&
--- 312,318 ----
  	register int space;
  	int len, rlen = 0, error = 0, s, dontroute, first = 1;

! 	if (sosendallatonce(so) && uio->uio_resid > so->so_snd.sb_hiwat)
  		return (EMSGSIZE);
  	dontroute =
  	    (flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 &&
***************
*** 345,352 ****
  			space = sbspace(&so->so_snd);
  			if (space <= rlen ||
  			   (sosendallatonce(so) &&
! 				space < u.u_count + rlen) ||
! 			   (u.u_count >= CLBYTES && space < CLBYTES &&
  			   so->so_snd.sb_cc >= CLBYTES &&
  			   (so->so_state & SS_NBIO) == 0)) {
  				if (so->so_state & SS_NBIO) {
--- 346,353 ----
  			space = sbspace(&so->so_snd);
  			if (space <= rlen ||
  			   (sosendallatonce(so) &&
! 				space < uio->uio_resid + rlen) ||
! 			   (uio->uio_resid >= CLBYTES && space < CLBYTES &&
  			   so->so_snd.sb_cc >= CLBYTES &&
  			   (so->so_state & SS_NBIO) == 0)) {
  				if (so->so_state & SS_NBIO) {
***************
*** 366,389 ****
  		space -= rlen;
  		while (space > 0) {
  			MGET(m, M_WAIT, MT_DATA);
! 			if (u.u_count >= CLBYTES / 2 && space >= CLBYTES) {
  				MCLGET(m);
  				if (m->m_len != CLBYTES)
  					goto nopages;
! 				len = MIN(CLBYTES, u.u_count);
  				space -= CLBYTES;
  			} else {
  nopages:
! 				len = MIN(MIN(MLEN, u.u_count), space);
  				space -= len;
  			}
! 			error = uiomove(mtod(m, caddr_t), len, UIO_WRITE);
  			m->m_len = len;
  			*mp = m;
  			if (error)
  				goto release;
  			mp = &m->m_next;
! 			if (u.u_count <= 0)
  				break;
  		}
  		if (dontroute)
--- 367,390 ----
  		space -= rlen;
  		while (space > 0) {
  			MGET(m, M_WAIT, MT_DATA);
! 			if (uio->uio_resid >= CLBYTES / 2 && space >= CLBYTES) {
  				MCLGET(m);
  				if (m->m_len != CLBYTES)
  					goto nopages;
! 				len = MIN(CLBYTES, uio->uio_resid);
  				space -= CLBYTES;
  			} else {
  nopages:
! 				len = MIN(MIN(MLEN, uio->uio_resid), space);
  				space -= len;
  			}
! 			error = uiomove(mtod(m, caddr_t), len, UIO_WRITE, uio);
  			m->m_len = len;
  			*mp = m;
  			if (error)
  				goto release;
  			mp = &m->m_next;
! 			if (uio->uio_resid == 0)
  				break;
  		}
  		if (dontroute)
***************
*** 401,407 ****
  		first = 0;
  		if (error)
  			break;
! 	} while (u.u_count);

  release:
  	sbunlock(&so->so_snd);
--- 402,408 ----
  		first = 0;
  		if (error)
  			break;
! 	} while (uio->uio_resid);

  release:
  	sbunlock(&so->so_snd);
***************
*** 424,432 ****
   * Although the sockbuf is locked, new data may still be appended,
   * and thus we must maintain consistency of the sockbuf during that time.
   */
! soreceive(so, aname, flags, rightsp)
  	register struct socket *so;
  	struct mbuf **aname;
  	int flags;
  	struct mbuf **rightsp;
  {
--- 425,434 ----
   * Although the sockbuf is locked, new data may still be appended,
   * and thus we must maintain consistency of the sockbuf during that time.
   */
! soreceive(so, aname, uio, flags, rightsp)
  	register struct socket *so;
  	struct mbuf **aname;
+ 	register struct uio *uio;
  	int flags;
  	struct mbuf **rightsp;
  {
***************
*** 447,459 ****
  		if (error)
  			goto bad;
  		do {
! 			len = u.u_count;
  			if (len > m->m_len)
  				len = m->m_len;
  			error =
! 			    uiomove(mtod(m, caddr_t), (int)len, UIO_READ);
  			m = m_free(m);
! 		} while (u.u_count && error == 0 && m);
  bad:
  		if (m)
  			m_freem(m);
--- 449,461 ----
  		if (error)
  			goto bad;
  		do {
! 			len = uio->uio_resid;
  			if (len > m->m_len)
  				len = m->m_len;
  			error =
! 			    uiomove(mtod(m, caddr_t), (int)len, UIO_READ, uio);
  			m = m_free(m);
! 		} while (uio->uio_resid && error == 0 && m);
  bad:
  		if (m)
  			m_freem(m);
***************
*** 477,483 ****
  			error = ENOTCONN;
  			goto release;
  		}
! 		if (u.u_count == 0)
  			goto release;
  		if (so->so_state & SS_NBIO) {
  			error = EWOULDBLOCK;
--- 479,485 ----
  			error = ENOTCONN;
  			goto release;
  		}
! 		if (uio->uio_resid == 0)
  			goto release;
  		if (so->so_state & SS_NBIO) {
  			error = EWOULDBLOCK;
***************
*** 539,548 ****
  	}
  	moff = 0;
  	offset = 0;
! 	while (m && u.u_count > 0 && error == 0) {
  		if (m->m_type != MT_DATA && m->m_type != MT_HEADER)
  			panic("receive 3");
! 		len = u.u_count;
  		so->so_state &= ~SS_RCVATMARK;
  		if (so->so_oobmark && len > so->so_oobmark - offset)
  			len = so->so_oobmark - offset;
--- 541,550 ----
  	}
  	moff = 0;
  	offset = 0;
! 	while (m && uio->uio_resid && error == 0) {
  		if (m->m_type != MT_DATA && m->m_type != MT_HEADER)
  			panic("receive 3");
! 		len = uio->uio_resid;
  		so->so_state &= ~SS_RCVATMARK;
  		if (so->so_oobmark && len > so->so_oobmark - offset)
  			len = so->so_oobmark - offset;
***************
*** 550,556 ****
  			len = m->m_len - moff;
  		splx(s);
  		error =
! 		    uiomove(mtod(m, caddr_t) + moff, (int)len, UIO_READ);
  		s = splnet();
  		if (len == m->m_len - moff) {
  			if (flags & MSG_PEEK) {
--- 552,558 ----
  			len = m->m_len - moff;
  		splx(s);
  		error =
! 		    uiomove(mtod(m, caddr_t) + moff, (int)len, UIO_READ, uio);
  		s = splnet();
  		if (len == m->m_len - moff) {
  			if (flags & MSG_PEEK) {
***************
*** 813,819 ****
  sohasoutofband(so)
  	register struct socket *so;
  {
! 	struct proc *p;

  	if (so->so_pgrp < 0)
  		GSIGNAL(-so->so_pgrp, SIGURG);
--- 815,821 ----
  sohasoutofband(so)
  	register struct socket *so;
  {
! register struct proc *p;

  	if (so->so_pgrp < 0)
  		GSIGNAL(-so->so_pgrp, SIGURG);
***************
*** 836,842 ****
  */

  soacc1(so)
! 	struct	socket	*so;
  	{

  	if	((so->so_options & SO_ACCEPTCONN) == 0)
--- 838,844 ----
  */

  soacc1(so)
! register struct	socket	*so;
  	{

  	if	((so->so_options & SO_ACCEPTCONN) == 0)
***************
*** 871,877 ****
  	struct	socket	*so;
  	int	n;
  	{
! 	struct	socket	*aso;

  	aso = so->so_q;
  	if	(soqremque(aso, n) == 0)
--- 873,879 ----
  	struct	socket	*so;
  	int	n;
  	{
! register struct	socket	*aso;

  	aso = so->so_q;
  	if	(soqremque(aso, n) == 0)
***************
*** 885,891 ****
  */

  connwhile(so)
! 	struct	socket	*so;
  	{

  	while	((so->so_state & SS_ISCONNECTING) && so->so_error == 0)
--- 887,893 ----
  */

  connwhile(so)
! register struct	socket	*so;
  	{

  	while	((so->so_state & SS_ISCONNECTING) && so->so_error == 0)
diff -r -c /usr/src/oldsys/sys/uipc_sys.c /usr/src/sys/sys/uipc_sys.c
*** /usr/src/oldsys/sys/uipc_sys.c	Wed Jul 26 16:23:06 1989
--- /usr/src/sys/sys/uipc_sys.c	Sat Apr  7 21:21:28 1990
***************
*** 303,313 ****
  		int	tolen;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;

  	msg.msg_name = uap->to;
  	msg.msg_namelen = uap->tolen;
! 	u.u_base = uap->buf;
! 	u.u_count = uap->len;
  	msg.msg_accrights = 0;
  	msg.msg_accrightslen = 0;
  	sendit(uap->s, &msg, uap->flags);
--- 303,316 ----
  		int	tolen;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;
+ 	struct iovec aiov;

  	msg.msg_name = uap->to;
  	msg.msg_namelen = uap->tolen;
! 	msg.msg_iov = &aiov;
! 	msg.msg_iovlen = 1;
! 	aiov.iov_base = uap->buf;
! 	aiov.iov_len = uap->len;
  	msg.msg_accrights = 0;
  	msg.msg_accrightslen = 0;
  	sendit(uap->s, &msg, uap->flags);
***************
*** 322,332 ****
  		int	flags;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;

  	msg.msg_name = 0;
  	msg.msg_namelen = 0;
! 	u.u_base = uap->buf;
! 	u.u_count = uap->len;
  	msg.msg_accrights = 0;
  	msg.msg_accrightslen = 0;
  	sendit(uap->s, &msg, uap->flags);
--- 325,338 ----
  		int	flags;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;
+ 	struct iovec aiov;

  	msg.msg_name = 0;
  	msg.msg_namelen = 0;
! 	msg.msg_iov = &aiov;
! 	msg.msg_iovlen = 1;
! 	aiov.iov_base = uap->buf;
! 	aiov.iov_len = uap->len;
  	msg.msg_accrights = 0;
  	msg.msg_accrightslen = 0;
  	sendit(uap->s, &msg, uap->flags);
***************
*** 340,361 ****
  		int	flags;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;
! 	struct iovec aiov;

  	u.u_error = copyin(uap->msg, (caddr_t)&msg, sizeof (msg));
  	if (u.u_error)
  		return;
! 	if ((u_int)msg.msg_iovlen > 1) {
  		u.u_error = EMSGSIZE;
  		return;
  	}
  	u.u_error =
! 	    copyin((caddr_t)msg.msg_iov, (caddr_t)&aiov,
! 		sizeof(aiov));
  	if (u.u_error)
  		return;
! 	u.u_base = aiov.iov_base;
! 	u.u_count = aiov.iov_len;
  	sendit(uap->s, &msg, uap->flags);
  }

--- 346,366 ----
  		int	flags;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;
! 	struct iovec aiov[MSG_MAXIOVLEN];

  	u.u_error = copyin(uap->msg, (caddr_t)&msg, sizeof (msg));
  	if (u.u_error)
  		return;
! 	if ((u_int)msg.msg_iovlen >= sizeof (aiov) / sizeof (aiov[0])) {
  		u.u_error = EMSGSIZE;
  		return;
  	}
  	u.u_error =
! 	    copyin((caddr_t)msg.msg_iov, (caddr_t)aiov,
! 		(unsigned)(msg.msg_iovlen * sizeof (aiov[0])));
  	if (u.u_error)
  		return;
! 	msg.msg_iov = aiov;
  	sendit(uap->s, &msg, uap->flags);
  }

***************
*** 365,370 ****
--- 370,376 ----
  	int flags;
  {
  	register struct file *fp;
+ 	struct uio auio;
  	register struct iovec *iov;
  	register int i;
  	struct mbuf *to, *rights;
***************
*** 376,383 ****
  	fp = gtsockf(s);
  	if (fp == 0)
  		return;
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_offset = 0;				/* XXX */
  	if (mp->msg_name) {
  		to = (struct mbuf *)sabuf;
  		MBZAP(to, mp->msg_namelen, MT_SONAME);
--- 382,410 ----
  	fp = gtsockf(s);
  	if (fp == 0)
  		return;
! 	auio.uio_iov = mp->msg_iov;
! 	auio.uio_iovcnt = mp->msg_iovlen;
! 	auio.uio_segflg = UIO_USERSPACE;
! 	auio.uio_offset = 0;				/* XXX */
! 	auio.uio_resid = 0;
! 	iov = mp->msg_iov;
! 	for (i = 0; i < mp->msg_iovlen; i++, iov++) {
! #ifndef	BSD2_10
! 		if (iov->iov_len < 0) {
! 			u.u_error = EINVAL;
! 			return;
! 		}
! #endif
! 		if (iov->iov_len == 0)
! 			continue;
! #ifndef	BSD2_10
! 		if (useracc(iov->iov_base, (u_int)iov->iov_len, B_READ) == 0) {
! 			u.u_error = EFAULT;
! 			return;
! 		}
! #endif
! 		auio.uio_resid += iov->iov_len;
! 	}
  	if (mp->msg_name) {
  		to = (struct mbuf *)sabuf;
  		MBZAP(to, mp->msg_namelen, MT_SONAME);
***************
*** 398,406 ****
  			return;
  	} else
  		rights = 0;
! 	len = u.u_count;
! 	u.u_error = SOSEND(fp->f_socket, to, flags, rights);
! 	u.u_r.r_val1 = len - u.u_count;
  }

  recvfrom()
--- 425,433 ----
  			return;
  	} else
  		rights = 0;
! 	len = auio.uio_resid;
! 	u.u_error = SOSEND(fp->f_socket, to, &auio, flags, rights);
! 	u.u_r.r_val1 = len - auio.uio_resid;
  }

  recvfrom()
***************
*** 414,419 ****
--- 441,447 ----
  		int	*fromlenaddr;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;
+ 	struct iovec aiov;
  	int len;

  	u.u_error = copyin((caddr_t)uap->fromlenaddr, (caddr_t)&len,
***************
*** 422,429 ****
  		return;
  	msg.msg_name = uap->from;
  	msg.msg_namelen = len;
! 	u.u_base = uap->buf;
! 	u.u_count = uap->len;
  	msg.msg_accrights = 0;
  	msg.msg_accrightslen = 0;
  	recvit(uap->s, &msg, uap->flags, (caddr_t)uap->fromlenaddr, (caddr_t)0);
--- 450,459 ----
  		return;
  	msg.msg_name = uap->from;
  	msg.msg_namelen = len;
! 	msg.msg_iov = &aiov;
! 	msg.msg_iovlen = 1;
! 	aiov.iov_base = uap->buf;
! 	aiov.iov_len = uap->len;
  	msg.msg_accrights = 0;
  	msg.msg_accrightslen = 0;
  	recvit(uap->s, &msg, uap->flags, (caddr_t)uap->fromlenaddr, (caddr_t)0);
***************
*** 438,448 ****
  		int	flags;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;

  	msg.msg_name = 0;
  	msg.msg_namelen = 0;
! 	u.u_base = uap->buf;
! 	u.u_count = uap->len;
  	msg.msg_accrights = 0;
  	msg.msg_accrightslen = 0;
  	recvit(uap->s, &msg, uap->flags, (caddr_t)0, (caddr_t)0);
--- 468,481 ----
  		int	flags;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;
+ 	struct iovec aiov;

  	msg.msg_name = 0;
  	msg.msg_namelen = 0;
! 	msg.msg_iov = &aiov;
! 	msg.msg_iovlen = 1;
! 	aiov.iov_base = uap->buf;
! 	aiov.iov_len = uap->len;
  	msg.msg_accrights = 0;
  	msg.msg_accrightslen = 0;
  	recvit(uap->s, &msg, uap->flags, (caddr_t)0, (caddr_t)0);
***************
*** 456,473 ****
  		int	flags;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;
! 	struct iovec aiov;

  	u.u_error = copyin((caddr_t)uap->msg, (caddr_t)&msg, sizeof (msg));
  	if (u.u_error)
  		return;
! 	if ((u_int)msg.msg_iovlen > 1) {
  		u.u_error = EMSGSIZE;
  		return;
  	}
  	u.u_error =
! 	    copyin((caddr_t)msg.msg_iov, (caddr_t)&aiov,
! 		sizeof(aiov));
  	if (u.u_error)
  		return;
  	recvit(uap->s, &msg, uap->flags,
--- 489,506 ----
  		int	flags;
  	} *uap = (struct a *)u.u_ap;
  	struct msghdr msg;
! 	struct iovec aiov[MSG_MAXIOVLEN];

  	u.u_error = copyin((caddr_t)uap->msg, (caddr_t)&msg, sizeof (msg));
  	if (u.u_error)
  		return;
! 	if ((u_int)msg.msg_iovlen >= sizeof (aiov) / sizeof (aiov[0])) {
  		u.u_error = EMSGSIZE;
  		return;
  	}
  	u.u_error =
! 	    copyin((caddr_t)msg.msg_iov, (caddr_t)aiov,
! 		(unsigned)(msg.msg_iovlen * sizeof(aiov[0])));
  	if (u.u_error)
  		return;
  	recvit(uap->s, &msg, uap->flags,
***************
*** 482,487 ****
--- 515,521 ----
  	caddr_t namelenp, rightslenp;
  {
  	register struct file *fp;
+ 	struct uio auio;
  	register struct iovec *iov;
  	register int i;
  	struct mbuf *from, *rights;
***************
*** 492,502 ****
  	fp = gtsockf(s);
  	if (fp == 0)
  		return;
! 	u.u_segflg = UIO_USERSPACE;
! 	u.u_offset = 0;				/* XXX */
! 	len = u.u_count;
! 	u.u_error = SORECEIVE(fp->f_socket, &from, flags, &rights);
! 	u.u_r.r_val1 = len - u.u_count;
  	if (mp->msg_name) {
  		len = mp->msg_namelen;
  		if (len <= 0 || from == 0)
--- 526,558 ----
  	fp = gtsockf(s);
  	if (fp == 0)
  		return;
! 	auio.uio_iov = mp->msg_iov;
! 	auio.uio_iovcnt = mp->msg_iovlen;
! 	auio.uio_segflg = UIO_USERSPACE;
! 	auio.uio_offset = 0;				/* XXX */
! 	auio.uio_resid = 0;
! 	iov = mp->msg_iov;
! 	for (i = 0; i < mp->msg_iovlen; i++, iov++) {
! #ifndef	BSD2_10
! 		if (iov->iov_len < 0) {
! 			u.u_error = EINVAL;
! 			return;
! 		}
! #endif
! 		if (iov->iov_len == 0)
! 			continue;
! #ifndef	BSD2_10
! 		if (useracc(iov->iov_base, (u_int)iov->iov_len, B_WRITE) == 0) {
! 			u.u_error = EFAULT;
! 			return;
! 		}
! #endif
! 		auio.uio_resid += iov->iov_len;
! 	}
! 	len = auio.uio_resid;
! 	u.u_error =
! 	    SORECEIVE((struct socket *)fp->f_data, &from, &auio,flags, &rights);
! 	u.u_r.r_val1 = len - auio.uio_resid;
  	if (mp->msg_name) {
  		len = mp->msg_namelen;
  		if (len <= 0 || from == 0)
diff -r -c /usr/src/oldsys/sys/uipc_usrreq.c /usr/src/sys/sys/uipc_usrreq.c
*** /usr/src/oldsys/sys/uipc_usrreq.c	Sat Apr 30 16:14:42 1988
--- /usr/src/sys/sys/uipc_usrreq.c	Sun Apr  8 03:26:52 1990
***************
*** 354,363 ****
  	unp->unp_inode = ip;
  	unp->unp_addr = m_copy(nam, 0, M_COPYALL);
  #else
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_dirp = soun->sun_path;
! 	u.u_dirp[nam->m_len-2] = 0;
! 	ip = namei(CREATE | FOLLOW);
  	if (ip) {
  		iput(ip);
  		return (EADDRINUSE);
--- 354,364 ----
  	unp->unp_inode = ip;
  	unp->unp_addr = m_copy(nam, 0, M_COPYALL);
  #else
! 	ndp->ni_nameiop = CREATE | FOLLOW;
! 	ndp->ni_segflg = UIO_SYSSPACE;
! 	ndp->ni_dirp = soun->sun_path;
! 	ndp->ni_dirp[nam->m_len-2] = 0;
! 	ip = namei(ndp);
  	if (ip) {
  		iput(ip);
  		return (EADDRINUSE);
***************
*** 366,372 ****
  		u.u_error = 0;			/* XXX */
  		return (error);
  	}
! 	ip = maknode(IFSOCK | 0777);
  	if (ip == NULL) {
  		error = u.u_error;		/* XXX */
  		u.u_error = 0;			/* XXX */
--- 367,373 ----
  		u.u_error = 0;			/* XXX */
  		return (error);
  	}
! 	ip = maknode(IFSOCK | 0777, ndp);
  	if (ip == NULL) {
  		error = u.u_error;		/* XXX */
  		u.u_error = 0;			/* XXX */
***************
*** 411,420 ****
  	if (ip)
  		IPUT(ip);
  #else
! 	u.u_segflg = UIO_SYSSPACE;
! 	u.u_dirp = soun->sun_path;
! 	u.u_dirp[nam->m_len-2] = 0;
! 	ip = namei(LOOKUP | FOLLOW);
  	if (ip == 0) {
  		error = u.u_error;
  		u.u_error = 0;
--- 412,422 ----
  	if (ip)
  		IPUT(ip);
  #else
! 	ndp->ni_nameiop = LOOKUP | FOLLOW;
! 	ndp->ni_segflg = UIO_SYSSPACE;
! 	ndp->ni_dirp = soun->sun_path;
! 	ndp->ni_dirp[nam->m_len-2] = 0;
! 	ip = namei(ndp);
  	if (ip == 0) {
  		error = u.u_error;
  		u.u_error = 0;
diff -r -c /usr/src/oldsys/sys/vm_swp.c /usr/src/sys/sys/vm_swp.c
*** /usr/src/oldsys/sys/vm_swp.c	Thu Sep  3 11:49:30 1987
--- /usr/src/sys/sys/vm_swp.c	Wed Apr 11 09:49:09 1990
***************
*** 16,21 ****
--- 16,22 ----
  #include "systm.h"
  #include "vm.h"
  #include "trace.h"
+ #include "uio.h"

  /*
   * swap IO headers.  They are filled in to point
***************
*** 66,76 ****
  		bp->b_un.b_addr = (caddr_t)(coreaddr<<6);
  		bp->b_xmem = (coreaddr>>10) & 077;
  		trace(TR_SWAPIO);
! 		(*bdevsw[major(swapdev)].d_strategy)(bp);
! 		s = splbio();
! 		while((bp->b_flags&B_DONE)==0)
! 			sleep((caddr_t)bp, PSWP);
! 		splx(s);
  		if ((bp->b_flags & B_ERROR) || bp->b_resid)
  			panic("hard IO err in swap");
  		count -= tcount;
--- 67,73 ----
  		bp->b_un.b_addr = (caddr_t)(coreaddr<<6);
  		bp->b_xmem = (coreaddr>>10) & 077;
  		trace(TR_SWAPIO);
! 		physstrat(bp, bdevsw[major(swapdev)].d_strategy, PSWP);
  		if ((bp->b_flags & B_ERROR) || bp->b_resid)
  			panic("hard IO err in swap");
  		count -= tcount;
***************
*** 130,161 ****
   *	to the argument list, adjusted all calls to physio/bphysio
   *	to pass the correct argument themselves.
   *		5/86 kb
   */
! physio(strat, bp, dev, rw, kind)
  	int (*strat)();
  	register struct buf *bp;
  	dev_t dev;
  	int rw, kind;
  {
! 	register int error, s;

! 	error = chkphys(kind);
! 	if (error)
! 		return(error);
! 	physbuf(bp, dev, rw);
  	u.u_procp->p_flag |= SLOCK;
! 	(*strat)(bp);
  	s = splbio();
! 	while ((bp->b_flags&B_DONE)==0)
! 		sleep((caddr_t)bp, PRIBIO);
  	splx(s);
! 	error = geterror(bp);
! 	u.u_procp->p_flag &= ~SLOCK;
! 	if (bp->b_flags&B_WANTED)
  		wakeup((caddr_t)bp);
! 	bp->b_flags &= ~(B_BUSY|B_WANTED);
! 	u.u_count = bp->b_resid;
! 	return(error);
  }

  /*
--- 127,198 ----
   *	to the argument list, adjusted all calls to physio/bphysio
   *	to pass the correct argument themselves.
   *		5/86 kb
+  *
+  * rewritten to use the iov/uio mechanism from 4.3bsd.  the physbuf routine
+  * was inlined.  essentially the chkphys routine performs the same task
+  * as the useracc routine on a 4.3 system. 3/90 sms
   */
! physio(strat, bp, dev, rw, kind, uio)
  	int (*strat)();
  	register struct buf *bp;
  	dev_t dev;
  	int rw, kind;
+ 	register struct uio *uio;
  {
! 	int error, s, nb, ts, c;
! 	register struct iovec *iov;

! nextiov:
  	u.u_procp->p_flag |= SLOCK;
! 	if (uio->uio_iovcnt == 0) {
! 		u.u_procp->p_flag &= ~SLOCK;
! 		return (0);
! 	}
! 	iov = uio->uio_iov;
! 	error = chkphys(kind, iov);
! 	if (error) {
! 		u.u_procp->p_flag &= ~SLOCK;
! 		return(error);
! 	}
  	s = splbio();
! 	while (bp->b_flags & B_BUSY) {
! 		bp->b_flags |= B_WANTED;
! 		sleep((caddr_t)bp, PRIBIO+1);
! 	}
  	splx(s);
! 	while (iov->iov_len) {
! 		bp->b_flags = B_BUSY|B_PHYS|rw;
! 		bp->b_dev = dev;
! 		nb = ((int)iov->iov_base >> 6) & 01777;
! 		ts = (u.u_sep ? UDSA : UISA)[nb >> 7] + (nb & 0177);
! 		bp->b_un.b_addr = (caddr_t)((ts << 6) + ((int)iov->iov_base & 077));
! 		bp->b_xmem = (ts >> 10) & 077;
! 		bp->b_blkno = uio->uio_offset >> PGSHIFT;
! 		bp->b_bcount = iov->iov_len;
! 		c = bp->b_bcount;
! 		bp->b_error = 0;
! 		physstrat(bp, strat, PRIBIO);
! 		c -= bp->b_resid;
! 		iov->iov_base += c;
! 		iov->iov_len -= c;
! 		uio->uio_resid -= c;
! 		uio->uio_offset += c;
! 		/* temp kludge for tape drives */
! 		if (bp->b_resid || (bp->b_flags & B_ERROR))
! 			break;
! 	}
! 	if (bp->b_flags & B_WANTED)
  		wakeup((caddr_t)bp);
! 	bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS);
! 	error = geterror(bp);
! 	/* temp kludge for tape drives */
! 	if (bp->b_resid || error) {
! 		u.u_procp->p_flag &= ~SLOCK;
! 		return (error);
! 	}
! 	uio->uio_iov++;
! 	uio->uio_iovcnt--;
! 	goto nextiov;
  }

  /*
***************
*** 162,188 ****
   * check for validity of physical I/O area
   * (modified from physio to use flag for BYTE-oriented transfers)
   */
! chkphys(flag)
  	int flag;
  {
- 	register u_int base;
  	register int nb, ts;

- 	base = (u_int)u.u_base;
  	/*
  	 * Check odd base, odd count, and address wraparound
  	 * Odd base and count not allowed if flag = WORD,
  	 * allowed if flag = BYTE.
  	 */
! 	if (flag == WORD && ((base|u.u_count) & 01))
  		return(EFAULT);
! 	if (base >= base + u.u_count)
  		return(EFAULT);
  	if (u.u_sep)
  		ts = 0;
  	else
  		ts = (u.u_tsize + 127) & ~0177;
! 	nb = (base >> 6) & 01777;
  	/*
  	 * Check overlap with text. (ts and nb now
  	 * in 64-byte clicks)
--- 199,224 ----
   * check for validity of physical I/O area
   * (modified from physio to use flag for BYTE-oriented transfers)
   */
! chkphys(flag, iov)
  	int flag;
+ 	register struct iovec *iov;
  {
  	register int nb, ts;

  	/*
  	 * Check odd base, odd count, and address wraparound
  	 * Odd base and count not allowed if flag = WORD,
  	 * allowed if flag = BYTE.
  	 */
! 	if (flag == WORD && (((int)iov->iov_base|iov->iov_len) & 01))
  		return(EFAULT);
! 	if (iov->iov_base >= iov->iov_base + iov->iov_len)
  		return(EFAULT);
  	if (u.u_sep)
  		ts = 0;
  	else
  		ts = (u.u_tsize + 127) & ~0177;
! 	nb = ((int)iov->iov_base >> 6) & 01777;
  	/*
  	 * Check overlap with text. (ts and nb now
  	 * in 64-byte clicks)
***************
*** 195,242 ****
  	 * the end is in the data or the start is in the stack
  	 * (remember wraparound was already checked).
  	 */
! 	if ((((base + u.u_count) >> 6) & 01777) >= ts + u.u_dsize &&
  	    nb < 1024 - u.u_ssize)
  		return(EFAULT);
  	return(0);
- }
-
- /*
-  * wait for buffer header, then fill it in to do physical I/O.
-  */
- physbuf(bp,dev,rw)
- 	register struct buf *bp;
- 	dev_t dev;
- 	int rw;
- {
- 	{
- 		register int s;
-
- 		s = splbio();
- 		while (bp->b_flags&B_BUSY) {
- 			bp->b_flags |= B_WANTED;
- 			sleep((caddr_t)bp, PRIBIO+1);
- 		}
- 		splx(s);
- 	}
- 	bp->b_flags = B_BUSY | B_PHYS | rw;
- 	bp->b_dev = dev;
- 	/*
- 	 * Compute physical address by simulating
- 	 * the segmentation hardware.
- 	 */
- 	{
- 		register u_int base;
- 		register int ts;
- 		int nb;
-
- 		base = (u_int)u.u_base;
- 		nb = (base >> 6) & 01777;
- 		ts = (u.u_sep ? UDSA: UISA)[nb >> 7] + (nb & 0177);
- 		bp->b_un.b_addr = (caddr_t)((ts << 6) + (base & 077));
- 		bp->b_xmem = (ts >> 10) & 077;
- 		bp->b_blkno = u.u_offset >> PGSHIFT;
- 		bp->b_bcount = u.u_count;
- 		bp->b_error = 0;
- 	}
  }
--- 231,238 ----
  	 * the end is in the data or the start is in the stack
  	 * (remember wraparound was already checked).
  	 */
! 	if (((((int)iov->iov_base + iov->iov_len) >> 6) & 01777) >= ts + u.u_dsize &&
  	    nb < 1024 - u.u_ssize)
  		return(EFAULT);
  	return(0);
  }
diff -r -c /usr/src/oldsys/sys/vm_text.c /usr/src/sys/sys/vm_text.c
*** /usr/src/oldsys/sys/vm_text.c	Mon May 29 13:44:40 1989
--- /usr/src/sys/sys/vm_text.c	Sat Apr  7 20:00:00 1990
***************
*** 141,146 ****
--- 141,148 ----
  	register struct inode *ip;
  {
  	register struct text *xp;
+ 	register u_int	count;
+ 	off_t	offset;
  	size_t ts;

  	if (ep->a_text == 0)
***************
*** 212,242 ****
  	u.u_procp->p_textp = xp;
  	xexpand(xp);
  	estabur(ts, (u_int)0, (u_int)0, 0, RW);
! 	u.u_count = ep->a_text & ~1;	/* no odd transfers in uiomove() */
! 	u.u_offset = sizeof(struct exec);
  	if (u.u_ovdata.uo_ovbase)
! 		u.u_offset += (NOVL + 1) * sizeof(u_int);
! 	u.u_base = 0;
! 	u.u_segflg = UIO_USERISPACE;
  	u.u_procp->p_flag |= SLOCK;
! 	readi(ip);

  	if (u.u_ovdata.uo_ovbase) {	/* read in overlays if necessary */
  		register int i;

  		for (i = 1; i <= NOVL; i++) {
  			u.u_ovdata.uo_curov = i;
! 			u.u_count = ctob(u.u_ovdata.uo_ov_offst[i] - u.u_ovdata.uo_ov_offst[i-1]);
! 			u.u_base = (caddr_t)(ctob(stoc(u.u_ovdata.uo_ovbase)));
! 			if (u.u_count) {
  				choverlay(RW);
! 				readi(ip);
  			}
  		}
  	}
  	u.u_ovdata.uo_curov = 0;
  	u.u_procp->p_flag &= ~SLOCK;
- 	u.u_segflg = UIO_USERSPACE;
  	xp->x_flag |= XWRIT;
  	xp->x_flag &= ~XLOAD;
  }
--- 214,244 ----
  	u.u_procp->p_textp = xp;
  	xexpand(xp);
  	estabur(ts, (u_int)0, (u_int)0, 0, RW);
! 	offset = sizeof(struct exec);
  	if (u.u_ovdata.uo_ovbase)
! 		offset += (NOVL + 1) * sizeof(u_int);
  	u.u_procp->p_flag |= SLOCK;
! 	u.u_error = rdwri(UIO_READ, ip, (caddr_t)0, ep->a_text & ~1,
! 			offset, UIO_USERISPACE, (int *)0);

  	if (u.u_ovdata.uo_ovbase) {	/* read in overlays if necessary */
  		register int i;

+ 		offset += (off_t)(ep->a_text & ~1);
  		for (i = 1; i <= NOVL; i++) {
  			u.u_ovdata.uo_curov = i;
! 			count = ctob(u.u_ovdata.uo_ov_offst[i] - u.u_ovdata.uo_ov_offst[i-1]);
! 			if (count) {
  				choverlay(RW);
! 				u.u_error = rdwri(UIO_READ, ip,
! 				    (caddr_t)(ctob(stoc(u.u_ovdata.uo_ovbase))),
! 					count, offset, UIO_USERISPACE,(int *)0);
! 				offset += (off_t) count;
  			}
  		}
  	}
  	u.u_ovdata.uo_curov = 0;
  	u.u_procp->p_flag &= ~SLOCK;
  	xp->x_flag |= XWRIT;
  	xp->x_flag &= ~XLOAD;
  }
*** /usr/src/man/man2/read.2.old	Thu Aug 20 12:32:37 1987
--- /usr/src/man/man2/read.2	Sun Apr  8 00:10:16 1990
***************
*** 14,20 ****
  cc = read(d, buf, nbytes)
  int cc, d;
  char *buf;
! int nbytes;
  .PP
  .ft B
  #include <sys/types.h>
--- 14,20 ----
  cc = read(d, buf, nbytes)
  int cc, d;
  char *buf;
! unsigned short nbytes;
  .PP
  .ft B
  #include <sys/types.h>
***************
*** 53,59 ****
  .DT
  struct iovec {
  	caddr_t	iov_base;
! 	int	iov_len;
  };
  .RE
  .fi
--- 53,59 ----
  .DT
  struct iovec {
  	caddr_t	iov_base;
! 	u_short	iov_len;
  };
  .RE
  .fi
***************
*** 135,174 ****
  was less than or equal to 0, or greater than 16.
  .TP 15
  [EINVAL]
- One of the
- .I iov_len
- values in the
- .I iov
- array was negative.
- .TP 15
- [EINVAL]
  The sum of the
  .I iov_len
  values in the
  .I iov
! array overflowed an integer.
  .TP 15
  [EFAULT]
  Part of the \fIiov\fP points outside the process's allocated address space.
  .SH "SEE ALSO"
  dup(2), fcntl(2), open(2), pipe(2), select(2), socket(2), socketpair(2)
- .SH BUGS
- Under
- .I 2.10BSD
- .I readv
- is implemented as a compatibility routine in the standard library and is
- semantically identical to the 4.3BSD
- .I readv
- on all current descriptors, with the exception of sockets (SOCK_STREAM
- does work identically however).  The compatibility routine implements
- .I readv
- non-atomically as multiple
- .I read
- calls.
- .PP
- Under
- .I 2.10BSD
- .I nbytes
- is actually an
- .B unsigned
- value.
--- 135,147 ----
  was less than or equal to 0, or greater than 16.
  .TP 15
  [EINVAL]
  The sum of the
  .I iov_len
  values in the
  .I iov
! array overflowed a short.
  .TP 15
  [EFAULT]
  Part of the \fIiov\fP points outside the process's allocated address space.
  .SH "SEE ALSO"
  dup(2), fcntl(2), open(2), pipe(2), select(2), socket(2), socketpair(2)
*** /usr/src/man/man2/write.2.old	Thu Aug 20 12:32:37 1987
--- /usr/src/man/man2/write.2	Sun Apr  8 00:10:19 1990
***************
*** 14,20 ****
  cc = write(d, buf, nbytes)
  int cc, d;
  char *buf;
! int nbytes;
  .PP
  .ft B
  #include <sys/types.h>
--- 14,20 ----
  cc = write(d, buf, nbytes)
  int cc, d;
  char *buf;
! unsigned short nbytes;
  .PP
  .ft B
  #include <sys/types.h>
***************
*** 53,59 ****
  .DT
  struct iovec {
  	caddr_t	iov_base;
! 	int	iov_len;
  };
  .RE
  .fi
--- 53,59 ----
  .DT
  struct iovec {
  	caddr_t	iov_base;
! 	u_short	iov_len;
  };
  .RE
  .fi
***************
*** 155,191 ****
  was less than or equal to 0, or greater than 16.
  .TP 15
  [EINVAL]
- One of the
- .I iov_len
- values in the
- .I iov
- array was negative.
- .TP 15
- [EINVAL]
  The sum of the
  .I iov_len
  values in the
  .I iov
! array overflowed an integer.
  .SH "SEE ALSO"
  fcntl(2), lseek(2), open(2), pipe(2), select(2)
- .SH BUGS
- Under
- .I 2.10BSD
- .I writev
- is implemented as a compatibility routine in the standard library and is
- semantically identical to the 4.3BSD
- .I writev
- on all current descriptors, with the exception of sockets (SOCK_STREAM
- does work identically however).  The compatibility routine implements
- .I writev
- non-atomically as multiple
- .I write
- calls.
- .PP
- Under
- .I 2.10BSD
- .I nbytes
- is actually an
- .B unsigned
- value.
--- 155,164 ----
  was less than or equal to 0, or greater than 16.
  .TP 15
  [EINVAL]
  The sum of the
  .I iov_len
  values in the
  .I iov
! array overflowed a short.
  .SH "SEE ALSO"
  fcntl(2), lseek(2), open(2), pipe(2), select(2)
#! /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:
#	/usr/src/lib/libc/pdp/sys/readv.s
#	/usr/src/lib/libc/pdp/sys/writev.s
# This archive created: Wed Apr 11 21:36:20 1990
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f '/usr/src/lib/libc/pdp/sys/readv.s'
then
	echo shar: "will not over-write existing file '/usr/src/lib/libc/pdp/sys/readv.s'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/lib/libc/pdp/sys/readv.s'
X/*
X * Copyright (c) 1987 Regents of the University of California.
X * All rights reserved.  The Berkeley software License Agreement
X * specifies the terms and conditions for redistribution.
X */
X
X#ifdef SYSLIBC_SCCS
X_sccsid: <@(#)readv.s	2.5 (Berkeley) 1/29/87\0>
X	.even
X#endif SYSLIBC_SCCS
X
X#include "SYS.h"
X
XSYSCALL(readv,norm)
SHAR_EOF
fi
if test -f '/usr/src/lib/libc/pdp/sys/writev.s'
then
	echo shar: "will not over-write existing file '/usr/src/lib/libc/pdp/sys/writev.s'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/src/lib/libc/pdp/sys/writev.s'
X/*
X * Copyright (c) 1987 Regents of the University of California.
X * All rights reserved.  The Berkeley software License Agreement
X * specifies the terms and conditions for redistribution.
X */
X
X#ifdef SYSLIBC_SCCS
X_sccsid: <@(#)writev.s	2.5 (Berkeley) 1/29/87\0>
X	.even
X#endif SYSLIBC_SCCS
X
X#include "SYS.h"
X
XSYSCALL(writev,norm)
SHAR_EOF
fi
exit 0
#	End of shell archive
*** /usr/src/lib/libc/pdp/Makefile.old	Sun Jul  3 21:50:14 1988
--- /usr/src/lib/libc/pdp/Makefile	Fri Apr  6 09:53:48 1990
***************
*** 7,13 ****
  #
  # Machine dependent routines for the PDP are located here
  #
! COMPAT=	com-2.9 com-4.1 com-4.3
  ALL=	crt gen net stdio sys ${COMPAT}
  TAGSFILE=tags

--- 7,13 ----
  #
  # Machine dependent routines for the PDP are located here
  #
! COMPAT=	com-2.9 com-4.1
  ALL=	crt gen net stdio sys ${COMPAT}
  TAGSFILE=tags

*** /usr/src/lib/libc/pdp/sys/Makefile.old	Wed Feb  4 21:20:29 1987
--- /usr/src/lib/libc/pdp/sys/Makefile	Fri Apr  6 09:33:46 1990
***************
*** 14,20 ****
  	getpriority.s getrlimit.s getrusage.s getsockname.s getsockopt.s \
  	gettimeofday.s getuid.s ioctl.s kill.s killpg.s link.s listen.s \
  	lseek.s lstat.s mkdir.s mknod.s mount.s open.s pipe.s profil.s \
! 	ptrace.s quota.s read.s readlink.s reboot.s recv.s recvfrom.s \
  	recvmsg.s rename.s rmdir.s sbrk.s select.s send.s sendmsg.s sendto.s \
  	setdopt.s setgroups.s sethostid.s sethostname.s setitimer.s \
  	setpgrp.s setpriority.s setquota.s setregid.s setreuid.s setrlimit.s \
--- 14,20 ----
  	getpriority.s getrlimit.s getrusage.s getsockname.s getsockopt.s \
  	gettimeofday.s getuid.s ioctl.s kill.s killpg.s link.s listen.s \
  	lseek.s lstat.s mkdir.s mknod.s mount.s open.s pipe.s profil.s \
! 	ptrace.s quota.s read.s readlink.s readv.s reboot.s recv.s recvfrom.s \
  	recvmsg.s rename.s rmdir.s sbrk.s select.s send.s sendmsg.s sendto.s \
  	setdopt.s setgroups.s sethostid.s sethostname.s setitimer.s \
  	setpgrp.s setpriority.s setquota.s setregid.s setreuid.s setrlimit.s \
***************
*** 21,27 ****
  	setsockopt.s settimeofday.s shutdown.s sigblock.s sigpause.s \
  	sigreturn.s sigsetmask.s sigstack.s sigvec.s socket.s socketpair.s \
  	stat.s symlink.s sync.s truncate.s umask.s umount.s unlink.s \
! 	utimes.s vfork.s vhangup.s wait.s wait3.s write.s
  OBJS=	_exit.o accept.o access.o acct.o adjtime.o bind.o brk.o chdir.o \
  	chmod.o chown.o chroot.o close.o connect.o creat.o dup.o dup2.o \
  	execl.o execle.o execv.o execve.o fchmod.o fchown.o fcntl.o flock.o \
--- 21,27 ----
  	setsockopt.s settimeofday.s shutdown.s sigblock.s sigpause.s \
  	sigreturn.s sigsetmask.s sigstack.s sigvec.s socket.s socketpair.s \
  	stat.s symlink.s sync.s truncate.s umask.s umount.s unlink.s \
! 	utimes.s vfork.s vhangup.s wait.s wait3.s write.s writev.s
  OBJS=	_exit.o accept.o access.o acct.o adjtime.o bind.o brk.o chdir.o \
  	chmod.o chown.o chroot.o close.o connect.o creat.o dup.o dup2.o \
  	execl.o execle.o execv.o execve.o fchmod.o fchown.o fcntl.o flock.o \
***************
*** 31,37 ****
  	getpriority.o getrlimit.o getrusage.o getsockname.o getsockopt.o \
  	gettimeofday.o getuid.o ioctl.o kill.o killpg.o link.o listen.o \
  	lseek.o lstat.o mkdir.o mknod.o mount.o open.o pipe.o profil.o \
! 	ptrace.o quota.o read.o readlink.o reboot.o recv.o recvfrom.o \
  	recvmsg.o rename.o rmdir.o sbrk.o select.o send.o sendmsg.o sendto.o \
  	setdopt.o setgroups.o sethostid.o sethostname.o setitimer.o \
  	setpgrp.o setpriority.o setquota.o setregid.o setreuid.o setrlimit.o \
--- 31,37 ----
  	getpriority.o getrlimit.o getrusage.o getsockname.o getsockopt.o \
  	gettimeofday.o getuid.o ioctl.o kill.o killpg.o link.o listen.o \
  	lseek.o lstat.o mkdir.o mknod.o mount.o open.o pipe.o profil.o \
! 	ptrace.o quota.o read.o readlink.o readv.o reboot.o recv.o recvfrom.o \
  	recvmsg.o rename.o rmdir.o sbrk.o select.o send.o sendmsg.o sendto.o \
  	setdopt.o setgroups.o sethostid.o sethostname.o setitimer.o \
  	setpgrp.o setpriority.o setquota.o setregid.o setreuid.o setrlimit.o \
***************
*** 38,44 ****
  	setsockopt.o settimeofday.o shutdown.o sigblock.o sigpause.o \
  	sigreturn.o sigsetmask.o sigstack.o sigvec.o socket.o socketpair.o \
  	stat.o symlink.o sync.o truncate.o umask.o umount.o unlink.o \
! 	utimes.o vfork.o vhangup.o wait.o wait3.o write.o
  CFLAGS=	-O ${DEFS}
  TAGSFILE=tags

--- 38,44 ----
  	setsockopt.o settimeofday.o shutdown.o sigblock.o sigpause.o \
  	sigreturn.o sigsetmask.o sigstack.o sigvec.o socket.o socketpair.o \
  	stat.o symlink.o sync.o truncate.o umask.o umount.o unlink.o \
! 	utimes.o vfork.o vhangup.o wait.o wait3.o write.o writev.o
  CFLAGS=	-O ${DEFS}
  TAGSFILE=tags

***************
*** 158,163 ****
--- 158,164 ----
  quota.o: quota.s ./SYS.h /usr/include/syscall.h
  read.o: read.s ./SYS.h /usr/include/syscall.h
  readlink.o: readlink.s ./SYS.h /usr/include/syscall.h
+ readv.o: readv.s ./SYS.h /usr/include/syscall.h
  reboot.o: reboot.s ./SYS.h /usr/include/syscall.h
  recv.o: recv.s ./SYS.h /usr/include/syscall.h
  recvfrom.o: recvfrom.s ./SYS.h /usr/include/syscall.h
***************
*** 204,209 ****
--- 205,211 ----
  wait.o: wait.s ./SYS.h /usr/include/syscall.h
  wait3.o: wait3.s ./SYS.h /usr/include/syscall.h
  write.o: write.s ./SYS.h /usr/include/syscall.h
+ writev.o: writev.s ./SYS.h /usr/include/syscall.h
  # DEPENDENCIES MUST END AT END OF FILE
  # IF YOU PUT STUFF HERE IT WILL GO AWAY
  # see make depend above
#! /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:
#	/usr/lib/adb/u
# This archive created: Thu Apr 12 08:57:57 1990
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f '/usr/lib/adb/u'
then
	echo shar: "will not over-write existing file '/usr/lib/adb/u'"
else
sed 's/^X//' << \SHAR_EOF > '/usr/lib/adb/u'
X./"pcb"non"u_fpsr"ndn"u_fpregs"n6Fn"u_fpsaved"ndn"f_fec"8t"f_fea"ndon
X+/"u_proc"non"u_ar0"non"u_comm"n15C+n"u_arg"n6on
X+/"u_ap"non
X+/"qsave"n
X+$<<label
X+/"val1"8t"val2"n2on
X+/"u_error"8t"u_eosys"n2bn"uid"8t"ruid"8t"gid"8t"rgid"n4un"groups"n16u
X+/"tsize"8t"dsize"8t"ssize"n3un
X+/"ssave"n
X+$<<label
X+/"rsave"n
X+$<<label
X+/"uisa"n16on
X+/"uisd"n16on
X+/"u_sep"nbn+"curov"8t"ovbase"8t"dbase"n2dun"
X+/"ov_offst"n16un"nseg"ndn64+
X+/"sigmask"n32Dn
X+/"sigonstack"16t"sigintr"16t"oldmask"n3Xn"code"ndn
X+/"onstack"8t"sigsp"nodn
X+/"ofile"n30on"pofile"n30bn
X+/"lastfile"ndn
X+/"cdir"8t"rdir"n2on
X+/"tty"8t"minor"8t"major"no2bn
X+/"cmask"nxn
X+/"ru"n
X+$<<rusage
X+/"cru"n
X+$<<rusage
X+/"itimers"n4Dn
X+/"start"nYn
X+/"acflag"nbn9+
X+/"rlimits"n12D
X+/"quota"non
X+/"nc_off"16t"nc_inum"8t"nc_dev"nDubbn
X+/"ni_dirp"8t"nameiop"8t"ni_error"nouun
X+/"ni_endoff"8t"ni_pdir"nDon
X+/"ni_base"8t"ni_count"noun
X+/"ni_iov"8t"ni_iovcnt"noun
X+/"ni_offset"8t"ni_segflg"8t"ni_resid"nDuun
X+/"d_inum"8t"d_name"nu14Cn
SHAR_EOF
fi
exit 0
#	End of shell archive
*** /usr/src/etc/pstat.c.old	Wed Aug 10 11:39:06 1988
--- /usr/src/etc/pstat.c	Thu Apr  5 21:42:47 1990
***************
*** 529,534 ****
--- 529,535 ----
  	struct user U;
  	long	*ip;
  	register i, j;
+ 	register struct nameidata *nd = &U.u_nd;

  	lseek(fm, ubase << 6, 0);
  	read(fm, &U, sizeof(U));
***************
*** 639,645 ****
  	printf("lastfile\t%d\n", U.u_lastfile);
  	printf("cdir\t%.1o\n", U.u_cdir);
  	printf("rdir\t%.1o\n", U.u_rdir);
! 	printf("pdir\t%.1o\n", U.u_pdir);
  	printf("ttyp\t%.1o\n", U.u_ttyp);
  	printf("ttyd\t%d,%d\n", major(U.u_ttyd), minor(U.u_ttyd));
  	printf("cmask\t%.1o\n", U.u_cmask);
--- 640,646 ----
  	printf("lastfile\t%d\n", U.u_lastfile);
  	printf("cdir\t%.1o\n", U.u_cdir);
  	printf("rdir\t%.1o\n", U.u_rdir);
! 	printf("pdir\t%.1o\n", nd->ni_pdir);
  	printf("ttyp\t%.1o\n", U.u_ttyp);
  	printf("ttyd\t%d,%d\n", major(U.u_ttyd), minor(U.u_ttyd));
  	printf("cmask\t%.1o\n", U.u_cmask);
***************
*** 678,696 ****
  			printf("%ld ", U.u_rlimit[i].rlim_max);
  		}
  	printf("\n");
- #ifdef QUOTA
  	printf("quota\t%.1o\n", U.u_quota);
! #endif
! 	printf("base\t%.1o\n", U.u_base);
! 	printf("count\t%u\n", U.u_count);
! 	printf("offset\t%ld\n", U.u_offset);
! 	printf("segflg\t%d\n", U.u_segflg);
  	printf("ncache\t%ld %u %d,%d\n", U.u_ncache.nc_prevoffset,
  		U.u_ncache.nc_inumber, major(U.u_ncache.nc_dev),
  		minor(U.u_ncache.nc_dev));
! 	printf("endoff\t%ld\n", U.ni_endoff);
! 	printf("dirp\t%.1o\n", U.u_dirp);
! 	printf("dent\t%u %s\n", U.u_dent.d_ino, U.u_dent.d_name);
  }

  oatoi(s)
--- 679,694 ----
  			printf("%ld ", U.u_rlimit[i].rlim_max);
  		}
  	printf("\n");
  	printf("quota\t%.1o\n", U.u_quota);
! 	printf("base,count,offset\t%.1o %u %ld\n", nd->ni_base,
! 		nd->ni_count, nd->ni_offset);
! 	printf("segflg\t%d\n", nd->ni_segflg);
  	printf("ncache\t%ld %u %d,%d\n", U.u_ncache.nc_prevoffset,
  		U.u_ncache.nc_inumber, major(U.u_ncache.nc_dev),
  		minor(U.u_ncache.nc_dev));
! 	printf("endoff\t%ld\n", nd->ni_endoff);
! 	printf("dirp\t%.1o\n", nd->ni_dirp);
! 	printf("dent\t%u %s\n", nd->ni_dent.d_ino, nd->ni_dent.d_name);
  }

  oatoi(s)

        This is a list of the system programs which will need to be
        recompiled when the u struct is changed.   The 'crash' program
        was never ported fully to 2.10.1BSD and nothing has been done
        to change that.  It is unknown whether the 'builcore' program
        works either, again, nothing has been done to change that.

/usr/src/bin/adb
/usr/src/bin/ps.c
/usr/src/etc/fstat.c
/usr/src/etc/pstat.c
/usr/src/new/OLD/buildcore.c
/usr/src/new/crash/crash.c
/usr/src/ucb/w.c
/usr/src/ucb/gcore.c

---------------------------------------------------------------------

        don't forget to

                rm -r /usr/src/lib/libc/com-4.3
                ar d /lib/libc.a rdwrv.o
                ar d /usr/lib/libc_p.a rdwrv.o
                rm /sys/sys/sys_inode2.c

----------------------------------------------------------------------

diff -r -c /usr/src/oldsys/OTHERS/berknet/bk.c /usr/src/sys/OTHERS/berknet/bk.c
*** /usr/src/oldsys/OTHERS/berknet/bk.c	Tue Dec 16 17:01:52 1986
--- /usr/src/sys/OTHERS/berknet/bk.c	Wed Apr 11 13:32:23 1990
***************
*** 105,112 ****
   * is waiting.  Our clearing tp->t_rec here allows further input
   * to accumulate.
   */
! bkread(tp)
  register struct tty *tp;
  {
  	register int i;
  	register s;
--- 105,113 ----
   * is waiting.  Our clearing tp->t_rec here allows further input
   * to accumulate.
   */
! bkread(tp, uio)
  register struct tty *tp;
+ 	struct uio *uio;
  {
  	register int i;
  	register s;
***************
*** 119,132 ****
  	splx(s);
  	if (tp->t_line != NETLDISC)
  		return (-1);
! 	i = MIN(tp->t_inbuf, (int)u.u_count);
! 	if (copyout(tp->t_bufp->b_un.b_addr, u.u_base, (unsigned)i)) {
  		u.u_error = EFAULT;
  		return (-1);
  	}
! 	u.u_count -= i;
! 	u.u_base += i;
! 	u.u_offset += i;
  	tp->t_cp = (char *)tp->t_bufp->b_un.b_addr;
  	tp->t_inbuf = 0;
  	tp->t_rec = 0;
--- 120,133 ----
  	splx(s);
  	if (tp->t_line != NETLDISC)
  		return (-1);
! 	i = MIN(tp->t_inbuf, (int)uio->uio_resid);
! 	if (copyout(tp->t_bufp->b_un.b_addr, uio->uio_iov->iov_base, (unsigned)i)) {
  		u.u_error = EFAULT;
  		return (-1);
  	}
! 	uio->uio_resid -= i;
! 	uio->uio_iov->iov_base += i;
! 	uio->uio_offset += i;
  	tp->t_cp = (char *)tp->t_bufp->b_un.b_addr;
  	tp->t_inbuf = 0;
  	tp->t_rec = 0;
***************
*** 186,189 ****
  }
  #endif UCB_NTTY
  #endif NBK > 0
-
--- 187,189 ----
diff -r -c /usr/src/oldsys/OTHERS/dig_anal/ds.c /usr/src/sys/OTHERS/dig_anal/ds.c
*** /usr/src/oldsys/OTHERS/dig_anal/ds.c	Wed May 27 21:56:56 1987
--- /usr/src/sys/OTHERS/dig_anal/ds.c	Wed Apr 11 15:44:25 1990
***************
*** 478,484 ****
   * the user buffer should be a multiple of the track size of the disk.
   * this is for efficiency of disk i/o.
   *
!  * using u.u_count, u.u_base, and f_bsize each buffer header is set up.
   * the converters only need the base address of the buffer and the word
   * count. the disk needs these in addition to the block number. if we
   * are doing d/a conversions then we start the disk up to fill up the
--- 478,484 ----
   * the user buffer should be a multiple of the track size of the disk.
   * this is for efficiency of disk i/o.
   *
!  * using uio_resid, iov_base, and f_bsize each buffer header is set up.
   * the converters only need the base address of the buffer and the word
   * count. the disk needs these in addition to the block number. if we
   * are doing d/a conversions then we start the disk up to fill up the
diff -r -c /usr/src/oldsys/OTHERS/dmc11/dmc.c /usr/src/sys/OTHERS/dmc11/dmc.c
*** /usr/src/oldsys/OTHERS/dmc11/dmc.c	Wed Oct  9 21:31:23 1985
--- /usr/src/sys/OTHERS/dmc11/dmc.c	Wed Apr 11 13:26:00 1990
***************
*** 166,173 ****
          dp->state = 0;
  }

! dmcread(dev)
  dev_t dev;
  {
          register struct buf *dp;
          register struct buf *bp, *pbp;
--- 166,174 ----
          dp->state = 0;
  }

! dmcread(dev, uio)
  dev_t dev;
+ struct uio *uio;
  {
          register struct buf *dp;
          register struct buf *bp, *pbp;
***************
*** 177,183 ****
          dp = &dmcutab[unit];

          if ((!(dp->state & OPEN))       /* last read after NETCLOSE */
!             || (u.u_count < bp->b_bcount)) {
                  u.u_error = EINVAL;
                  return;
          }
--- 178,184 ----
          dp = &dmcutab[unit];

          if ((!(dp->state & OPEN))       /* last read after NETCLOSE */
!             || (uio->uio_resid < bp->b_bcount)) {
                  u.u_error = EINVAL;
                  return;
          }
***************
*** 199,205 ****
          (void) _spl0();

          if (bp->b_bcount > 0) {
!                 iomove(mapin(bp), bp->b_bcount, B_READ);
                  mapout(bp);
          }
          dp->inbufq = bp->inbufq;
--- 200,206 ----
          (void) _spl0();

          if (bp->b_bcount > 0) {
!                 uiomove(mapin(bp), bp->b_bcount, B_READ, uio);
                  mapout(bp);
          }
          dp->inbufq = bp->inbufq;
***************
*** 210,217 ****
          dmcitrans(unit,BACC | RFLAG, bp->b_un.b_addr, bp->xcnt);
  }

! dmcwrite(dev)
  dev_t dev;
  {
          register struct buf *bp, *dp, *pbp;
          register int unit;
--- 211,219 ----
          dmcitrans(unit,BACC | RFLAG, bp->b_un.b_addr, bp->xcnt);
  }

! dmcwrite(dev, uio)
  dev_t dev;
+ struct uio *uio;
  {
          register struct buf *bp, *dp, *pbp;
          register int unit;
***************
*** 219,225 ****
          if (chkphys(BYTE))
                  return;
          unit = minor(dev);
!         if (u.u_count > BUFSIZ) {
                  u.u_error = EINVAL;
                  return;
          }
--- 221,227 ----
          if (chkphys(BYTE))
                  return;
          unit = minor(dev);
!         if (uio->uio_resid > BUFSIZ) {
                  u.u_error = EINVAL;
                  return;
          }
***************
*** 261,267 ****
          dmcitrans(unit, BACC|TFLAG, bp->b_un.b_addr,
                  ((unsigned)bp->b_xmem<<EXTSHFT)|bp->b_bcount);
          iowait(bp);
!         u.u_count = 0;
          bp->b_flags = 0;
          u.u_procp->p_flag &= ~SLOCK;
          bp->tbufq = dp->tbufq;
--- 263,269 ----
          dmcitrans(unit, BACC|TFLAG, bp->b_un.b_addr,
                  ((unsigned)bp->b_xmem<<EXTSHFT)|bp->b_bcount);
          iowait(bp);
!         uio->uio_resid = 0;
          bp->b_flags = 0;
          u.u_procp->p_flag &= ~SLOCK;
          bp->tbufq = dp->tbufq;
diff -r -c /usr/src/oldsys/OTHERS/du11/du.c /usr/src/sys/OTHERS/du11/du.c
*** /usr/src/oldsys/OTHERS/du11/du.c	Wed Oct  9 21:31:31 1985
--- /usr/src/sys/OTHERS/du11/du.c	Wed Apr 11 09:55:25 1990
***************
*** 213,219 ****
  	maint = 0;
  }

! duread()
  {
  	register nbytes;

--- 213,221 ----
  	maint = 0;
  }

! duread(dev, uio)
! 	dev_t dev;
! 	struct uio *uio;
  {
  	register nbytes;

***************
*** 248,261 ****
  	/*
  	 * Copy the message to the caller's buffer
  	 */
! 	nbytes = min(u.u_count, du11.durbufo->msgbc);
! 	iomove(du11.durbufo->msgbufp, nbytes, B_READ);
  	if (++du11.durbufo == du11.durbuff + MSGN)
  		du11.durbufo = du11.durbuff;
  	du11.durbufn--;
  }

! duwrite()
  {
  	register nbytes;

--- 250,265 ----
  	/*
  	 * Copy the message to the caller's buffer
  	 */
! 	nbytes = min(uio->uio_resid, du11.durbufo->msgbc);
! 	uiomove(du11.durbufo->msgbufp, nbytes, B_READ, uio);
  	if (++du11.durbufo == du11.durbuff + MSGN)
  		du11.durbufo = du11.durbuff;
  	du11.durbufn--;
  }

! duwrite(dev, uio)
! 	dev_t	dev;
! 	struct	uio *uio;
  {
  	register nbytes;

***************
*** 268,276 ****
  	/*
  	 * Transfer  the message from the caller's buffer to ours
  	 */
! 	nbytes = min(u.u_count, MSGLEN);
  	du11.dutbufi->msgbc = nbytes;
! 	iomove(du11.dutbufi->msgbufp, nbytes, B_WRITE);
  	if (++du11.dutbufi == du11.dutbuff + MSGN)
  		du11.dutbufi = du11.dutbuff;
  	du11.dutbufn++;
--- 272,280 ----
  	/*
  	 * Transfer  the message from the caller's buffer to ours
  	 */
! 	nbytes = min(uio->uio_resid, MSGLEN);
  	du11.dutbufi->msgbc = nbytes;
! 	uiomove(du11.dutbufi->msgbufp, nbytes, B_WRITE, uio);
  	if (++du11.dutbufi == du11.dutbuff + MSGN)
  		du11.dutbufi = du11.dutbuff;
  	du11.dutbufn++;
diff -r -c /usr/src/oldsys/OTHERS/dv/dv.c /usr/src/sys/OTHERS/dv/dv.c
*** /usr/src/oldsys/OTHERS/dv/dv.c	Wed Jun 25 09:58:28 1986
--- /usr/src/sys/OTHERS/dv/dv.c	Wed Apr 11 11:10:34 1990
***************
*** 408,433 ****
  	if(n==0)
  		dvstart();
  }
! dvread(dev)
  {

  	if(dvphys(dev))
! 	physio(dvstrategy, &rdvbuf, dev, B_READ, WORD);
  }

! dvwrite(dev)
  {

  	if(dvphys(dev))
! 	physio(dvstrategy, &rdvbuf, dev, B_WRITE, WORD);
  }

! dvphys(dev)
  {
  	long c;

! 	c = u.u_offset >> 9;
! 	c += (u.u_count+511) / 512;
  	if(c > dv_sizes[minor(dev) & 07].nblocks) {
  		u.u_error = ENXIO;
  		return(0);
--- 408,437 ----
  	if(n==0)
  		dvstart();
  }
! dvread(dev, uio)
! 	dev_t dev;
! 	struct uio *uio;
  {

  	if(dvphys(dev))
! 	physio(dvstrategy, &rdvbuf, dev, B_READ, WORD, uio);
  }

! dvwrite(dev, uio)
! 	dev_t dev;
! 	struct uio *uio;
  {

  	if(dvphys(dev))
! 	physio(dvstrategy, &rdvbuf, dev, B_WRITE, WORD, uio);
  }

! dvphys(dev, uio)
  {
  	long c;

! 	c = uio->uio_offset >> 9;
! 	c += (uio->uio_resid+511) / 512;
  	if(c > dv_sizes[minor(dev) & 07].nblocks) {
  		u.u_error = ENXIO;
  		return(0);
***************
*** 434,438 ****
  	}
  	return(1);
  }
-
-
--- 438,440 ----
diff -r -c /usr/src/oldsys/OTHERS/ht/ht.c /usr/src/sys/OTHERS/ht/ht.c
*** /usr/src/oldsys/OTHERS/ht/ht.c	Wed May 27 19:09:19 1987
--- /usr/src/sys/OTHERS/ht/ht.c	Wed Apr 11 13:46:32 1990
***************
*** 432,444 ****
  	physio(htstrategy, &rhtbuf, dev, B_WRITE);
  }

! htphys(dev)
  dev_t dev;
  {
  	daddr_t a;
  	register struct tu_softc *sc = &tu_softc[TUUNIT(dev)];

! 	a = dbtofsb(u.u_offset >> PGSHIFT);
  	sc->sc_blkno = a;
  	sc->sc_nxrec = a + 1;
  }
--- 432,445 ----
  	physio(htstrategy, &rhtbuf, dev, B_WRITE);
  }

! htphys(dev, uio)
  dev_t dev;
+ struct uio *uio;
  {
  	daddr_t a;
  	register struct tu_softc *sc = &tu_softc[TUUNIT(dev)];

! 	a = dbtofsb(uio->uio_offset >> PGSHIFT);
  	sc->sc_blkno = a;
  	sc->sc_nxrec = a + 1;
  }
diff -r -c /usr/src/oldsys/OTHERS/multiplexor/mx2.c /usr/src/sys/OTHERS/multiplexor/mx2.c
*** /usr/src/oldsys/OTHERS/multiplexor/mx2.c	Wed Oct  9 21:31:59 1985
--- /usr/src/sys/OTHERS/multiplexor/mx2.c	Wed Apr 11 09:59:43 1990
***************
*** 211,217 ****
   * Calls are made through linesw to handle actual
   * data movement.
   */
! mxread(dev)
  {
  	register struct group *gp;
  	register struct chan *cp;
--- 211,219 ----
   * Calls are made through linesw to handle actual
   * data movement.
   */
! mxread(dev, uio)
! 	dev_t dev;
! 	struct uio *uio;
  {
  	register struct group *gp;
  	register struct chan *cp;
***************
*** 228,246 ****

  	fmp = FP->f_flag & FMP;
  	if (fmp != FMP) {
! 		if (u.u_count == 0)
  			return;
  		msread(fmp, FP->f_un.f_chan);
  		return;
  	}

! 	if ((int)u.u_base & 1) {
  		u.u_error = ENXIO;
  		return;
  	}

  	s = spl6();
! 	if (u.u_count == 0)
  	{
  		if (gp->g_datq == 0)
  			u.u_error = ENXIO;
--- 230,248 ----

  	fmp = FP->f_flag & FMP;
  	if (fmp != FMP) {
! 		if (uio->uio_resid == 0)
  			return;
  		msread(fmp, FP->f_un.f_chan);
  		return;
  	}

! 	if ((int)uio->uio_iov->iov_base & 1) {
  		u.u_error = ENXIO;
  		return;
  	}

  	s = spl6();
! 	if (uio->uio_resid == 0)
  	{
  		if (gp->g_datq == 0)
  			u.u_error = ENXIO;
***************
*** 252,258 ****
  	}
  	splx(s);

! 	while (gp->g_datq && u.u_count >= CNTLSIZ + 2) {
  		esc = 0;
  		cp = nextcp(gp);
  		if (cp==NULL) {
--- 254,260 ----
  	}
  	splx(s);

! 	while (gp->g_datq && uio->uio_resid >= CNTLSIZ + 2) {
  		esc = 0;
  		cp = nextcp(gp);
  		if (cp==NULL) {
***************
*** 263,279 ****
  			count += CNTLSIZ;
  			if (cp->c_flags&NMBUF)
  				count += nmsize;
! 			if (count > u.u_count) {
  				(void) sdata(cp);
  				return;
  			}
  			esc++;
  		}
! 		base = u.u_base;
! 		count = u.u_count;
! 		u.u_base += sizeof h;
! 		u.u_count -= sizeof h;
! 		xfr = u.u_count;
  		if (esc) {
  			more = mcread(cp);
  		} else {
--- 265,282 ----
  			count += CNTLSIZ;
  			if (cp->c_flags&NMBUF)
  				count += nmsize;
! 			if (count > uio->uio_resid) {
  				(void) sdata(cp);
  				return;
  			}
  			esc++;
  		}
! 		base = uio->uio_iov->iov_base;
! 		count = uio->uio_iov->iov_len;
! 		uio->uio_iov->iov_base += sizeof h;
! 		uio->uio_iov->iov_len -= sizeof h;
! 		uio->uio_resid -= sizeof h;
! 		xfr = uio->uio_resid;
  		if (esc) {
  			more = mcread(cp);
  		} else {
***************
*** 284,294 ****
  		if (more < 0)
  			scontrol(cp, M_CLOSE, 0);
  		(void) _spl0();
! 		if (xfr == u.u_count) {
  			esc++;
  			IOMOVE((caddr_t)m_eot, sizeof m_eot, B_READ);
  		}
! 		xfr -= u.u_count;
  		if (esc) {
  			h.count = 0;
  			h.ccount = xfr;
--- 287,297 ----
  		if (more < 0)
  			scontrol(cp, M_CLOSE, 0);
  		(void) _spl0();
! 		if (xfr == uio->uio_resid) {
  			esc++;
  			IOMOVE((caddr_t)m_eot, sizeof m_eot, B_READ);
  		}
! 		xfr -= uio->uio_resid;
  		if (esc) {
  			h.count = 0;
  			h.ccount = xfr;
***************
*** 297,305 ****
  			h.ccount = 0;
  			mxrstrt(cp, &cp->cx.datq, BLOCK|ALT);
  		}
! 		if (u.u_count && (xfr&1)) {
! 			u.u_base++;
! 			u.u_count--;
  		}
  		(void) copyout((caddr_t)&h, base, sizeof h);

--- 300,309 ----
  			h.ccount = 0;
  			mxrstrt(cp, &cp->cx.datq, BLOCK|ALT);
  		}
! 		if (uio->uio_resid && (xfr&1)) {
! 			uio->uio_iov->iov_base++;
! 			uio->uio_iov->iov_len--;
! 			uio->uio_resid--;
  		}
  		(void) copyout((caddr_t)&h, base, sizeof h);

***************
*** 307,313 ****
  }


! mxwrite(dev)
  {
  register struct chan *cp;
  struct	wh h;
--- 311,319 ----
  }


! mxwrite(dev, uio)
! 	dev_t dev;
! 	struct uio *uio;
  {
  register struct chan *cp;
  struct	wh h;
***************
*** 325,332 ****
  	}

  	burpcount = 0;
! 	while (u.u_count >= sizeof h) {
! 		hbase = u.u_base;
  		IOMOVE((caddr_t)&h, sizeof h, B_WRITE);
  		if (u.u_error)
  			return;
--- 331,338 ----
  	}

  	burpcount = 0;
! 	while (uio->uio_resid >= sizeof h) {
! 		hbase = uio->uio_iov->iov_base;
  		IOMOVE((caddr_t)&h, sizeof h, B_WRITE);
  		if (u.u_error)
  			return;
***************
*** 340,349 ****
  			u.u_error = ENXIO;
  			return;
  		}
! 		ucount = u.u_count;
! 		ubase = u.u_base;
! 		u.u_count = h.count;
! 		u.u_base = h.data;

  		if (esc==0) {
  			struct tty *tp;
--- 346,355 ----
  			u.u_error = ENXIO;
  			return;
  		}
! 		ucount = uio->uio_resid;
! 		ubase = uio->uio_iov->iov_base;
! 		uio->uio_resid = uio->uio_iov->iov_len = h.count;
! 		uio->uio_iov->iov_base = h.data;

  		if (esc==0) {
  			struct tty *tp;
***************
*** 359,374 ****
  			}
  		loop:
  			waddr = (caddr_t)(*linesw[line].l_write)(tp);
! 			if (u.u_count) {
  				if (gp->g_state&ENAMSG) {
  					burpcount++;
  					cp->c_flags |= BLKMSG;
  /*
! 					scontrol(cp, M_BLK, u.u_count);
  */
  					h.ccount = -1;
! 					h.count = u.u_count;
! 					h.data = u.u_base;
  					(void) copyout((caddr_t)&h, hbase, sizeof h);
  				} else {
  					if(waddr == 0) {
--- 365,380 ----
  			}
  		loop:
  			waddr = (caddr_t)(*linesw[line].l_write)(tp);
! 			if (uio->uio_resid) {
  				if (gp->g_state&ENAMSG) {
  					burpcount++;
  					cp->c_flags |= BLKMSG;
  /*
! 					scontrol(cp, M_BLK, uio->uio_resid);
  */
  					h.ccount = -1;
! 					h.count = uio->uio_resid;
! 					h.data = uio->uio_iov->iov_base;
  					(void) copyout((caddr_t)&h, hbase, sizeof h);
  				} else {
  					if(waddr == 0) {
***************
*** 382,391 ****
  		} else {
  			mxwcontrol(cp);
  		}
! 		u.u_count = ucount;
! 		u.u_base = ubase;
  	}
! 	u.u_count = burpcount;
  }


--- 388,397 ----
  		} else {
  			mxwcontrol(cp);
  		}
! 		uio->uio_resid = uio->uio_iov->iov_len = ucount;
! 		uio->uio_iov->iov_base = ubase;
  	}
! 	uio->uio_resid = uio->uio_iov->iov_len = burpcount;
  }


***************
*** 396,403 ****
   * Kernel-to-Kernel and other special transfers are not
   * yet in.
   */
! mcread(cp)
  register struct chan *cp;
  {
  register struct clist *q;
  register char *np;
--- 402,410 ----
   * Kernel-to-Kernel and other special transfers are not
   * yet in.
   */
! mcread(cp, uio)
  register struct chan *cp;
+ 	struct uio *uio;
  {
  register struct clist *q;
  register char *np;
***************
*** 421,434 ****


  caddr_t
! mcwrite(cp)
  register struct chan *cp;
  {
  register struct clist *q;
  int	s;

  	q = &cp->cy.datq;
! 	while (u.u_count) {
  		s = spl6();
  		if (q->c_cc > HIQ || (cp->c_flags&EOTMARK)) {
  			cp->c_flags |= SIGBLK;
--- 428,442 ----


  caddr_t
! mcwrite(cp, uio)
  register struct chan *cp;
+ 	struct	uio *uio;
  {
  register struct clist *q;
  int	s;

  	q = &cp->cy.datq;
! 	while (uio->uio_resid) {
  		s = spl6();
  		if (q->c_cc > HIQ || (cp->c_flags&EOTMARK)) {
  			cp->c_flags |= SIGBLK;
***************
*** 447,454 ****
   * Msread and mswrite move bytes
   * between user and non-multiplexed channel.
   */
! msread(fmp, cp)
  register struct chan *cp;
  {
  register struct clist *q;
  int s;
--- 455,463 ----
   * Msread and mswrite move bytes
   * between user and non-multiplexed channel.
   */
! msread(fmp, cp, uio)
  register struct chan *cp;
+ 	struct	uio *uio;
  {
  register struct clist *q;
  int s;
***************
*** 486,499 ****
  }


! mswrite(fmp, cp)
  register struct chan *cp;
  {
  	register struct clist *q;
  	register int cc;

  	q = (fmp&FMPX) ? &cp->cy.datq : &cp->cx.datq;
! 	while (u.u_count) {
  		(void) _spl6();
  		if (cp->c_flags&WCLOSE) {
  			gsignal(cp->c_pgrp, SIGPIPE);
--- 495,509 ----
  }


! mswrite(fmp, cp, uio)
  register struct chan *cp;
+ 	struct	uio *uio;
  {
  	register struct clist *q;
  	register int cc;

  	q = (fmp&FMPX) ? &cp->cy.datq : &cp->cx.datq;
! 	while (uio->uio_resid) {
  		(void) _spl6();
  		if (cp->c_flags&WCLOSE) {
  			gsignal(cp->c_pgrp, SIGPIPE);
***************
*** 531,544 ****
   * move chars between clist and user space.
   */

! mxmove(q, dir)
  register struct clist *q;
  register dir;
  {
  register cc;
  char cbuf[HIQ];

! 	cc = MIN(u.u_count, sizeof cbuf);
  	if (dir == B_READ)
  		cc = q_to_b(q, cbuf, cc);
  	if (cc <= 0)
--- 541,555 ----
   * move chars between clist and user space.
   */

! mxmove(q, dir, uio)
  register struct clist *q;
  register dir;
+ 	struct uio *uio;
  {
  register cc;
  char cbuf[HIQ];

! 	cc = MIN(uio->uio_resid, sizeof cbuf);
  	if (dir == B_READ)
  		cc = q_to_b(q, cbuf, cc);
  	if (cc <= 0)
diff -r -c /usr/src/oldsys/OTHERS/rc/rc.c /usr/src/sys/OTHERS/rc/rc.c
*** /usr/src/oldsys/OTHERS/rc/rc.c	Wed Oct  9 21:32:09 1985
--- /usr/src/sys/OTHERS/rc/rc.c	Wed Apr 11 09:48:00 1990
***************
*** 13,24 ****

  extern	struct rcdevice *RCADDR;

! rcread(dev)
  dev_t	dev;
  {
  	struct tm t;

! 	if(u.u_count != sizeof(t)) {
  		u.u_error = EINVAL;
  		return;
  	}
--- 13,25 ----

  extern	struct rcdevice *RCADDR;

! rcread(dev, uio)
  dev_t	dev;
+ struct uio *uio;
  {
  	struct tm t;

! 	if(uio->uio_resid != sizeof(t)) {
  		u.u_error = EINVAL;
  		return;
  	}
***************
*** 32,44 ****
  	t.tm_yday = -1;
  	t.tm_isdst = -1;

! 	if (copyout((caddr_t) &t, (caddr_t) u.u_base, sizeof t) < 0)
  		  u.u_error = EFAULT;
! 	u.u_count -= sizeof t;
  }

! rcwrite(dev)
  dev_t	dev;
  {
  	register ymd;
  	register hm;
--- 33,46 ----
  	t.tm_yday = -1;
  	t.tm_isdst = -1;

! 	if (copyout((caddr_t)&t, (caddr_t)uio->uio_iov->iov_base, sizeof t) < 0)
  		  u.u_error = EFAULT;
! 	uio->uio_resid -= sizeof t;
  }

! rcwrite(dev, uio)
  dev_t	dev;
+ struct uio *uio;
  {
  	register ymd;
  	register hm;
***************
*** 45,55 ****
  	struct	tm t;


! 	if(u.u_count != sizeof(t)) {
  		u.u_error = EINVAL;
  		return;
  	}
! 	if (copyin((caddr_t) u.u_base, (caddr_t) &t, sizeof(t)) < 0) {
  		u.u_error = EINVAL;
  		return;
  	}
--- 47,57 ----
  	struct	tm t;


! 	if(uio->uio_resid != sizeof(t)) {
  		u.u_error = EINVAL;
  		return;
  	}
! 	if (copyin((caddr_t)uio->uio_iov->iov_base,(caddr_t)&t,sizeof(t)) < 0) {
  		u.u_error = EINVAL;
  		return;
  	}
diff -r -c /usr/src/oldsys/OTHERS/versatec/vp.c /usr/src/sys/OTHERS/versatec/vp.c
*** /usr/src/oldsys/OTHERS/versatec/vp.c	Sat Jan 10 15:35:25 1987
--- /usr/src/sys/OTHERS/versatec/vp.c	Wed Apr 11 14:44:30 1990
***************
*** 125,142 ****
  	*vpp = vp11.state = 0;
  }

! vpwrite(dev)
  dev_t dev;
  {
  	int vpstart();

! 	if ((vp11.bytecount=u.u_count) == 0)	/* true byte count */
  		return;
! 	if (u.u_count&01)	/* avoid EFAULT error in physio() */
! 		u.u_count++;
  	if (vperror())
  		return;
! 	return (physio(vpstart, &vpbuf, dev, B_WRITE, WORD));
  	/* note that newer 1200A's print @ 1000 lines/min = 2.2kbytes/sec */
  }

--- 125,143 ----
  	*vpp = vp11.state = 0;
  }

! vpwrite(dev, uio)
  dev_t dev;
+ struct uio *uio;
  {
  	int vpstart();

! 	if ((vp11.bytecount=uio->uio_resid) == 0)	/* true byte count */
  		return;
! 	if (uio->uio_resid&01)	/* avoid EFAULT error in physio() */
! 		uio->uio_resid++;
  	if (vperror())
  		return;
! 	return (physio(vpstart, &vpbuf, dev, B_WRITE, WORD, uio));
  	/* note that newer 1200A's print @ 1000 lines/min = 2.2kbytes/sec */
  }

***************
*** 182,187 ****
--- 183,190 ----
  	register int ctrl;
  	register short *vpp;
  	register struct buf *bp;
+ 	struct	uio	uio;
+ 	struct	iovec	iov;

  	switch (cmd) {

***************
*** 211,219 ****

  #ifdef THIS_IS_NOT_USEABLE
  	case BUFWRITE:
! 		u.u_base = fuword(addr);
! 		u.u_count = fuword(addr+NBPW);
! 		if ((int)u.u_base == -1 || (int)u.u_count == -1) {
  			u.u_error = EFAULT;
  			return;
  		}
--- 214,224 ----

  #ifdef THIS_IS_NOT_USEABLE
  	case BUFWRITE:
! 		uio.uio_iovcnt = 1;
! 		uio.uio_iov = &iov;
! 		iov.iov_base = fuword(addr);
! 		iov.iov_len = uio.uio_resid = fuword(addr+NBPW);
! 		if ((int)iov.iov_base == -1 || iov.iov_len == -1) {
  			u.u_error = EFAULT;
  			return;
  		}
***************
*** 229,235 ****
  			(void) _spl0();
  			return(geterror(bp));
  		}
! 		if (u.u_count == 0)
  			return;
  		/* simulate a write without starting i/o */
  		(void) _spl4();
--- 234,240 ----
  			(void) _spl0();
  			return(geterror(bp));
  		}
! 		if (uio.uio_resid == 0)
  			return;
  		/* simulate a write without starting i/o */
  		(void) _spl4();