Subject: chflags - immutable|appendonly files come to 2BSD (#201 - Part 5 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 5 of 14 (#201). Files affected by this part are: /usr/src/sys/sys/tty.c /usr/src/sys/sys/tty_conf.c /usr/src/sys/sys/tty_pty.c /usr/src/sys/sys/tty_tb.c /usr/src/sys/sys/tty_tty.c /usr/src/sys/sys/ufs_fio.c /usr/src/sys/sys/ufs_inode.c /usr/src/sys/sys/ufs_namei.c /usr/src/sys/sys/ufs_syscalls.c /usr/src/sys/sys/uipc_socket.c /usr/src/sys/sys/uipc_syscalls.c /usr/src/sys/sys/vm_swp.c /usr/src/sys/sys/vm_text.c =====================cut here======================== *** /usr/src/sys/sys/tty.c.old Fri Dec 31 23:26:58 1993 --- /usr/src/sys/sys/tty.c Thu Dec 8 22:44:34 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)tty.c 1.3 (2.11BSD GTE) 12/31/93 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)tty.c 1.4 (2.11BSD GTE) 12/8/94 */ #include "param.h" *************** *** 17,22 **** --- 17,23 ---- #include "uio.h" #include "kernel.h" #include "systm.h" + #include "inode.h" /* * Table giving parity for characters and indicating *************** *** 68,100 **** 0007,0007,0007,0007,0007,0007,0007,0007 }; - #ifdef whybother - /* - * Input mapping table-- if an entry is non-zero, when the - * corresponding character is typed preceded by "\" the escape - * sequence is replaced by the table value. Mostly used for - * upper-case only terminals. - */ - char maptab[] ={ - 000,000,000,000,000,000,000,000, - 000,000,000,000,000,000,000,000, - 000,000,000,000,000,000,000,000, - 000,000,000,000,000,000,000,000, - 000,'|',000,000,000,000,000,'`', - '{','}',000,000,000,000,000,000, - 000,000,000,000,000,000,000,000, - 000,000,000,000,000,000,000,000, - 000,000,000,000,000,000,000,000, - 000,000,000,000,000,000,000,000, - 000,000,000,000,000,000,000,000, - 000,000,000,000,000,000,'~',000, - 000,'A','B','C','D','E','F','G', - 'H','I','J','K','L','M','N','O', - 'P','Q','R','S','T','U','V','W', - 'X','Y','Z',000,000,000,000,000, - }; - #endif - short tthiwat[16] = { 100,100,100,100,100,100,100,200,200,400,400,400,650,650,1300,2000 }; short ttlowat[16] = --- 69,74 ---- *************** *** 205,212 **** --- 179,188 ---- register struct tty *tp; { + #ifdef DIAGNOSTIC if (tp == 0) panic("ttrstrt"); + #endif tp->t_state &= ~TS_TIMEOUT; ttstart(tp); } *************** *** 237,242 **** --- 213,219 ---- register struct tty *tp; u_int com; caddr_t data; + int flag; { int dev = tp->t_dev; extern int nldisp; *************** *** 291,297 **** return (ENXIO); if (t != tp->t_line) { s = spltty(); ! (*linesw[tp->t_line].l_close)(tp); error = (*linesw[t].l_open)(dev, tp); if (error) { (void) (*linesw[tp->t_line].l_open)(dev, tp); --- 268,274 ---- return (ENXIO); if (t != tp->t_line) { s = spltty(); ! (*linesw[tp->t_line].l_close)(tp, flag); error = (*linesw[t].l_open)(dev, tp); if (error) { (void) (*linesw[tp->t_line].l_open)(dev, tp); *************** *** 417,427 **** } case FIONBIO: ! if (*(int *)data) ! tp->t_state |= TS_NBIO; ! else ! tp->t_state &= ~TS_NBIO; ! break; case FIOASYNC: if (*(int *)data) --- 394,400 ---- } case FIONBIO: ! break; /* XXX remove */ case FIOASYNC: if (*(int *)data) *************** *** 595,605 **** /* * "close" a line discipline */ ! ttylclose(tp) register struct tty *tp; { ! ttywflush(tp); tp->t_line = 0; } --- 568,587 ---- /* * "close" a line discipline */ ! ttylclose(tp, flag) register struct tty *tp; { ! /* ! * 4.4 has IO_NDELAY but I think that is a mistake because the upper level ! * 'close' routines all pass 'fp->f_flags' down. This was verified with a ! * printf here - the F* flags are received rather than the IO_* flags! ! */ ! ! if (flag & FNDELAY) ! ttyflush(tp, FREAD|FWRITE); ! else ! ttywflush(tp); tp->t_line = 0; } *************** *** 815,848 **** goto endcase; } - if (tp->t_flags & LCASE && c <= 0177) { - if (tp->t_state&TS_BKSL) { - ttyrub(unputc(&tp->t_rawq), tp); - #ifdef whybother - if (maptab[c]) - c = maptab[c]; - #else - if (c == '\047') - c = '`'; - else if (c == '!') - c = '|'; - else if (c == '(') - c = '{'; - else if (c == ')') - c = '}'; - else if (c == '^') - c = '~'; - else if (c >= 'a' && c <= 'z') - c &= ~040; - #endif - c |= 0200; - tp->t_state &= ~(TS_BKSL|TS_QUOT); - } else if (c >= 'A' && c <= 'Z') - c += 'a' - 'A'; - else if (c == '\\') - tp->t_state |= TS_BKSL; - } - /* * Cbreak mode, don't process line editing * characters; check high water mark for wakeup. --- 797,802 ---- *************** *** 1028,1060 **** tk_nout++; #endif /* - * for upper-case-only terminals, - * generate escapes. - */ - if (tp->t_flags&LCASE) { - colp = "({)}!|^~'`"; - while (*colp++) - if (c == *colp++) { - if (ttyoutput('\\', tp) >= 0) - return (c); - c = colp[-2]; - break; - } - if ('A' <= c && c <= 'Z') { - if (ttyoutput('\\', tp) >= 0) - return (c); - } else if ('a' <= c && c <= 'z') - c += 'A' - 'a'; - } - - /* * turn to if desired. */ if (c == '\n' && tp->t_flags&CRMOD) if (ttyoutput('\r', tp) >= 0) return (c); - if (c == '~' && tp->t_flags&TILDE) - c = '`'; if ((tp->t_flags&FLUSHO) == 0 && putc(c, &tp->t_outq)) return (c); /* --- 982,992 ---- *************** *** 1143,1149 **** * 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; { --- 1075,1081 ---- * Called from device's read routine after it has * calculated the tty-structure given as argument. */ ! ttread(tp, uio, flag) register struct tty *tp; struct uio *uio; { *************** *** 1187,1193 **** s = spltty(); if (tp->t_rawq.c_cc <= 0) { if ((tp->t_state&TS_CARR_ON) == 0 || ! (tp->t_state&TS_NBIO)) { splx(s); return (EWOULDBLOCK); } --- 1119,1125 ---- s = spltty(); if (tp->t_rawq.c_cc <= 0) { if ((tp->t_state&TS_CARR_ON) == 0 || ! (flag & IO_NDELAY)) { splx(s); return (EWOULDBLOCK); } *************** *** 1213,1220 **** */ s = spltty(); if (qp->c_cc <= 0) { ! if ((tp->t_state&TS_CARR_ON) == 0 || ! (tp->t_state&TS_NBIO)) { splx(s); return (EWOULDBLOCK); } --- 1145,1151 ---- */ s = spltty(); if (qp->c_cc <= 0) { ! if ((tp->t_state&TS_CARR_ON) == 0 || (flag & IO_NDELAY)) { splx(s); return (EWOULDBLOCK); } *************** *** 1317,1323 **** * 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; { --- 1248,1254 ---- * Called from the device's write routine after it has * calculated the tty-structure given as argument. */ ! ttwrite(tp, uio, flag) register struct tty *tp; register struct uio *uio; { *************** *** 1329,1337 **** hiwat = TTHIWAT(tp); cnt = uio->uio_resid; error = 0; loop: ! if ((tp->t_state&TS_CARR_ON) == 0) ! return (EIO); /* * Hang the process if it's in the background. */ --- 1260,1283 ---- hiwat = TTHIWAT(tp); cnt = uio->uio_resid; error = 0; + cc = 0; loop: ! s = spltty(); ! if (!(tp->t_state&TS_CARR_ON)) { ! if (tp->t_state & TS_ISOPEN) { ! splx(s); ! return(EIO); ! } else if (flag & IO_NDELAY) { ! splx(s); ! error = EWOULDBLOCK; ! goto out; ! } else { ! /* Sleep awaiting carrier. */ ! sleep((caddr_t)&tp->t_rawq, TTIPRI); ! goto loop; ! } ! } ! splx(s); /* * Hang the process if it's in the background. */ *************** *** 1351,1405 **** * 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) goto ovhiwat; - if (tp->t_flags&FLUSHO) - continue; /* ! * If we're mapping lower case or kludging tildes, ! * then we've got to look at each character, so ! * just feed the stuff to ttyoutput... ! */ ! if (tp->t_flags & (LCASE|TILDE)) { ! while (cc > 0) { ! c = *cp++; ! tp->t_rocount = 0; ! while ((c = ttyoutput(c, tp)) >= 0) { ! /* out of clists, wait a bit */ ! ttstart(tp); ! 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; ! } ! --cc; ! if (tp->t_outq.c_cc > hiwat) ! goto ovhiwat; } - continue; } /* * If nothing fancy need be done, grab those characters we --- 1297,1321 ---- * mark, sleep on overflow awaiting device aid * in acquiring new space. */ ! while (uio->uio_resid || cc > 0) { ! if (tp->t_flags&FLUSHO) { ! uio->uio_resid = 0; ! return(0); } if (tp->t_outq.c_cc > hiwat) goto ovhiwat; /* ! * Grab a hunk of data from the user, unless we have some ! * leftover from last time. ! */ ! if (cc == 0) { ! cc = MIN(uio->uio_resid, OBUFSIZ); ! cp = obuf; ! error = uiomove(cp, cc, uio); ! if (error) { ! cc = 0; ! break; } } /* * If nothing fancy need be done, grab those characters we *************** *** 1426,1437 **** /* no c-lists, wait a bit */ 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; } cp++, cc--; --- 1342,1347 ---- *************** *** 1461,1490 **** /* 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) ! goto ovhiwat; ! } ! } ! ttstart(tp); return (error); 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 ! * is also set in t_flags. */ if (tp->t_outq.c_cc <= hiwat) { splx(s); --- 1371,1397 ---- /* out of c-lists, wait a bit */ ttstart(tp); sleep((caddr_t)&lbolt, TTOPRI); goto loop; } if (tp->t_flags&FLUSHO || tp->t_outq.c_cc > hiwat) ! break; ! } /* while (cc > 0) */ ! ttstart(tp); ! } /* while (uio->uio_resid || cc > 0) */ ! out: ! /* ! * If cc is nonzero, we leave the uio structure inconsistent, as the ! * offset and iov pointers have moved forward, but it doesn't matter ! * (the call will either return short or restart with a new uio). ! */ ! uio->uio_resid += cc; return (error); ovhiwat: s = spltty(); /* ! * This can only occur if FLUSHO is also set in t_flags, ! * or if ttstart/oproc is synchronous (or very fast). */ if (tp->t_outq.c_cc <= hiwat) { splx(s); *************** *** 1491,1501 **** goto loop; } ttstart(tp); ! if (tp->t_state&TS_NBIO) { splx(s); ! if (uio->uio_resid == cnt) ! return (EWOULDBLOCK); ! return (0); } tp->t_state |= TS_ASLEEP; sleep((caddr_t)&tp->t_outq, TTOPRI); --- 1398,1407 ---- goto loop; } ttstart(tp); ! if (flag & IO_NDELAY) { splx(s); ! uio->uio_resid += cc; ! return (uio->uio_resid == cnt ? EWOULDBLOCK : 0); } tp->t_state |= TS_ASLEEP; sleep((caddr_t)&tp->t_outq, TTOPRI); *************** *** 1533,1542 **** else switch (partab[c&=0177]&0177) { case ORDINARY: ! if (tp->t_flags&LCASE && c >= 'A' && c <= 'Z') ! ttyrubo(tp, 2); ! else ! ttyrubo(tp, 1); break; case VTAB: --- 1439,1445 ---- else switch (partab[c&=0177]&0177) { case ORDINARY: ! ttyrubo(tp, 1); break; case VTAB: *************** *** 1678,1685 **** c &= 0177; if (c == 0177) c = '?'; - else if (tp->t_flags&LCASE) - c += 'a' - 1; else c += 'A' - 1; } --- 1581,1586 ---- *** /usr/src/sys/sys/tty_conf.c.old Tue Jul 5 16:20:12 1988 --- /usr/src/sys/sys/tty_conf.c Thu Dec 15 20:06:55 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)tty_conf.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. * ! * @(#)tty_conf.c 1.2 (2.11BSD GTE) 11/30/94 */ #include "param.h" *************** *** 102,109 **** return(error); } ! SLCLOSE(tp) struct tty *tp; { int slclose(); --- 102,110 ---- return(error); } ! SLCLOSE(tp, flag) struct tty *tp; + int flag; { int slclose(); *** /usr/src/sys/sys/tty_pty.c.old Wed Apr 11 09:49:18 1990 --- /usr/src/sys/sys/tty_pty.c Thu Dec 8 20:21:57 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)tty_pty.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. * ! * @(#)tty_pty.c 1.2 (2.11BSD GTE) 12/8/94 */ /* *************** *** 23,32 **** #include "proc.h" #include "uio.h" #include "kernel.h" #if NPTY == 1 #undef NPTY ! #define NPTY 32 /* crude XXX */ #endif #define BUFSIZ 100 /* Chunk size iomoved to/from user */ --- 23,33 ---- #include "proc.h" #include "uio.h" #include "kernel.h" + #include "inode.h" #if NPTY == 1 #undef NPTY ! #define NPTY 16 /* crude XXX */ #endif #define BUFSIZ 100 /* Chunk size iomoved to/from user */ *************** *** 46,52 **** #define PF_RCOLL 0x01 #define PF_WCOLL 0x02 - #define PF_NBIO 0x04 #define PF_PKT 0x08 /* packet mode */ #define PF_STOPPED 0x10 /* user told stopped */ #define PF_REMOTE 0x20 /* remote and flow controlled input */ --- 47,52 ---- *************** *** 83,102 **** return (error); } ! ptsclose(dev) dev_t dev; { register struct tty *tp; tp = &pt_tty[minor(dev)]; ! (*linesw[tp->t_line].l_close)(tp); ttyclose(tp); 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)]; --- 83,104 ---- return (error); } ! ptsclose(dev, flag) dev_t dev; + int flag; { register struct tty *tp; tp = &pt_tty[minor(dev)]; ! (*linesw[tp->t_line].l_close)(tp, flag); ttyclose(tp); ptcwakeup(tp, FREAD|FWRITE); } ! ptsread(dev, uio, flag) dev_t dev; register struct uio *uio; + int flag; { register struct tty *tp = &pt_tty[minor(dev)]; register struct pt_ioctl *pti = &pt_ioctl[minor(dev)]; *************** *** 113,119 **** sleep((caddr_t)&lbolt, TTIPRI); } if (tp->t_canq.c_cc == 0) { ! if (tp->t_state & TS_NBIO) return (EWOULDBLOCK); sleep((caddr_t)&tp->t_canq, TTIPRI); goto again; --- 115,121 ---- sleep((caddr_t)&lbolt, TTIPRI); } if (tp->t_canq.c_cc == 0) { ! if (flag & IO_NDELAY) return (EWOULDBLOCK); sleep((caddr_t)&tp->t_canq, TTIPRI); goto again; *************** *** 129,135 **** return (error); } else if (tp->t_oproc) ! error = (*linesw[tp->t_line].l_read)(tp, uio); ptcwakeup(tp, FWRITE); return (error); } --- 131,137 ---- return (error); } else if (tp->t_oproc) ! error = (*linesw[tp->t_line].l_read)(tp, uio, flag); ptcwakeup(tp, FWRITE); return (error); } *************** *** 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; --- 141,150 ---- * Wakeups of controlling tty will happen * indirectly, when tty driver calls ptsstart. */ ! ptswrite(dev, uio, flag) dev_t dev; register struct uio *uio; + int flag; { register struct tty *tp; *************** *** 148,154 **** tp = &pt_tty[minor(dev)]; if (tp->t_oproc == 0) return (EIO); ! return ((*linesw[tp->t_line].l_write)(tp, uio)); } /* --- 151,157 ---- tp = &pt_tty[minor(dev)]; if (tp->t_oproc == 0) return (EIO); ! return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); } /* *************** *** 214,221 **** return (0); } ! ptcclose(dev) dev_t dev; { register struct tty *tp; --- 217,225 ---- return (0); } ! ptcclose(dev, flag) dev_t dev; + int flag; { register struct tty *tp; *************** *** 225,233 **** 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)]; --- 229,238 ---- tp->t_oproc = 0; /* mark closed */ } ! ptcread(dev, uio, flag) dev_t dev; register struct uio *uio; + int flag; { register struct tty *tp = &pt_tty[minor(dev)]; struct pt_ioctl *pti = &pt_ioctl[minor(dev)]; *************** *** 260,267 **** break; } if ((tp->t_state&TS_CARR_ON) == 0) ! return (EIO); ! if (pti->pt_flags&PF_NBIO) return (EWOULDBLOCK); sleep((caddr_t)&tp->t_outq.c_cf, TTIPRI); } --- 265,272 ---- break; } if ((tp->t_state&TS_CARR_ON) == 0) ! return (0); /* EOF */ ! if (flag & IO_NDELAY) return (EWOULDBLOCK); sleep((caddr_t)&tp->t_outq.c_cf, TTIPRI); } *************** *** 271,277 **** 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) { --- 276,282 ---- cc = q_to_b(&tp->t_outq, buf, MIN(uio->uio_resid, BUFSIZ)); if (cc <= 0) break; ! error = uiomove(buf, cc, uio); } if (tp->t_outq.c_cc <= TTLOWAT(tp)) { if (tp->t_state&TS_ASLEEP) { *************** *** 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]; --- 376,387 ---- return (0); } ! ptcwrite(dev, uio, flag) dev_t dev; register struct uio *uio; + int flag; { register struct tty *tp = &pt_tty[minor(dev)]; register char *cp; register int cc = 0; char locbuf[BUFSIZ]; *************** *** 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 */ --- 395,406 ---- if (pti->pt_flags & PF_REMOTE) { if (tp->t_canq.c_cc) goto block; ! while (uio->uio_resid && tp->t_canq.c_cc < TTYHOG - 1) { if (cc == 0) { ! cc = MIN(uio->uio_resid, BUFSIZ); cc = MIN(cc, TTYHOG - 1 - tp->t_canq.c_cc); cp = locbuf; ! error = uiomove(cp, cc, uio); 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 */ --- 416,426 ---- wakeup((caddr_t)&tp->t_canq); return (0); } ! while (uio->uio_resid > 0) { if (cc == 0) { ! cc = MIN(uio->uio_resid, BUFSIZ); cp = locbuf; ! error = uiomove(cp, cc, uio); if (error) return (error); /* check again for safety */ *************** *** 455,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); --- 448,456 ---- */ if ((tp->t_state&TS_CARR_ON) == 0) return (EIO); ! if (flag & IO_NDELAY) { ! /* adjust for data copied in but not written */ uio->uio_resid += cc; if (cnt == 0) return (EWOULDBLOCK); return (0); *************** *** 473,478 **** --- 464,470 ---- caddr_t data; u_int cmd; dev_t dev; + int flag; { register struct tty *tp = &pt_tty[minor(dev)]; register struct pt_ioctl *pti = &pt_ioctl[minor(dev)]; *************** *** 512,524 **** ttyflush(tp, FREAD|FWRITE); return (0); - case FIONBIO: - if (*(int *)data) - pti->pt_flags |= PF_NBIO; - else - pti->pt_flags &= ~PF_NBIO; - return (0); - case TIOCSETP: case TIOCSETN: case TIOCSETD: --- 504,509 ---- *************** *** 526,531 **** --- 511,526 ---- ; break; } + /* + * Unsure if the comment below still applies or not. For now put the + * new code in ifdef'd out. + */ + + #ifdef four_four_bsd + error = (*linesw[t->t_line].l_ioctl(tp, cmd, data, flag); + if (error < 0) + error = ttioctl(tp, cmd, data, flag); + #else error = ttioctl(tp, cmd, data, flag); /* * Since we use the tty queues internally, *************** *** 534,544 **** * from here... */ if (linesw[tp->t_line].l_rint != ttyinput) { ! (*linesw[tp->t_line].l_close)(tp); tp->t_line = 0; (void)(*linesw[tp->t_line].l_open)(dev, tp); error = ENOTTY; } if (error < 0) { if (pti->pt_flags & PF_UCNTL && (cmd & ~0xff) == UIOCCMD(0)) { --- 529,540 ---- * from here... */ if (linesw[tp->t_line].l_rint != ttyinput) { ! (*linesw[tp->t_line].l_close)(tp, flag); tp->t_line = 0; (void)(*linesw[tp->t_line].l_open)(dev, tp); error = ENOTTY; } + #endif if (error < 0) { if (pti->pt_flags & PF_UCNTL && (cmd & ~0xff) == UIOCCMD(0)) { *** /usr/src/sys/sys/tty_tb.c.old Sat Apr 7 21:42:00 1990 --- /usr/src/sys/sys/tty_tb.c Wed Nov 30 21:43:08 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)tty_tb.c 1.1 (2.10BSD Berkeley) 12/1/86 */ #include "tb.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)tty_tb.c 1.2 (2.11BSD GTE) 11/29/94 */ #include "tb.h" *************** *** 99,106 **** /* * Line discipline change or last device close. */ ! tbclose(tp) register struct tty *tp; { register int s; int modebits = TBPOINT|TBSTOP; --- 99,107 ---- /* * Line discipline change or last device close. */ ! tbclose(tp, flag) register struct tty *tp; + int flag; { register int s; int modebits = TBPOINT|TBSTOP; *************** *** 120,126 **** * Read from a tablet line. * Characters have been buffered in a buffer and decoded. */ ! tbread(tp, uio) register struct tty *tp; struct uio *uio; { --- 121,127 ---- * Read from a tablet line. * Characters have been buffered in a buffer and decoded. */ ! tbread(tp, uio, flag) register struct tty *tp; struct uio *uio; { *************** *** 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); --- 131,137 ---- if ((tp->t_state&TS_CARR_ON) == 0) return (EIO); ! ret = uiomove(&tbp->rets, tc->tbc_uiosize, uio); if (tc->tbc_flags&TBF_POL) tbp->rets.polpos.p_key = ' '; return (ret); *** /usr/src/sys/sys/tty_tty.c.old Sat Apr 7 21:27:51 1990 --- /usr/src/sys/sys/tty_tty.c Tue Nov 29 20:35:33 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)tty_tty.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. * ! * @(#)tty_tty.c 1.2 (2.11BSD GTE) 11/29/94 */ /* *************** *** 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*/ --- 28,51 ---- } /*ARGSUSED*/ ! syread(dev, uio, flag) dev_t dev; struct uio *uio; + int flag; { if (u.u_ttyp == NULL) return (ENXIO); ! return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd, uio, flag)); } /*ARGSUSED*/ ! sywrite(dev, uio, flag) 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, flag)); } /*ARGSUSED*/ *** /usr/src/sys/sys/ufs_fio.c.old Sat Apr 7 18:11:43 1990 --- /usr/src/sys/sys/ufs_fio.c Thu Dec 15 20:10:01 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_fio.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. * ! * @(#)ufs_fio.c 1.2 (2.11BSD GTE) 12/15/94 */ #include "param.h" *************** *** 13,19 **** --- 13,22 ---- #include "namei.h" #include "systm.h" #include "acct.h" + #include "stat.h" + extern int securelevel; + /* * Check mode permission on inode pointer. * Mode is READ, WRITE or EXEC. *************** *** 36,41 **** --- 39,48 ---- m = mode; if (m == IWRITE) { + if (ip->i_flags & IMMUTABLE) { + u.u_error = EPERM; + return(1); + } /* * Disallow write attempts on read-only * file systems; unless the file is a block *************** *** 92,127 **** return (1); } - /* - * Look up a pathname and test if - * the resultant inode is owned by the - * current user. - * If not, try for super-user. - * If permission is granted, - * return inode pointer. - */ - struct inode * - owner(fname, follow) - caddr_t fname; - 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) - return (ip); - if (suser()) - return (ip); - iput(ip); - return (NULL); - } - /* copied, for supervisory networking, to sys_net.c */ /* * Test if the current user is the --- 99,104 ---- *************** *** 137,139 **** --- 114,190 ---- u.u_error = EPERM; return (0); } + + /* + * Set the attributes on a file. This was placed here because ufs_syscalls + * is too large already (it will probably be split into two files eventually). + */ + + ufs_setattr(ip, vap) + register struct inode *ip; + register struct vattr *vap; + { + int error; + struct timeval atimeval, mtimeval; + + if (ip->i_fs->fs_ronly) /* can't change anything on a RO fs */ + return(EROFS); + if (vap->va_flags != VNOVAL) + { + if (u.u_uid != ip->i_uid && !suser()) + return(u.u_error); + if (u.u_uid == 0) + { + #ifdef not_quite_yet + if ((ip->i_flags & (SF_IMMUTABLE|SF_APPEND))) && + securelevel > 0) + return(EPERM); + #endif + ip->i_flags = vap->va_flags; + } + else + { + if (ip->i_flags & (SF_IMMUTABLE|SF_APPEND)) + return(EPERM); + ip->i_flags &= SF_SETTABLE; + ip->i_flags |= (vap->va_flags & UF_SETTABLE); + } + ip->i_flag |= ICHG; + if (vap->va_flags & (IMMUTABLE|APPEND)) + return(0); + } + if (ip->i_flags & (IMMUTABLE|APPEND)) + return(EPERM); + /* + * Go thru the fields (other than 'flags') and update iff not VNOVAL. + */ + if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) + if (error = chown1(ip, vap->va_uid, vap->va_gid)) + return(error); + if (vap->va_size != (off_t)VNOVAL) + { + if ((ip->i_mode & IFMT) == IFDIR) + return(EISDIR); + itrunc(ip, vap->va_size); + if (u.u_error) + return(u.u_error); + } + if (vap->va_atime != (time_t)VNOVAL || + vap->va_mtime != (time_t)VNOVAL) + { + if (u.u_uid != ip->i_uid && !suser() && + ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || + access(ip, IWRITE))) + return(u.u_error); + if (vap->va_atime != (time_t)VNOVAL) + ip->i_flag |= IACC; + if (vap->va_mtime != (time_t)VNOVAL) + ip->i_flag |= (IUPD|ICHG); + atimeval.tv_sec = vap->va_atime; + mtimeval.tv_sec = vap->va_mtime; + iupdat(ip, &atimeval, &mtimeval, 1); + } + if (vap->va_mode != (mode_t)VNOVAL) + return(chmod1(ip, vap->va_mode)); + return(0); + } *** /usr/src/sys/sys/ufs_inode.c.old Fri Dec 31 23:29:31 1993 --- /usr/src/sys/sys/ufs_inode.c Mon Nov 28 20:33:32 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_inode.c 1.3 (2.11BSD GTE) 12/31/93 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_inode.c 1.4 (2.11BSD GTE) 11/26/94 */ #include "param.h" *************** *** 109,114 **** --- 109,117 ---- #ifdef EXTERNALITIMES struct icommon2 xic2; #endif + #ifdef QUOTA + struct dquot **xdq; + #endif loop: ih = &ihead[INOHASH(dev, ino)]; *************** *** 188,194 **** ip->i_lastr = 0; #ifdef QUOTA QUOTAMAP(); ! dqrele(ix_dquot[ip - inode]); QUOTAUNMAP(); #endif bp = bread(dev, itod(ino)); --- 191,198 ---- ip->i_lastr = 0; #ifdef QUOTA QUOTAMAP(); ! xdq = &ix_dquot[ip - inode]; ! dqrele(*xdq); QUOTAUNMAP(); #endif bp = bread(dev, itod(ino)); *************** *** 214,220 **** ip->i_number = 0; #ifdef QUOTA QUOTAMAP(); ! ix_dquot[ip - inode] = NODQUOT; QUOTAUNMAP(); #endif iput(ip); --- 218,224 ---- ip->i_number = 0; #ifdef QUOTA QUOTAMAP(); ! *xdq = NODQUOT; QUOTAUNMAP(); #endif iput(ip); *************** *** 223,228 **** --- 227,233 ---- dp = (struct dinode *)mapin(bp); dp += itoo(ino); ip->i_ic1 = dp->di_ic1; + ip->i_flags = dp->di_flags; #ifdef EXTERNALITIMES xic2 = dp->di_ic2; #else *************** *** 239,247 **** #ifdef QUOTA QUOTAMAP(); if (ip->i_mode == 0) ! ix_dquot[ip - inode] = NODQUOT; else ! ix_dquot[ip - inode] = inoquota(ip); QUOTAUNMAP(); #endif return (ip); --- 244,252 ---- #ifdef QUOTA QUOTAMAP(); if (ip->i_mode == 0) ! *xdq = NODQUOT; else ! *xdq = inoquota(ip); QUOTAUNMAP(); #endif return (ip); *************** *** 398,403 **** --- 403,409 ---- tip->i_flag &= ~(IUPD|IACC|ICHG|IMOD); dp = (struct dinode *)mapin(bp) + itoo(tip->i_number); dp->di_ic1 = tip->i_ic1; + dp->di_flags = tip->i_flags; #ifdef EXTERNALITIMES dp->di_ic2 = xic2; #else *************** *** 692,698 **** * to scan the inode table here anyway, we might as well get the * extra benefit. * ! * this is called from sumount()/sys3.c when dev is being unmounted */ #ifdef QUOTA iflush(dev, iq) --- 698,704 ---- * to scan the inode table here anyway, we might as well get the * extra benefit. * ! * this is called from sumount() when dev is being unmounted */ #ifdef QUOTA iflush(dev, iq) *************** *** 703,709 **** dev_t dev; { register struct inode *ip; ! register open = 0; for (ip = inode; ip < inodeNINODE; ip++) { #ifdef QUOTA --- 709,715 ---- dev_t dev; { register struct inode *ip; ! register int open = 0; for (ip = inode; ip < inodeNINODE; ip++) { #ifdef QUOTA *** /usr/src/sys/sys/ufs_namei.c.old Mon Aug 19 14:47:46 1991 --- /usr/src/sys/sys/ufs_namei.c Sat Nov 26 23:26:42 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_namei.c 1.2 (Berkeley) 1/26/90 */ #include "param.h" #include "../machine/seg.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_namei.c 1.3 (2.11BSD GTE) 11/26/94 */ #include "param.h" #include "../machine/seg.h" *************** *** 906,912 **** panic("wdir: newblk"); ndp->ni_dent.d_reclen = DIRBLKSIZ; error = rdwri(UIO_WRITE, dp, (caddr_t)&ndp->ni_dent, ! newentrysize, ndp->ni_offset, 1, (int *)0); dp->i_size = roundup(dp->i_size, DIRBLKSIZ); iput(dp); return (error); --- 906,913 ---- panic("wdir: newblk"); ndp->ni_dent.d_reclen = DIRBLKSIZ; error = rdwri(UIO_WRITE, dp, (caddr_t)&ndp->ni_dent, ! newentrysize, ndp->ni_offset, UIO_SYSSPACE, ! IO_UNIT|IO_SYNC, (int *)0); dp->i_size = roundup(dp->i_size, DIRBLKSIZ); iput(dp); return (error); *************** *** 1013,1019 **** */ ndp->ni_dent.d_ino = 0; (void) rdwri(UIO_WRITE, dp, (caddr_t)&ndp->ni_dent, ! (int)DIRSIZ(&ndp->ni_dent), ndp->ni_offset, 1, (int *)0); } else { /* * Collapse new free space into previous entry. --- 1014,1021 ---- */ ndp->ni_dent.d_ino = 0; (void) rdwri(UIO_WRITE, dp, (caddr_t)&ndp->ni_dent, ! (int)DIRSIZ(&ndp->ni_dent), ndp->ni_offset, ! UIO_SYSSPACE, IO_UNIT|IO_SYNC, (int *)0); } else { /* * Collapse new free space into previous entry. *************** *** 1042,1048 **** ndp->ni_dent.d_ino = ip->i_number; u.u_error = rdwri(UIO_WRITE, dp, (caddr_t)&ndp->ni_dent, ! (int)DIRSIZ(&ndp->ni_dent), ndp->ni_offset, 1, (int *)0); iput(dp); } --- 1044,1051 ---- ndp->ni_dent.d_ino = ip->i_number; u.u_error = rdwri(UIO_WRITE, dp, (caddr_t)&ndp->ni_dent, ! (int)DIRSIZ(&ndp->ni_dent), ndp->ni_offset, ! UIO_SYSSPACE, IO_UNIT|IO_SYNC, (int *)0); iput(dp); } *************** *** 1106,1112 **** for (off = 0; off < ip->i_size; off += dp->d_reclen) { error = rdwri(UIO_READ, ip, (caddr_t)dp, MINDIRSIZ, ! off, 1, &count); /* * Since we read MINDIRSIZ, residual must * be 0 unless we're at end of file. --- 1109,1115 ---- for (off = 0; off < ip->i_size; off += dp->d_reclen) { error = rdwri(UIO_READ, ip, (caddr_t)dp, MINDIRSIZ, ! off, UIO_SYSSPACE, IO_UNIT, &count); /* * Since we read MINDIRSIZ, residual must * be 0 unless we're at end of file. *************** *** 1164,1170 **** break; } error = rdwri(UIO_READ, ip, (caddr_t)&dirbuf, ! sizeof(struct dirtemplate), (off_t)0, 1, (int *)0); if (error != 0) break; if (dirbuf.dotdot_namlen != 2 || --- 1167,1174 ---- break; } error = rdwri(UIO_READ, ip, (caddr_t)&dirbuf, ! sizeof(struct dirtemplate), (off_t)0, ! UIO_SYSSPACE, IO_UNIT, (int *)0); if (error != 0) break; if (dirbuf.dotdot_namlen != 2 || *** /usr/src/sys/sys/ufs_syscalls.c.old Fri Apr 29 19:48:59 1994 --- /usr/src/sys/sys/ufs_syscalls.c Wed Dec 7 22:15:11 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_syscalls.c 1.4 (2.11BSD GTE) 4/29/94 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_syscalls.c 1.5 (2.11BSD GTE) 12/7/94 */ #include "param.h" *************** *** 19,24 **** --- 19,25 ---- #include "quota.h" #endif + static void copen(); static struct inode *getinode(); /* *************** *** 39,45 **** if ((ip = getinode(uap->fd)) == NULL) return; ! ILOCK(ip); if ((ip->i_mode & IFMT) != IFDIR) { u.u_error = ENOTDIR; goto bad; --- 40,46 ---- if ((ip = getinode(uap->fd)) == NULL) return; ! ilock(ip); if ((ip->i_mode & IFMT) != IFDIR) { u.u_error = ENOTDIR; goto bad; *************** *** 46,52 **** } if (access(ip, IEXEC)) goto bad; ! IUNLOCK(ip); ip->i_count++; irele(u.u_cdir); u.u_cdir = ip; --- 47,53 ---- } if (access(ip, IEXEC)) goto bad; ! iunlock(ip); ip->i_count++; irele(u.u_cdir); u.u_cdir = ip; *************** *** 90,96 **** } if (access(ip, IEXEC)) goto bad; ! IUNLOCK(ip); if (*ipp) irele(*ipp); *ipp = ip; --- 91,97 ---- } if (access(ip, IEXEC)) goto bad; ! iunlock(ip); if (*ipp) irele(*ipp); *ipp = ip; *************** *** 111,117 **** int crtmode; } *uap = (struct a *) u.u_ap; ! copen(uap->mode-FOPEN, uap->crtmode, uap->fname); } /* --- 112,118 ---- int crtmode; } *uap = (struct a *) u.u_ap; ! copen(uap->mode, uap->crtmode, uap->fname); } /* *************** *** 124,130 **** int fmode; } *uap = (struct a *)u.u_ap; ! copen(FWRITE|FCREAT|FTRUNC, uap->fmode, uap->fname); } /* --- 125,131 ---- int fmode; } *uap = (struct a *)u.u_ap; ! copen(O_WRONLY|O_CREAT|O_TRUNC, uap->fmode, uap->fname); } /* *************** *** 132,139 **** * Check permissions, allocate an open file structure, * and call the device open routine if any. */ copen(mode, arg, fname) ! register int mode; int arg; caddr_t fname; { --- 133,141 ---- * Check permissions, allocate an open file structure, * and call the device open routine if any. */ + static void copen(mode, arg, fname) ! int mode; int arg; caddr_t fname; { *************** *** 140,147 **** register struct inode *ip; register struct file *fp; register struct nameidata *ndp = &u.u_nd; ! int indx; fp = falloc(); if (fp == NULL) return; --- 142,150 ---- register struct inode *ip; register struct file *fp; register struct nameidata *ndp = &u.u_nd; ! int indx, type; + mode = FFLAGS(mode); /* convert from open to kernel flags */ fp = falloc(); if (fp == NULL) return; *************** *** 148,155 **** 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; --- 151,158 ---- indx = u.u_r.r_val1; ndp->ni_segflg = UIO_USERSPACE; ndp->ni_dirp = fname; ! if (mode & O_CREAT) { ! if (mode & O_EXCL) ndp->ni_nameiop = CREATE; else ndp->ni_nameiop = CREATE | FOLLOW; *************** *** 160,172 **** ip = maknode(arg&07777&(~ISVTX), ndp); if (ip == NULL) goto bad1; ! mode &= ~FTRUNC; } else { ! if (mode&FEXCL) { u.u_error = EEXIST; goto bad; } ! mode &= ~FCREAT; } } else { ndp->ni_nameiop = LOOKUP | FOLLOW; --- 163,175 ---- ip = maknode(arg&07777&(~ISVTX), ndp); if (ip == NULL) goto bad1; ! mode &= ~O_TRUNC; } else { ! if (mode & O_EXCL) { u.u_error = EEXIST; goto bad; } ! mode &= ~O_CREAT; } } else { ndp->ni_nameiop = LOOKUP | FOLLOW; *************** *** 178,188 **** u.u_error = EOPNOTSUPP; goto bad; } ! if ((mode&FCREAT) == 0) { if (mode&FREAD) if (access(ip, IREAD)) goto bad; ! if (mode&(FWRITE|FTRUNC)) { if (access(ip, IWRITE)) goto bad; if ((ip->i_mode&IFMT) == IFDIR) { --- 181,195 ---- u.u_error = EOPNOTSUPP; goto bad; } ! if ((ip->i_flags & APPEND) && (mode & (FWRITE|O_APPEND)) == FWRITE) { ! u.u_error = EPERM; ! goto bad; ! } ! if ((mode& O_CREAT) == 0) { if (mode&FREAD) if (access(ip, IREAD)) goto bad; ! if (mode&(FWRITE|O_TRUNC)) { if (access(ip, IWRITE)) goto bad; if ((ip->i_mode&IFMT) == IFDIR) { *************** *** 191,199 **** } } } ! if (mode&FTRUNC) itrunc(ip, (u_long)0); ! IUNLOCK(ip); fp->f_flag = mode&FMASK; fp->f_type = DTYPE_INODE; fp->f_data = (caddr_t)ip; --- 198,206 ---- } } } ! if (mode & O_TRUNC) itrunc(ip, (u_long)0); ! iunlock(ip); fp->f_flag = mode&FMASK; fp->f_type = DTYPE_INODE; fp->f_data = (caddr_t)ip; *************** *** 200,213 **** if (setjmp(&u.u_qsave)) { if (u.u_error == 0) u.u_error = EINTR; u.u_ofile[indx] = NULL; closef(fp); return; } u.u_error = openi(ip, mode); ! if (u.u_error == 0) ! return; ! ILOCK(ip); bad: iput(ip); bad1: --- 207,236 ---- if (setjmp(&u.u_qsave)) { if (u.u_error == 0) u.u_error = EINTR; + bad2: u.u_ofile[indx] = NULL; closef(fp); return; } u.u_error = openi(ip, mode); ! if (u.u_error == 0) { ! if (mode & O_EXLOCK) ! mode &= ~O_SHLOCK; ! type = 0; ! if (mode & O_SHLOCK) ! type |= LOCK_SH; ! if (mode & O_EXLOCK) ! type |= LOCK_EX; ! if (!type) ! return; ! if (mode & O_NONBLOCK) ! type |= LOCK_NB; ! u.u_error = ino_lock(fp, type); ! if (u.u_error == 0) ! return; ! goto bad2; ! } ! ilock(ip); bad: iput(ip); bad1: *************** *** 258,264 **** ip->i_flag |= IACC|IUPD|ICHG; } } - out: iput(ip); } --- 281,286 ---- *************** *** 285,290 **** --- 307,317 ---- iput(ip); return; } + if (ip->i_flags & (IMMUTABLE|APPEND)) { + u.u_error = EPERM; + iput(ip); + return; + } ip->i_nlink++; ip->i_flag |= ICHG; iupdat(ip, &time, &time, 1); *************** *** 324,331 **** char *linkname; } *uap = (struct a *)u.u_ap; register struct inode *ip; ! register char *tp; ! register c, nc; register struct nameidata *ndp = &u.u_nd; tp = uap->target; --- 351,358 ---- char *linkname; } *uap = (struct a *)u.u_ap; register struct inode *ip; ! char *tp; ! int c, nc; register struct nameidata *ndp = &u.u_nd; tp = uap->target; *************** *** 352,359 **** ip = maknode(IFLNK | 0777, ndp); if (ip == NULL) return; ! u.u_error = rdwri(UIO_WRITE, ip, uap->target, nc, (off_t)0, 0, ! (int *)0); /* handle u.u_error != 0 */ iput(ip); } --- 379,386 ---- ip = maknode(IFLNK | 0777, ndp); if (ip == NULL) return; ! u.u_error = rdwri(UIO_WRITE, ip, uap->target, nc, (off_t)0, ! UIO_USERSPACE, IO_UNIT, (int *)0); /* handle u.u_error != 0 */ iput(ip); } *************** *** 387,392 **** --- 414,423 ---- u.u_error = EBUSY; goto out; } + if ((ip->i_flags & (IMMUTABLE|APPEND)) || (dp->i_flags & APPEND)) { + u.u_error = EPERM; + goto out; + } if (ip->i_flag&ITEXT) xuntext(ip->i_text); /* try once to free text */ if (dirremove(ndp)) { *************** *** 413,419 **** int sbase; } *uap = (struct a *)u.u_ap; ! GETF(fp, uap->fd); if (fp->f_type != DTYPE_INODE) { u.u_error = ESPIPE; return; --- 444,451 ---- int sbase; } *uap = (struct a *)u.u_ap; ! if ((fp = getf(uap->fd)) == NULL) ! return; if (fp->f_type != DTYPE_INODE) { u.u_error = ESPIPE; return; *************** *** 539,546 **** u.u_error = EINVAL; goto out; } ! u.u_error = rdwri(UIO_READ, ip, uap->buf, uap->count, (off_t)0, 0, ! &resid); out: iput(ip); u.u_r.r_val1 = uap->count - resid; --- 571,578 ---- u.u_error = EINVAL; goto out; } ! u.u_error = rdwri(UIO_READ, ip, uap->buf, uap->count, (off_t)0, ! UIO_USERSPACE, IO_UNIT, &resid); out: iput(ip); u.u_r.r_val1 = uap->count - resid; *************** *** 547,552 **** --- 579,634 ---- } /* + * change flags of a file given pathname. + */ + chflags() + { + register struct inode *ip; + register struct a { + char *fname; + u_short flags; + } *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; + if ((ip = namei(ndp)) == NULL) + return; + u.u_error = chflags1(ip, uap->flags); + iput(ip); + } + + /* + * change flags of a file given file descriptor. + */ + fchflags() + { + register struct a { + int fd; + u_short flags; + } *uap = (struct a *)u.u_ap; + register struct inode *ip; + + if ((ip = getinode(uap->fd)) == NULL) + return; + ilock(ip); + u.u_error = chflags1(ip, uap->flags); + iunlock(ip); + } + + chflags1(ip, flags) + register struct inode *ip; + u_short flags; + { + struct vattr vattr; + + VATTR_NULL(&vattr); + vattr.va_flags = flags; + return(ufs_setattr(ip, &vattr)); + } + + /* * Change mode of a file given path name. */ chmod() *************** *** 556,565 **** char *fname; int fmode; } *uap = (struct a *)u.u_ap; ! if ((ip = owner(uap->fname, FOLLOW)) == NULL) return; ! u.u_error = chmod1(ip, uap->fmode); iput(ip); } --- 638,655 ---- char *fname; int fmode; } *uap = (struct a *)u.u_ap; + struct vattr vattr; + 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) return; ! VATTR_NULL(&vattr); ! vattr.va_mode = uap->fmode & 07777; ! u.u_error = ufs_setattr(ip, &vattr); iput(ip); } *************** *** 573,590 **** int fmode; } *uap = (struct a *)u.u_ap; register struct inode *ip; if ((ip = getinode(uap->fd)) == NULL) return; ! if (u.u_uid != ip->i_uid && !suser()) ! return; ! ILOCK(ip); ! u.u_error = chmod1(ip, uap->fmode); ! IUNLOCK(ip); } /* ! * Change the mode on a file. * Inode must be locked before calling. */ chmod1(ip, mode) --- 663,681 ---- int fmode; } *uap = (struct a *)u.u_ap; register struct inode *ip; + struct vattr vattr; if ((ip = getinode(uap->fd)) == NULL) return; ! ilock(ip); ! VATTR_NULL(&vattr); ! vattr.va_mode = uap->fmode & 07777; ! u.u_error = ufs_setattr(ip, &vattr); ! iunlock(ip); } /* ! * Change the mode on a file. This routine is called from ufs_setattr. * Inode must be locked before calling. */ chmod1(ip, mode) *************** *** 592,606 **** register int mode; { ! if (ip->i_fs->fs_ronly) ! return (EROFS); ! ip->i_mode &= ~07777; if (u.u_uid) { ! if ((ip->i_mode & IFMT) != IFDIR) ! mode &= ~ISVTX; ! if (!groupmember(ip->i_gid)) ! mode &= ~ISGID; } ip->i_mode |= mode&07777; ip->i_flag |= ICHG; if (ip->i_flag&ITEXT && (ip->i_mode&ISVTX)==0) --- 683,697 ---- register int mode; { ! if (u.u_uid != ip->i_uid && !suser()) ! return(u.u_error); if (u.u_uid) { ! if ((ip->i_mode & IFMT) != IFDIR && (mode & ISVTX)) ! return(EFTYPE); ! if (!groupmember(ip->i_gid) && (mode & ISGID)) ! return(EPERM); } + ip->i_mode &= ~07777; /* why? */ ip->i_mode |= mode&07777; ip->i_flag |= ICHG; if (ip->i_flag&ITEXT && (ip->i_mode&ISVTX)==0) *************** *** 620,625 **** --- 711,717 ---- int gid; } *uap = (struct a *)u.u_ap; register struct nameidata *ndp = &u.u_nd; + struct vattr vattr; ndp->ni_nameiop = LOOKUP | NOFOLLOW; ndp->ni_segflg = UIO_USERSPACE; *************** *** 627,633 **** ip = namei(ndp); if (ip == NULL) return; ! u.u_error = chown1(ip, uap->uid, uap->gid); iput(ip); } --- 719,728 ---- ip = namei(ndp); if (ip == NULL) return; ! VATTR_NULL(&vattr); ! vattr.va_uid = uap->uid; ! vattr.va_gid = uap->gid; ! u.u_error = ufs_setattr(ip, &vattr); iput(ip); } *************** *** 642,657 **** int gid; } *uap = (struct a *)u.u_ap; register struct inode *ip; if ((ip = getinode(uap->fd)) == NULL) return; ! ILOCK(ip); ! u.u_error = chown1(ip, uap->uid, uap->gid); ! IUNLOCK(ip); } /* ! * Perform chown operation on inode ip; * inode must be locked prior to call. */ chown1(ip, uid, gid) --- 737,756 ---- int gid; } *uap = (struct a *)u.u_ap; register struct inode *ip; + struct vattr vattr; if ((ip = getinode(uap->fd)) == NULL) return; ! ilock(ip); ! VATTR_NULL(&vattr); ! vattr.va_uid = uap->uid; ! vattr.va_gid = uap->gid; ! u.u_error = ufs_setattr(ip, &vattr); ! iunlock(ip); } /* ! * Perform chown operation on inode ip. This routine called from ufs_setattr. * inode must be locked prior to call. */ chown1(ip, uid, gid) *************** *** 658,668 **** register struct inode *ip; register int uid, gid; { #ifdef QUOTA long change; #endif - if (ip->i_fs->fs_ronly) - return (EROFS); if (uid == -1) uid = ip->i_uid; if (gid == -1) --- 757,767 ---- register struct inode *ip; register int uid, gid; { + int ouid, ogid; #ifdef QUOTA + struct dquot **xdq; long change; #endif if (uid == -1) uid = ip->i_uid; if (gid == -1) *************** *** 675,680 **** --- 774,781 ---- if ((u.u_uid != ip->i_uid || uid != ip->i_uid || !groupmember((gid_t)gid)) && !suser()) return (u.u_error); + ouid = ip->i_uid; + ogid = ip->i_gid; #ifdef QUOTA QUOTAMAP(); if (ip->i_uid == uid) *************** *** 683,704 **** change = ip->i_size; (void) chkdq(ip, -change, 1); (void) chkiq(ip->i_dev, ip, ip->i_uid, 1); ! dqrele(ix_dquot[ip - inode]); #endif ip->i_uid = uid; ip->i_gid = gid; - ip->i_flag |= ICHG; - if (u.u_ruid != 0) - ip->i_mode &= ~(ISUID|ISGID); #ifdef QUOTA ! ix_dquot[ip - inode] = inoquota(ip); (void) chkdq(ip, change, 1); (void) chkiq(ip->i_dev, (struct inode *)NULL, (uid_t)uid, 1); QUOTAUNMAP(); - return (u.u_error); /* should == 0 ALWAYS !! */ - #else - return (0); #endif } utimes() --- 784,807 ---- change = ip->i_size; (void) chkdq(ip, -change, 1); (void) chkiq(ip->i_dev, ip, ip->i_uid, 1); ! xdq = &ix_dquot[ip - inode]; ! dqrele(*xdq); #endif ip->i_uid = uid; ip->i_gid = gid; #ifdef QUOTA ! *xdq = inoquota(ip); (void) chkdq(ip, change, 1); (void) chkiq(ip->i_dev, (struct inode *)NULL, (uid_t)uid, 1); QUOTAUNMAP(); #endif + if (ouid != uid || ogid != gid) + ip->i_flag |= ICHG; + if (ouid != uid && u.u_uid != 0) + ip->i_mode &= ~ISUID; + if (ogid != gid && u.u_gid != 0) + ip->i_mode &= ~ISGID; + return (0); } utimes() *************** *** 708,727 **** struct timeval *tptr; } *uap = (struct a *)u.u_ap; register struct inode *ip; struct timeval tv[2]; ! if ((ip = owner(uap->fname, FOLLOW)) == NULL) return; ! if (ip->i_fs->fs_ronly) { ! u.u_error = EROFS; ! iput(ip); return; ! } ! u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)); ! if (u.u_error == 0) { ! ip->i_flag |= IACC|IUPD|ICHG; ! iupdat(ip, &tv[0], &tv[1], 0); ! } iput(ip); } --- 811,834 ---- struct timeval *tptr; } *uap = (struct a *)u.u_ap; register struct inode *ip; + register struct nameidata *ndp = &u.u_nd; struct timeval tv[2]; + struct vattr vattr; ! VATTR_NULL(&vattr); ! if (uap->tptr == NULL) { ! tv[0].tv_sec = tv[1].tv_sec = time.tv_sec; ! vattr.va_vaflags |= VA_UTIMES_NULL; ! } else if (u.u_error = copyin((caddr_t)uap->tptr,(caddr_t)tv,sizeof(tv))) return; ! ndp->ni_nameiop = LOOKUP|FOLLOW; ! ndp->ni_segflg = UIO_USERSPACE; ! ndp->ni_dirp = uap->fname; ! if ((ip = namei(ndp)) == NULL) return; ! vattr.va_atime = tv[0].tv_sec; ! vattr.va_mtime = tv[1].tv_sec; ! u.u_error = ufs_setattr(ip, &vattr); iput(ip); } *************** *** 745,750 **** --- 852,858 ---- } *uap = (struct a *)u.u_ap; register struct inode *ip; register struct nameidata *ndp = &u.u_nd; + struct vattr vattr; ndp->ni_nameiop = LOOKUP | FOLLOW; ndp->ni_segflg = UIO_USERSPACE; *************** *** 754,764 **** return; if (access(ip, IWRITE)) goto bad; ! if ((ip->i_mode&IFMT) == IFDIR) { ! u.u_error = EISDIR; ! goto bad; ! } ! itrunc(ip, (u_long)uap->length); bad: iput(ip); } --- 862,870 ---- return; if (access(ip, IWRITE)) goto bad; ! VATTR_NULL(&vattr); ! vattr.va_size = uap->length; ! u.u_error = ufs_setattr(ip, &vattr); bad: iput(ip); } *************** *** 774,779 **** --- 880,886 ---- } *uap = (struct a *)u.u_ap; register struct inode *ip; register struct file *fp; + struct vattr vattr; if ((fp = getf(uap->fd)) == NULL) return; *************** *** 783,789 **** } ip = (struct inode *)fp->f_data; ilock(ip); ! itrunc(ip, (u_long)uap->length); iunlock(ip); } --- 890,898 ---- } ip = (struct inode *)fp->f_data; ilock(ip); ! VATTR_NULL(&vattr); ! vattr.va_size = uap->length; ! u.u_error = ufs_setattr(ip, &vattr); iunlock(ip); } *************** *** 850,855 **** --- 959,978 ---- if (ip == NULL) return; dp = ndp->ni_pdir; + /* + * 'from' file can not be renamed if it is immutable/appendonly or if its + * parent directory is append only. + */ + if ((ip->i_flags & (IMMUTABLE|APPEND)) || (dp->i_flags & APPEND)) { + iput(dp); + if (dp == ip) + irele(ip); + else + iput(ip); + u.u_error = EPERM; + return; + } + if ((ip->i_mode&IFMT) == IFDIR) { register struct direct *d; *************** *** 883,889 **** ip->i_nlink++; ip->i_flag |= ICHG; iupdat(ip, &time, &time, 1); ! IUNLOCK(ip); /* * When the target exists, both the directory --- 1006,1012 ---- ip->i_nlink++; ip->i_flag |= ICHG; iupdat(ip, &time, &time, 1); ! iunlock(ip); /* * When the target exists, both the directory *************** *** 897,902 **** --- 1020,1035 ---- goto out; } dp = ndp->ni_pdir; + /* + * rename can not be done if 'to' file exists and is immutable/appendonly + * or if the directory is append only (this is because an existing 'to' + * has to be deleted first and that is illegal in an appendonly directory). + */ + if (xp && ((xp->i_flags & (IMMUTABLE|APPEND)) || (dp->i_flags & APPEND))) { + error = EPERM; + goto bad; + } + /* * If ".." must be changed (ie the directory gets a new * parent) then the source directory must not be in the *************** *** 1011,1017 **** xp->i_nlink--; if (doingdirectory) { if (--xp->i_nlink != 0) ! panic("rename: linked directory"); itrunc(xp, (u_long)0); } xp->i_flag |= ICHG; --- 1144,1150 ---- xp->i_nlink--; if (doingdirectory) { if (--xp->i_nlink != 0) ! panic("rename: lnk dir"); itrunc(xp, (u_long)0); } xp->i_flag |= ICHG; *************** *** 1054,1061 **** dp->i_nlink--; dp->i_flag |= ICHG; error = rdwri(UIO_READ, xp, (caddr_t)&dirbuf, ! sizeof(struct dirtemplate), (off_t)0, 1, ! (int *)0); if (error == 0) { if (dirbuf.dotdot_namlen != 2 || --- 1187,1194 ---- dp->i_nlink--; dp->i_flag |= ICHG; error = rdwri(UIO_READ, xp, (caddr_t)&dirbuf, ! sizeof(struct dirtemplate), (off_t)0, ! UIO_SYSSPACE, IO_UNIT, (int *)0); if (error == 0) { if (dirbuf.dotdot_namlen != 2 || *************** *** 1067,1073 **** (void) rdwri(UIO_WRITE, xp, (caddr_t)&dirbuf, sizeof(struct dirtemplate), ! (off_t)0, 1,(int *)0); cacheinval(dp); } } --- 1200,1207 ---- (void) rdwri(UIO_WRITE, xp, (caddr_t)&dirbuf, sizeof(struct dirtemplate), ! (off_t)0, UIO_SYSSPACE, ! IO_UNIT|IO_SYNC, (int *)0); cacheinval(dp); } } *************** *** 1112,1117 **** --- 1246,1254 ---- { register struct inode *ip; register struct inode *pdir = ndp->ni_pdir; + #ifdef QUOTA + struct dquot **xdq; + #endif ip = ialloc(pdir); if (ip == NULL) { *************** *** 1120,1127 **** } #ifdef QUOTA QUOTAMAP(); ! if (ix_dquot[ip - inode] != NODQUOT) ! panic("maknode: dquot"); #endif ip->i_flag |= IACC|IUPD|ICHG; if ((mode & IFMT) == 0) --- 1257,1265 ---- } #ifdef QUOTA QUOTAMAP(); ! xdq = &ix_dquot[ip - inode]; ! if (*xdq != NODQUOT) ! panic("maknode"); #endif ip->i_flag |= IACC|IUPD|ICHG; if ((mode & IFMT) == 0) *************** *** 1133,1139 **** if (ip->i_mode & ISGID && !groupmember(ip->i_gid)) ip->i_mode &= ~ISGID; #ifdef QUOTA ! ix_dquot[ip - inode] = inoquota(ip); QUOTAUNMAP(); #endif --- 1271,1277 ---- if (ip->i_mode & ISGID && !groupmember(ip->i_gid)) ip->i_mode &= ~ISGID; #ifdef QUOTA ! *xdq = inoquota(ip); QUOTAUNMAP(); #endif *************** *** 1175,1180 **** --- 1313,1321 ---- register struct inode *ip, *dp; struct dirtemplate dirtemplate; register struct nameidata *ndp = &u.u_nd; + #ifdef QUOTA + struct dquot **xdq; + #endif ndp->ni_nameiop = CREATE; ndp->ni_segflg = UIO_USERSPACE; *************** *** 1204,1211 **** } #ifdef QUOTA QUOTAMAP(); ! if (ix_dquot[ip - inode] != NODQUOT) ! panic("mkdir: dquot"); #endif ip->i_flag |= IACC|IUPD|ICHG; ip->i_mode = uap->dmode & ~u.u_cmask; --- 1345,1353 ---- } #ifdef QUOTA QUOTAMAP(); ! xdq = &ix_dquot[ip - inode]; ! if (*xdq != NODQUOT) ! panic("mkdir"); #endif ip->i_flag |= IACC|IUPD|ICHG; ip->i_mode = uap->dmode & ~u.u_cmask; *************** *** 1213,1219 **** ip->i_uid = u.u_uid; ip->i_gid = dp->i_gid; #ifdef QUOTA ! ix_dquot[ip - inode] = inoquota(ip); QUOTAUNMAP(); #endif iupdat(ip, &time, &time, 1); --- 1355,1361 ---- ip->i_uid = u.u_uid; ip->i_gid = dp->i_gid; #ifdef QUOTA ! *xdq = inoquota(ip); QUOTAUNMAP(); #endif iupdat(ip, &time, &time, 1); *************** *** 1236,1242 **** dirtemplate.dot_ino = ip->i_number; dirtemplate.dotdot_ino = dp->i_number; u.u_error = rdwri(UIO_WRITE, ip, (caddr_t)&dirtemplate, ! sizeof (dirtemplate), (off_t)0, 1, (int *)0); if (u.u_error) { dp->i_nlink--; dp->i_flag |= ICHG; --- 1378,1385 ---- dirtemplate.dot_ino = ip->i_number; dirtemplate.dotdot_ino = dp->i_number; u.u_error = rdwri(UIO_WRITE, ip, (caddr_t)&dirtemplate, ! sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE, IO_UNIT|IO_SYNC, ! (int *)0); if (u.u_error) { dp->i_nlink--; dp->i_flag |= ICHG; *************** *** 1322,1327 **** --- 1465,1474 ---- */ if (ip->i_nlink != 2 || !dirempty(ip, dp->i_number)) { u.u_error = ENOTEMPTY; + goto out; + } + if ((dp->i_flags & APPEND) || (ip->i_flags & (IMMUTABLE|APPEND))) { + u.u_error = EPERM; goto out; } /* *** /usr/src/sys/sys/uipc_socket.c.old Thu Dec 24 16:33:37 1992 --- /usr/src/sys/sys/uipc_socket.c Sat Nov 26 23:51:39 1994 *************** *** 9,15 **** * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. * ! * @(#)uipc_socket.c 7.8 (Berkeley) 1/20/88 */ #include "param.h" --- 9,15 ---- * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. * ! * @(#)uipc_socket.c 7.8.1 (2.11BSD GTE) 11/26/94 */ #include "param.h" *************** *** 374,380 **** 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) --- 374,380 ---- len = MIN(MIN(MLEN, uio->uio_resid), space); space -= len; } ! error = uiomove(mtod(m, caddr_t), len, uio); m->m_len = len; *mp = m; if (error) *************** *** 449,455 **** 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: --- 449,455 ---- if (len > m->m_len) len = m->m_len; error = ! uiomove(mtod(m, caddr_t), (int)len, uio); m = m_free(m); } while (uio->uio_resid && error == 0 && m); bad: *************** *** 547,554 **** if (len > m->m_len - moff) 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) { --- 547,553 ---- if (len > m->m_len - moff) len = m->m_len - moff; splx(s); ! error = uiomove(mtod(m, caddr_t) + moff, (int)len, uio); s = splnet(); if (len == m->m_len - moff) { if (flags & MSG_PEEK) { *** /usr/src/sys/sys/uipc_syscalls.c.old Mon Jan 10 21:29:33 1994 --- /usr/src/sys/sys/uipc_syscalls.c Fri Dec 2 23:21:52 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)uipc_syscalls.c 7.1.1 (2.11BSD GTE) 12/31/93 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)uipc_syscalls.c 7.1.2 (2.11BSD GTE) 12/2/94 */ #include "param.h" *************** *** 27,35 **** #include "netinet/in.h" #include "netinet/in_systm.h" ! #define MBZAP(m, len, type) \ ! (m)->m_next = 0; (m)->m_off = MMINOFF; (m)->m_len = (len); \ ! (m)->m_type = (type); (m)->m_act = 0; /* * System call interface to the socket abstraction. --- 27,43 ---- #include "netinet/in.h" #include "netinet/in_systm.h" ! static void ! MBZAP(m, len, type) ! register struct mbuf *m; ! int len, type; ! { ! m->m_next = 0; ! m->m_off = MMINOFF; ! m->m_len = len; ! m->m_type = type; ! m->m_act = 0; ! } /* * System call interface to the socket abstraction. *************** *** 387,392 **** --- 395,401 ---- auio.uio_segflg = UIO_USERSPACE; auio.uio_offset = 0; /* XXX */ auio.uio_resid = 0; + auio.uio_rw = UIO_WRITE; iov = mp->msg_iov; for (i = 0; i < mp->msg_iovlen; i++, iov++) { #ifndef pdp11 *************** *** 531,536 **** --- 540,546 ---- auio.uio_segflg = UIO_USERSPACE; auio.uio_offset = 0; /* XXX */ auio.uio_resid = 0; + auio.uio_rw = UIO_READ; iov = mp->msg_iov; for (i = 0; i < mp->msg_iovlen; i++, iov++) { #ifndef pdp11 *** /usr/src/sys/sys/vm_swp.c.old Wed Dec 23 23:39:03 1992 --- /usr/src/sys/sys/vm_swp.c Wed Nov 30 20:05:31 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)vm_swp.c 2.2 (2.11BSD) 9/22/91 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)vm_swp.c 2.3 (2.11BSD) 11/30/94 */ #include "param.h" *************** *** 212,229 **** return(error); } ! rawread(dev, uio) dev_t dev; ! struct uio *uio; { return(physio(cdevsw[major(dev)].d_strategy, (struct buf *)NULL, dev, ! B_READ, uio)); ! } ! ! rawwrite(dev, uio) ! dev_t dev; ! struct uio *uio; ! { ! return(physio(cdevsw[major(dev)].d_strategy, (struct buf *)NULL, dev, ! B_WRITE, uio)); } --- 212,222 ---- return(error); } ! rawrw(dev, uio, flag) dev_t dev; ! register struct uio *uio; ! int flag; { return(physio(cdevsw[major(dev)].d_strategy, (struct buf *)NULL, dev, ! uio->uio_rw == UIO_READ ? B_READ : B_WRITE, uio)); } *** /usr/src/sys/sys/vm_text.c.old Thu Jun 6 20:01:19 1991 --- /usr/src/sys/sys/vm_text.c Sat Nov 26 23:30:10 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)vm_text.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. * ! * @(#)vm_text.c 1.2 (2.11BSD GTE) 11/26/94 */ #include "param.h" *************** *** 219,225 **** 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; --- 219,225 ---- 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, IO_UNIT, (int *)0); if (u.u_ovdata.uo_ovbase) { /* read in overlays if necessary */ register int i; *************** *** 232,238 **** 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; } } --- 232,239 ---- choverlay(RW); u.u_error = rdwri(UIO_READ, ip, (caddr_t)(ctob(stoc(u.u_ovdata.uo_ovbase))), ! count, offset, UIO_USERISPACE, ! IO_UNIT, (int *)0); offset += (off_t) count; } }