Subject: chflags - immutable|appendonly files come to 2BSD (#203 - Part 7 of 14)
Index:	bin,etc,lib,sys/many_files 2.11BSD

Description:
	Files/directories can not be declared append-only, immutable, archived 
	or not to be dumped under 2.11BSD.

	dump(8) lacked the ability to bypass files marked for 'nodump'.

	Upper case only and Hazeltine terminal support made the tty driver 
	(and several utilities - 'vi' and 'getty' to name two) needlessly
	complicated and larger (especially since those devices are obsolete).

	open(2) can not provide for atomically obtaining a flock(2)'d
	file descriptor.

	open(2)ing with O_NDELAY (now called O_NONBLOCK) would not wait
	for carrier on the first i/o operation.

	Obsolete stub system calls 'setdopt' and 'getdopt' were still
	present in the kernel even though they have never done anything
	except take up space.

Repeat-By:
	This section does not apply this time since this is an 'update'
	which adds new functionality rather than fixing an existing bug.

Fix:
	Refer to part 1 (#197) for the complete description and installation
	instructions.

	This is part 7 of 14 (#203).

	Files affected by this part are:

/usr/src/sys/pdp/conf.c
/usr/src/sys/pdp/cons.c
/usr/src/sys/pdp/mch_xxx.s
/usr/src/sys/pdp/mem.c
/usr/src/sys/pdp/trap.c

=====================cut  here========================
*** /usr/src/sys/pdp/conf.c.old	Wed Dec 23 20:45:18 1992
--- /usr/src/sys/pdp/conf.c	Wed Nov 30 20:02:46 1994
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)conf.c	2.1 (2.11BSD Berkeley) 12/23/92
   */
  
  #include "param.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)conf.c	2.2 (2.11BSD Berkeley) 11/29/94
   */
  
  #include "param.h"
***************
*** 18,24 ****
  
  int	nulldev();
  int	nodev();
! int	rawread(), rawwrite();
  
  #include "rk.h"
  #if NRK > 0
--- 18,24 ----
  
  int	nulldev();
  int	nodev();
! int	rawrw();
  
  #include "rk.h"
  #if NRK > 0
***************
*** 332,338 ****
  int	logopen(), logclose(), logread(), logioctl(), logselect();
  int	syopen(), syread(), sywrite(), syioctl(), syselect();
  
! int	mmread(),mmwrite();
  #define	mmselect	seltrue
  
  int	ttselect(), seltrue();
--- 332,338 ----
  int	logopen(), logclose(), logread(), logioctl(), logselect();
  int	syopen(), syread(), sywrite(), syioctl(), syselect();
  
! int	mmrw();
  #define	mmselect	seltrue
  
  int	ttselect(), seltrue();
***************
*** 343,349 ****
  	cnioctl,	nulldev,	cons,		ttselect,
  	nulldev,
  /* mem = 1 */
! 	nulldev,	nulldev,	mmread,		mmwrite,
  	nodev,		nulldev,	0,		mmselect,
  	nulldev,
  /* dz = 2 */
--- 343,349 ----
  	cnioctl,	nulldev,	cons,		ttselect,
  	nulldev,
  /* mem = 1 */
! 	nulldev,	nulldev,	mmrw,		mmrw,
  	nodev,		nulldev,	0,		mmselect,
  	nulldev,
  /* dz = 2 */
***************
*** 363,377 ****
  	nodev,		nulldev,	0,		nodev,
  	nulldev,
  /* ht = 6 */
! 	htopen,		htclose,	rawread,	rawwrite,
  	htioctl,	nulldev,	0,		seltrue,
  	htstrategy,
  /* tm = 7 */
! 	tmopen,		tmclose,	rawread,	rawwrite,
  	tmioctl,	nulldev,	0,		seltrue,
  	tmstrategy,
  /* ts = 8 */
! 	tsopen,		tsclose,	rawread,	rawwrite,
  	tsioctl,	nulldev,	0,		seltrue,
  	tsstrategy,
  /* tty = 9 */
--- 363,377 ----
  	nodev,		nulldev,	0,		nodev,
  	nulldev,
  /* ht = 6 */
! 	htopen,		htclose,	rawrw,		rawrw,
  	htioctl,	nulldev,	0,		seltrue,
  	htstrategy,
  /* tm = 7 */
! 	tmopen,		tmclose,	rawrw,		rawrw,
  	tmioctl,	nulldev,	0,		seltrue,
  	tmstrategy,
  /* ts = 8 */
! 	tsopen,		tsclose,	rawrw,		rawrw,
  	tsioctl,	nulldev,	0,		seltrue,
  	tsstrategy,
  /* tty = 9 */
***************
*** 387,425 ****
  	ptyioctl,	ptsstop,	pt_tty,		ttselect,
  	nulldev,
  /* dr = 12 */
! 	dropen,		drclose,	rawread,	rawwrite,
  	drioctl,	nulldev,	0,		seltrue,
  	drstrategy,
  /* hk = 13 */
! 	hkopen,		hkclose,	rawread,	rawwrite,
  	nodev,		nulldev,	0,		seltrue,
  	hkstrategy,
  /* ra = 14 */
! 	raopen,		raclose,	rawread,	rawwrite,
  	nodev,		nulldev,	0,		seltrue,
  	rastrategy,
  /* rk = 15 */
! 	rkopen,		rkclose,	rawread,	rawwrite,
  	nodev,		nulldev,	0,		seltrue,
  	rkstrategy,
  /* rl = 16 */
! 	rlopen,		rlclose,	rawread,	rawwrite,
  	nodev,		nulldev,	0,		seltrue,
  	rlstrategy,
  /* rx = 17 */
! 	rxopen,		rxclose,	rawread,	rawwrite,
  	rxioctl,	nulldev,	0,		seltrue,
  	rxstrategy,
  /* si = 18 */
! 	siopen,		siclose,	rawread,	rawwrite,
  	nodev,		nulldev,	0,		seltrue,
  	sistrategy,
  /* xp = 19 */
! 	xpopen,		xpclose,	rawread,	rawwrite,
  	nodev,		nulldev,	0,		seltrue,
  	xpstrategy,
  /* br = 20 */
! 	bropen,		brclose,	rawread,	rawwrite,
  	nodev,		nulldev,	0,		seltrue,
  	brstrategy,
  /* dn = 21 */
--- 387,425 ----
  	ptyioctl,	ptsstop,	pt_tty,		ttselect,
  	nulldev,
  /* dr = 12 */
! 	dropen,		drclose,	rawrw,		rawrw,
  	drioctl,	nulldev,	0,		seltrue,
  	drstrategy,
  /* hk = 13 */
! 	hkopen,		hkclose,	rawrw,		rawrw,
  	nodev,		nulldev,	0,		seltrue,
  	hkstrategy,
  /* ra = 14 */
! 	raopen,		raclose,	rawrw,		rawrw,
  	nodev,		nulldev,	0,		seltrue,
  	rastrategy,
  /* rk = 15 */
! 	rkopen,		rkclose,	rawrw,		rawrw,
  	nodev,		nulldev,	0,		seltrue,
  	rkstrategy,
  /* rl = 16 */
! 	rlopen,		rlclose,	rawrw,		rawrw,
  	nodev,		nulldev,	0,		seltrue,
  	rlstrategy,
  /* rx = 17 */
! 	rxopen,		rxclose,	rawrw,		rawrw,
  	rxioctl,	nulldev,	0,		seltrue,
  	rxstrategy,
  /* si = 18 */
! 	siopen,		siclose,	rawrw,		rawrw,
  	nodev,		nulldev,	0,		seltrue,
  	sistrategy,
  /* xp = 19 */
! 	xpopen,		xpclose,	rawrw,		rawrw,
  	nodev,		nulldev,	0,		seltrue,
  	xpstrategy,
  /* br = 20 */
! 	bropen,		brclose,	rawrw,		rawrw,
  	nodev,		nulldev,	0,		seltrue,
  	brstrategy,
  /* dn = 21 */
***************
*** 431,437 ****
  	logioctl,	nulldev,	0,		logselect,
  	nulldev,
  /* tmscp = 23 (tu81/tk50) */
! 	tmscpopen,	tmscpclose,	rawread,	rawwrite,
  	tmscpioctl,	nulldev,	0,		seltrue,
  	tmscpstrategy,
  /* dhv = 24 */
--- 431,437 ----
  	logioctl,	nulldev,	0,		logselect,
  	nulldev,
  /* tmscp = 23 (tu81/tk50) */
! 	tmscpopen,	tmscpclose,	rawrw,		rawrw,
  	tmscpioctl,	nulldev,	0,		seltrue,
  	tmscpstrategy,
  /* dhv = 24 */
*** /usr/src/sys/pdp/cons.c.old	Thu Apr  5 20:19:43 1990
--- /usr/src/sys/pdp/cons.c	Wed Nov 30 22:01:31 1994
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)cons.c	1.1 (2.10BSD Berkeley) 12/1/86
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)cons.c	1.2 (2.11BSD GTE) 11/29/94
   */
  
  /*
***************
*** 78,104 ****
  {
  	register struct tty *tp = &cons[minor(dev)];
  
! 	(*linesw[tp->t_line].l_close)(tp);
  	ttyclose(tp);
  }
  
  /*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*/
--- 78,107 ----
  {
  	register struct tty *tp = &cons[minor(dev)];
  
! 	(*linesw[tp->t_line].l_close)(tp, flag);
  	ttyclose(tp);
  }
  
  /*ARGSUSED*/
! cnread(dev, uio, flag)
  	dev_t dev;
  	struct uio *uio;
+ 	int flag;
  {
  	register struct tty *tp = &cons[minor(dev)];
  
! 	return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
  }
  
  /*ARGSUSED*/
! cnwrite(dev, uio, flag)
  	dev_t dev;
+ 	struct uio *uio;
+ 	int flag;
  {
  	register struct tty *tp = &cons[minor(dev)];
  
! 	return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
  }
  
  /*ARGSUSED*/
***************
*** 124,130 ****
  	register struct tty *tp = &cons[minor(dev)];
  	register int error;
  
! 	error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, addr);
  	if (error >= 0)
  		return (error);
  	error = ttioctl(tp, cmd, addr, flag);
--- 127,133 ----
  	register struct tty *tp = &cons[minor(dev)];
  	register int error;
  
! 	error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, addr, flag);
  	if (error >= 0)
  		return (error);
  	error = ttioctl(tp, cmd, addr, flag);
*** /usr/src/sys/pdp/mch_xxx.s.old	Fri Dec 31 23:45:07 1993
--- /usr/src/sys/pdp/mch_xxx.s	Thu Dec 15 20:20:38 1994
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)mch_xxx.s	1.3 (2.11BSD GTE) 12/31/93
   */
  #include "DEFS.h"
  #include "../machine/mch_iopage.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)mch_xxx.s	1.5 (2.11BSD GTE) 12/15/94
   */
  #include "DEFS.h"
  #include "../machine/mch_iopage.h"
***************
*** 630,632 ****
--- 630,656 ----
  	sub	$4,_lastiv		/ adjust last interrupt vector
  	mov	_lastiv,r0		/ put in right place for return value
  	rts	pc			/ return assigned vector
+ 
+ /*
+  * vattr_null()
+  *
+  * Initialize a inode attribute structure.  See the comments in h/inode.h
+  * for more details.  If the vnode/inode attribute structure (which is a
+  * subset of 4.4's) changes then this routine must change also.  The 'sxt'
+  * sequences below are shorter/faster than "mov $VNOVAL,..." since VNOVAL
+  * is -1.
+ */
+ ENTRY(vattr_null)
+ 	mov	2(sp),r0		/ get address of vattr structure
+ 	mov	$-1,(r0)+		/ va_mode = VNOVAL
+ 	sxt	(r0)+			/ va_uid = VNOVAL
+ 	sxt	(r0)+			/ va_gid = VNOVAL
+ 	sxt	(r0)+			/ va_size - hi = VNOVAL
+ 	sxt	(r0)+			/ va_size - lo = VNOVAL
+ 	sxt	(r0)+			/ va_atime - hi = VNOVAL
+ 	sxt	(r0)+			/ va_atime - lo = VNOVAL
+ 	sxt	(r0)+			/ va_mtime - hi = VNOVAL
+ 	sxt	(r0)+			/ va_mtime - lo = VNOVAL
+ 	sxt	(r0)+			/ va_flags = VNOVAL
+ 	clr	(r0)+			/ va_vaflags = 0
+ 	rts	pc
*** /usr/src/sys/pdp/mem.c.old	Wed Apr 11 16:31:49 1990
--- /usr/src/sys/pdp/mem.c	Tue Nov 29 21:54:53 1994
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)mem.c	1.1 (2.10BSD Berkeley) 12/1/86
   */
  
  #include "param.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)mem.c	1.2 (2.11BSD GTE) 11/29/94
   */
  
  #include "param.h"
***************
*** 15,45 ****
  #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));
- }
- 
  /*
   * This routine is callable only from the high
   * 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;
--- 15,30 ----
  #include "hk.h"
  #include "xp.h"
  
  /*
   * This routine is callable only from the high
   * kernel as it assumes normal mapping and doesn't
!  * bother to save 'seg5'.
   */
! 
! mmrw(dev, uio, flag)
  	dev_t dev;
  	register struct uio *uio;
! 	int flag;
  {
  	register struct iovec *iov;
  	int error = 0;
***************
*** 63,78 ****
  				   ((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;
--- 48,63 ----
  				   ((btoc(8192)-1)<<8)|RW);
  			on = uio->uio_offset & 077L;
  			c = MIN(iov->iov_len, 8192 - on);
! 			error = uiomove(SEG5+on, c, uio);
  			normalseg5();
  			continue;
  /* minor device 1 is kernel memory */
  		case 1:
! 			error = uiomove((caddr_t)uio->uio_offset, iov->iov_len, uio);
  			continue;
  /* minor device 2 is EOF/RATHOLE */
  		case 2:
! 			if (uio->uio_rw == UIO_READ)
  				return(0);
  			c = iov->iov_len;
  			break;
*** /usr/src/sys/pdp/trap.c.old	Mon Aug 23 19:06:46 1993
--- /usr/src/sys/pdp/trap.c	Sat Nov 26 15:05:33 1994
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)trap.c	1.3 (2.11BSD GTE) 8/23/93
   */
  
  #include "param.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)trap.c	1.4 (2.11BSD GTE) 11/24/94
   */
  
  #include "param.h"
***************
*** 42,48 ****
   * the various FPE_... codes defined in <signal.h>.  On the VAX these come
   * free because those *are* the codes the VAX FP hardware generates.
   */
! static int	pdpfec[16] = {
  	FPE_CRAZY,		/*  0: not a legal FEC code */
  	FPE_CRAZY,		/*  1: not a legal FEC code */
  	FPE_OPCODE_TRAP,	/*  2: bad floating point op code */
--- 42,48 ----
   * the various FPE_... codes defined in <signal.h>.  On the VAX these come
   * free because those *are* the codes the VAX FP hardware generates.
   */
! static	u_char pdpfec[16] = {
  	FPE_CRAZY,		/*  0: not a legal FEC code */
  	FPE_CRAZY,		/*  1: not a legal FEC code */
  	FPE_OPCODE_TRAP,	/*  2: bad floating point op code */
