Subject: chflags - immutable|appendonly files come to 2BSD (#200 - Part 4 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 4 of 14 (#200). Files affected by this part are: /usr/src/sys/sys/init_main.c /usr/src/sys/sys/init_sysent.c /usr/src/sys/sys/kern_acct.c /usr/src/sys/sys/kern_descrip.c /usr/src/sys/sys/kern_exec.c /usr/src/sys/sys/kern_sig.c /usr/src/sys/sys/kern_subr.c /usr/src/sys/sys/quota_kern.c /usr/src/sys/sys/subr_log.c /usr/src/sys/sys/sys_generic.c /usr/src/sys/sys/sys_inode.c /usr/src/sys/sys/sys_net.c /usr/src/sys/sys/sys_pipe.c /usr/src/sys/sys/syscalls.c =====================cut here======================== *** /usr/src/sys/sys/init_main.c.old Mon Mar 15 18:28:07 1993 --- /usr/src/sys/sys/init_main.c Thu Dec 15 19:57:55 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)init_main.c 1.5 (2.11BSD GTE) 3/12/93 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)init_main.c 1.6 (2.11BSD GTE) 12/15/94 */ #include "param.h" *************** *** 30,35 **** --- 30,37 ---- int netoff = 1; int cmask = CMASK; + int securelevel = -1; + extern size_t physmem; extern struct mapent _coremap[]; *************** *** 323,329 **** 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; --- 325,331 ---- goto leave; } err = rdwri(UIO_READ, ip, &ex, sizeof (ex), (off_t)0, UIO_SYSSPACE, ! IO_UNIT, &resid); if (err || resid) { printf("%s header err %d\n", NETNIX, ret); goto leave; *************** *** 345,351 **** 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); --- 347,353 ---- off = sizeof (ex); for (i = 0; i < nettsize; i++) { err = rdwri(UIO_READ, ip, oneclick, ctob(1), off, UIO_SYSSPACE, ! IO_UNIT, &resid); if (err || resid) goto release; mapseg5(nettext + i, 077406); *************** *** 355,361 **** } 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); --- 357,363 ---- } for (i = 0; i < initdata; i++) { err = rdwri(UIO_READ, ip, oneclick, ctob(1), off, UIO_SYSSPACE, ! IO_UNIT, &resid); if (err || resid) goto release; mapseg5(netdata + i, 077406); *************** *** 365,371 **** } 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\n", NETNIX, err); mfree(coremap, nettsize, nettext); --- 367,373 ---- } if (ex.a_data & 077) { err = rdwri(UIO_READ, ip, oneclick, ex.a_data & 077, off, ! UIO_SYSSPACE, IO_UNIT, &resid); if (err || resid) { release: printf("%s err %d\n", NETNIX, err); mfree(coremap, nettsize, nettext); *************** *** 396,402 **** 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)); --- 398,404 ---- iput(ip); u.u_error = 0; ndp->ni_dirp = 0; ! ndp->ni_segflg = UIO_USERSPACE; ndp->ni_endoff = 0; bzero(&u.u_ncache, sizeof(u.u_ncache)); bzero(&ndp->ni_dent, sizeof(ndp->ni_dent)); *** /usr/src/sys/sys/init_sysent.c.old Thu Apr 21 19:47:00 1994 --- /usr/src/sys/sys/init_sysent.c Sun Nov 27 00:09:12 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)init_sysent.c 1.5 (2.11BSD GTE) 4/21/94 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)init_sysent.c 1.6 (2.11BSD GTE) 11/26/94 */ /* *************** *** 39,45 **** /* 1.5 descriptors */ int getdtablesize(),dup(),dup2(),close(); ! int select(),getdopt(),setdopt(),fcntl(),flock(); /* 1.6 resource controls */ int getpriority(),setpriority(),getrusage(),getrlimit(),setrlimit(); --- 39,45 ---- /* 1.5 descriptors */ int getdtablesize(),dup(),dup2(),close(); ! int select(),fcntl(),flock(); /* 1.6 resource controls */ int getpriority(),setpriority(),getrusage(),getrlimit(),setrlimit(); *************** *** 54,60 **** /* 2.2 file system */ int chdir(), fchdir(), chroot(); ! int mkdir(),rmdir(); int creat(),open(),mknod(),unlink(),stat(),fstat(),lstat(); int chown(),fchown(),chmod(),fchmod(),utimes(); int link(),symlink(),readlink(),rename(); --- 54,60 ---- /* 2.2 file system */ int chdir(), fchdir(), chroot(); ! int mkdir(),rmdir(), chflags(), fchflags(); int creat(),open(),mknod(),unlink(),stat(),fstat(),lstat(); int chown(),fchown(),chmod(),fchmod(),utimes(); int link(),symlink(),readlink(),rename(); *************** *** 122,129 **** 3, mknod, /* 14 = mknod */ 2, chmod, /* 15 = chmod */ 3, chown, /* 16 = chown; now 3 args */ ! 0, nosys, /* 17 = old break */ ! 0, nosys, /* 18 = old stat */ 4, lseek, /* 19 = lseek */ 0, getpid, /* 20 = getpid */ 3, smount, /* 21 = mount */ --- 122,129 ---- 3, mknod, /* 14 = mknod */ 2, chmod, /* 15 = chmod */ 3, chown, /* 16 = chown; now 3 args */ ! 2, chflags, /* 17 = chflags */ ! 2, fchflags, /* 18 = fchflags */ 4, lseek, /* 19 = lseek */ 0, getpid, /* 20 = getpid */ 3, smount, /* 21 = mount */ *************** *** 196,205 **** 2, sethostname, /* 88 = sethostname */ 0, getdtablesize, /* 89 = getdtablesize */ 2, dup2, /* 90 = dup2 */ ! 2, getdopt, /* 91 = getdopt */ 3, fcntl, /* 92 = fcntl */ 5, select, /* 93 = select */ ! 2, setdopt, /* 94 = setdopt */ 1, fsync, /* 95 = fsync */ 3, setpriority, /* 96 = setpriority */ errnet(3, socket), /* 97 = socket */ --- 196,205 ---- 2, sethostname, /* 88 = sethostname */ 0, getdtablesize, /* 89 = getdtablesize */ 2, dup2, /* 90 = dup2 */ ! 0, nosys, /* 91 = unused */ 3, fcntl, /* 92 = fcntl */ 5, select, /* 93 = select */ ! 0, nosys, /* 94 = unused */ 1, fsync, /* 95 = fsync */ 3, setpriority, /* 96 = setpriority */ errnet(3, socket), /* 97 = socket */ *** /usr/src/sys/sys/kern_acct.c.old Wed Mar 10 23:46:52 1993 --- /usr/src/sys/sys/kern_acct.c Sat Nov 26 23:08:26 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_acct.c 2.1 (2.11BSD) 3/10/93 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_acct.c 2.2 (2.11BSD) 11/26/94 */ #include "param.h" *************** *** 134,140 **** ap->ac_flag = u.u_acflag; siz = ip->i_size; u.u_error = rdwri(UIO_WRITE, ip, ap, sizeof(acctbuf), siz, ! UIO_SYSSPACE, (int *)0); if (u.u_error) itrunc(ip, (u_long)siz); iunlock(ip); --- 134,140 ---- ap->ac_flag = u.u_acflag; siz = ip->i_size; u.u_error = rdwri(UIO_WRITE, ip, ap, sizeof(acctbuf), siz, ! UIO_SYSSPACE, IO_UNIT|IO_APPEND, (int *)0); if (u.u_error) itrunc(ip, (u_long)siz); iunlock(ip); *** /usr/src/sys/sys/kern_descrip.c.old Thu Dec 24 16:30:06 1992 --- /usr/src/sys/sys/kern_descrip.c Tue Nov 29 19:35:41 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_descrip.c 1.2 (2.11BSD GTE) 12/24/92 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_descrip.c 1.3 (2.11BSD GTE) 11/26/94 */ #include "param.h" *************** *** 33,55 **** u.u_r.r_val1 = NOFILE; } - getdopt() - { - - } - - setdopt() - { - - } - dup() { register struct a { int i; } *uap = (struct a *) u.u_ap; ! struct file *fp; ! int j; if (uap->i &~ 077) { uap->i &= 077; dup2(); return; } /* XXX */ --- 33,45 ---- u.u_r.r_val1 = NOFILE; } dup() { register struct a { int i; } *uap = (struct a *) u.u_ap; ! register struct file *fp; ! register int j; if (uap->i &~ 077) { uap->i &= 077; dup2(); return; } /* XXX */ *************** *** 86,92 **** dupit(fd, fp, flags) register int fd; register struct file *fp; ! register int flags; { u.u_ofile[fd] = fp; --- 76,82 ---- dupit(fd, fp, flags) register int fd; register struct file *fp; ! int flags; { u.u_ofile[fd] = fp; *************** *** 111,117 **** register char *pop; uap = (struct a *)u.u_ap; ! GETF(fp, uap->fdes); pop = &u.u_pofile[uap->fdes]; switch(uap->cmd) { case F_DUPFD: --- 101,108 ---- register char *pop; uap = (struct a *)u.u_ap; ! if ((fp = getf(uap->fdes)) == NULL) ! return; pop = &u.u_pofile[uap->fdes]; switch(uap->cmd) { case F_DUPFD: *************** *** 134,151 **** break; case F_GETFL: ! u.u_r.r_val1 = fp->f_flag+FOPEN; break; case F_SETFL: ! fp->f_flag &= FCNTLCANT; ! fp->f_flag |= (uap->arg-FOPEN) &~ FCNTLCANT; ! u.u_error = fset(fp, FNDELAY, fp->f_flag & FNDELAY); if (u.u_error) break; u.u_error = fset(fp, FASYNC, fp->f_flag & FASYNC); if (u.u_error) ! (void) fset(fp, FNDELAY, 0); break; case F_GETOWN: --- 125,142 ---- break; case F_GETFL: ! u.u_r.r_val1 = OFLAGS(fp->f_flag); break; case F_SETFL: ! fp->f_flag &= ~FCNTLFLAGS; ! fp->f_flag |= (FFLAGS(uap->arg)) & ~FCNTLFLAGS; ! u.u_error = fset(fp, FNONBLOCK, fp->f_flag & FNONBLOCK); if (u.u_error) break; u.u_error = fset(fp, FASYNC, fp->f_flag & FASYNC); if (u.u_error) ! (void) fset(fp, FNONBLOCK, 0); break; case F_GETOWN: *************** *** 170,182 **** fp->f_flag |= bit; else fp->f_flag &= ~bit; ! return (fioctl(fp, (u_int)(bit == FNDELAY ? FIONBIO : FIOASYNC), (caddr_t)&value)); } fgetown(fp, valuep) ! struct file *fp; ! int *valuep; { register int error; --- 161,173 ---- fp->f_flag |= bit; else fp->f_flag &= ~bit; ! return (fioctl(fp, (u_int)(bit == FNONBLOCK ? FIONBIO : FIOASYNC), (caddr_t)&value)); } fgetown(fp, valuep) ! register struct file *fp; ! register int *valuep; { register int error; *************** *** 192,198 **** } fsetown(fp, value) ! struct file *fp; int value; { --- 183,189 ---- } fsetown(fp, value) ! register struct file *fp; int value; { *************** *** 203,209 **** } #endif if (value > 0) { ! struct proc *p = pfind(value); if (p == 0) return (ESRCH); value = p->p_pgrp; --- 194,200 ---- } #endif if (value > 0) { ! register struct proc *p = pfind(value); if (p == 0) return (ESRCH); value = p->p_pgrp; *************** *** 216,222 **** fioctl(fp, cmd, value) register struct file *fp; ! int cmd; caddr_t value; { --- 207,213 ---- fioctl(fp, cmd, value) register struct file *fp; ! u_int cmd; caddr_t value; { *************** *** 225,238 **** close() { ! struct a { int i; } *uap = (struct a *)u.u_ap; - register int i = uap->i; register struct file *fp; ! GETF(fp, i); ! u.u_ofile[i] = NULL; while (u.u_lastfile >= 0 && u.u_ofile[u.u_lastfile] == NULL) u.u_lastfile--; closef(fp); --- 216,228 ---- close() { ! register struct a { int i; } *uap = (struct a *)u.u_ap; register struct file *fp; ! GETF(fp, uap->i); ! u.u_ofile[uap->i] = NULL; while (u.u_lastfile >= 0 && u.u_ofile[u.u_lastfile] == NULL) u.u_lastfile--; closef(fp); *************** *** 249,255 **** struct stat ub; uap = (struct a *)u.u_ap; ! GETF(fp, uap->fdes); switch (fp->f_type) { case DTYPE_PIPE: --- 239,246 ---- struct stat ub; uap = (struct a *)u.u_ap; ! if ((fp = getf(uap->fdes)) == NULL) ! return; switch (fp->f_type) { case DTYPE_PIPE: *************** *** 265,272 **** break; #endif default: ! panic("fstat"); ! /*NOTREACHED*/ } if (u.u_error == 0) u.u_error = copyout((caddr_t)&ub, (caddr_t)uap->sb, --- 256,263 ---- break; #endif default: ! u.u_error = EINVAL; ! break; } if (u.u_error == 0) u.u_error = copyout((caddr_t)&ub, (caddr_t)uap->sb, *************** *** 345,351 **** /* * Convert a user supplied file descriptor into a pointer * to a file structure. Only task is to check range of the descriptor. ! * Critical paths should use the GETF macro. */ struct file * getf(f) --- 336,343 ---- /* * Convert a user supplied file descriptor into a pointer * to a file structure. Only task is to check range of the descriptor. ! * Critical paths should use the GETF macro unless code size is a ! * consideration. */ struct file * getf(f) *************** *** 389,401 **** } *uap = (struct a *)u.u_ap; register struct file *fp; ! GETF(fp, uap->fd); if (fp->f_type != DTYPE_INODE) { u.u_error = EOPNOTSUPP; return; } if (uap->how & LOCK_UN) { ! ino_unlock(fp, FSHLOCK|FEXLOCK); return; } if ((uap->how & (LOCK_SH | LOCK_EX)) == 0) --- 381,394 ---- } *uap = (struct a *)u.u_ap; register struct file *fp; ! if ((fp = getf(uap->fd)) == NULL) ! return; if (fp->f_type != DTYPE_INODE) { u.u_error = EOPNOTSUPP; return; } if (uap->how & LOCK_UN) { ! ino_unlock(fp, FSHLOCK | FEXLOCK); return; } if ((uap->how & (LOCK_SH | LOCK_EX)) == 0) *** /usr/src/sys/sys/kern_exec.c.old Sun Dec 27 23:53:08 1992 --- /usr/src/sys/sys/kern_exec.c Sat Nov 26 23:12:37 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_exec.c 1.2 (2.11BSD GTE) 12/23/92 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_exec.c 1.3 (2.11BSD GTE) 11/26/94 */ #include "param.h" *************** *** 105,111 **** */ 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) && --- 105,111 ---- */ exdata.ex_shell[0] = '\0'; /* for zero length files */ u.u_error = rdwri(UIO_READ, ip, &exdata, sizeof(exdata), (off_t)0, ! UIO_SYSSPACE, IO_UNIT, &resid); if (u.u_error) goto bad; if (resid > sizeof(exdata) - sizeof(exdata.ex_exec) && *************** *** 516,522 **** 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) { --- 516,522 ---- 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, IO_UNIT, &resid); if (resid != 0) u.u_error = ENOEXEC; if (u.u_error) { *************** *** 609,615 **** 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 --- 609,615 ---- else offset += ep->a_text; rdwri(UIO_READ, ip, (caddr_t) 0, ep->a_data, offset, ! UIO_USERSPACE, IO_UNIT, (int *)0); /* * set SUID/SGID protections, if no tracing *** /usr/src/sys/sys/kern_sig.c.old Fri Apr 15 22:17:13 1994 --- /usr/src/sys/sys/kern_sig.c Sat Nov 26 23:16:37 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_sig.c 1.4 (2.11BSD GTE) 4/15/94 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_sig.c 1.5 (2.11BSD GTE) 11/26/94 */ #include "param.h" *************** *** 841,859 **** 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); --- 841,859 ---- itrunc(ip, (u_long)0); u.u_acflag |= ACORE; u.u_error = rdwri(UIO_WRITE, ip, &u, ctob(USIZE), (off_t)0, ! UIO_SYSSPACE, IO_UNIT, (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, IO_UNIT, (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, IO_UNIT, (int *)0); out: iput(ip); return (u.u_error == 0); *** /usr/src/sys/sys/kern_subr.c.old Wed Apr 11 09:49:25 1990 --- /usr/src/sys/sys/kern_subr.c Mon Nov 28 20:18:28 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_subr.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. * ! * @(#)kern_subr.c 1.2 (2.11BSD GTE) 11/26/94 */ #include "param.h" *************** *** 15,24 **** #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; --- 15,23 ---- #include "uio.h" /* copied, for supervisory networking, to sys_net.c */ ! uiomove(cp, n, uio) caddr_t cp; u_int n; register struct uio *uio; { register struct iovec *iov; *************** *** 39,52 **** 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); --- 38,51 ---- case UIO_USERSPACE: if (cnt > 100 && cp + cnt < SEG6) ! error = uiofmove(cp, cnt, uio, iov); else if ((cnt | (int)cp | (int)iov->iov_base) & 1) ! if (uio->uio_rw == UIO_READ) error = vcopyout(cp,iov->iov_base, cnt); else error = vcopyin(iov->iov_base, cp, cnt); else { ! if (uio->uio_rw == UIO_READ) error = copyout(cp, iov->iov_base, cnt); else error = copyin(iov->iov_base, cp, cnt); *************** *** 57,64 **** 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); --- 56,63 ---- case UIO_USERISPACE: if (cnt > 100 && cp + cnt < SEG6) ! error = uiofmove(cp, cnt, uio, iov); ! else if (uio->uio_rw == UIO_READ) error = copyiout(cp, iov->iov_base, cnt); else error = copyiin(iov->iov_base, cp, cnt); *************** *** 67,73 **** 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); --- 66,72 ---- break; case UIO_SYSSPACE: ! if (uio->uio_rw == UIO_READ) bcopy((caddr_t)cp, iov->iov_base, cnt); else bcopy(iov->iov_base, (caddr_t)cp, cnt); *************** *** 176,185 **** * 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; { --- 175,183 ---- * language helper routine, fmove, uses segment register 6 to map in the * user's memory. */ ! uiofmove(cp, n, uio, iov) caddr_t cp; register int n; struct uio *uio; struct iovec *iov; { *************** *** 208,214 **** on = (short)iov->iov_base & 017777; c = MIN(n, 8192-on); for (;;) { ! if (rw == UIO_READ) error = fmove(sega[segr], segd[segr], cp, SEG6+on, c); else error = fmove(sega[segr], segd[segr], SEG6+on, cp, c); --- 206,212 ---- on = (short)iov->iov_base & 017777; c = MIN(n, 8192-on); for (;;) { ! if (uio->uio_rw == UIO_READ) error = fmove(sega[segr], segd[segr], cp, SEG6+on, c); else error = fmove(sega[segr], segd[segr], SEG6+on, cp, c); *** /usr/src/sys/sys/quota_kern.c.old Mon Jan 10 21:28:48 1994 --- /usr/src/sys/sys/quota_kern.c Sat Nov 26 23:20:31 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)quota_kern.c 7.1.1 (2.11BSD GTE) 12/31/93 * * I'll say it here and not every other place i've had to hack: * Mike Karels was right - " just buy a vax...". i have traded cpu cycles --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)quota_kern.c 7.1.2 (2.11BSD GTE) 11/26/94 * * I'll say it here and not every other place i've had to hack: * Mike Karels was right - " just buy a vax...". i have traded cpu cycles *************** *** 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; } --- 406,412 ---- QUOTAUNMAP(); ILOCK(ip); fail = rdwri(UIO_READ, ip, &xq, sizeof (xq), ! (off_t)uid * sizeof (xq), UIO_SYSSPACE, IO_UNIT,(int *)0); QUOTAMAP(); dq->dq_dqb = xq; } *************** *** 413,419 **** #else ILOCK(ip); fail = rdwri(UIO_READ, ip, (caddr_t)&dq->dq_dqb, sizeof (struct dqblk), ! (off_t)uid * sizeof (struct dqblk), 1, (int *)0); #endif IUNLOCK(ip); if (dq->dq_flags & DQ_WANT) --- 413,419 ---- #else ILOCK(ip); fail = rdwri(UIO_READ, ip, (caddr_t)&dq->dq_dqb, sizeof (struct dqblk), ! (off_t)uid * sizeof(struct dqblk), UIO_SYSSPACE, IO_UNIT, (int *)0); #endif IUNLOCK(ip); if (dq->dq_flags & DQ_WANT) *************** *** 640,652 **** QUOTAUNMAP(); ILOCK(ip); (void)rdwri(UIO_WRITE, ip, &xq, sizeof (xq), ! (off_t)uid * sizeof (xq), UIO_SYSSPACE, (int *)0); QUOTAMAP(); } #else ILOCK(ip); (void) rdwri(UIO_WRITE, ip, (caddr_t)&dq->dq_dqb, sizeof (struct dqblk), ! (off_t)dq->dq_uid * sizeof (struct dqblk), 1, (int *)0); #endif IUNLOCK(ip); if (dq->dq_flags & DQ_WANT) --- 640,654 ---- QUOTAUNMAP(); ILOCK(ip); (void)rdwri(UIO_WRITE, ip, &xq, sizeof (xq), ! (off_t)uid * sizeof (xq), UIO_SYSSPACE, ! IO_UNIT, (int *)0); QUOTAMAP(); } #else ILOCK(ip); (void) rdwri(UIO_WRITE, ip, (caddr_t)&dq->dq_dqb, sizeof (struct dqblk), ! (off_t)dq->dq_uid * sizeof (struct dqblk), UIO_SYSSPACE, ! IO_UNIT, (int *)0); #endif IUNLOCK(ip); if (dq->dq_flags & DQ_WANT) *** /usr/src/sys/sys/subr_log.c.old Fri Dec 31 23:40:06 1993 --- /usr/src/sys/sys/subr_log.c Wed Nov 30 22:05:08 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)subr_log.c 1.2 (2.11BSD GTE) 12/31/93 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)subr_log.c 1.3 (2.11BSD GTE) 11/30/94 */ /* *************** *** 16,21 **** --- 16,22 ---- #include "ioctl.h" #include "msgbuf.h" #include "file.h" + #include "inode.h" #include "errno.h" #include "uio.h" #include "machine/seg.h" *************** *** 22,28 **** #define LOG_RDPRI (PZERO + 1) - #define LOG_NBIO 0x02 #define LOG_ASYNC 0x04 #define LOG_RDWAIT 0x08 --- 23,28 ---- *************** *** 29,49 **** struct logsoftc { int sc_state; /* see above for possibilities */ struct proc *sc_selp; /* process waiting on select call */ ! int sc_pgrp; /* process group for async I/O */ } logsoftc; int log_open; /* also used in log() */ /*ARGSUSED*/ ! logopen(dev) dev_t dev; { if (log_open) return (EBUSY); log_open = 1; ! logsoftc.sc_selp = 0; ! logsoftc.sc_pgrp = u.u_procp->p_pgrp; #ifndef pdp11 /* * Potential race here with putchar() but since putchar should be --- 29,50 ---- struct logsoftc { int sc_state; /* see above for possibilities */ struct proc *sc_selp; /* process waiting on select call */ ! int sc_pgid; /* process/group for async I/O */ } logsoftc; int log_open; /* also used in log() */ /*ARGSUSED*/ ! logopen(dev, mode) dev_t dev; + int mode; { if (log_open) return (EBUSY); log_open = 1; ! logsoftc.sc_pgid = u.u_procp->p_pid; /* signal process only */ ! #ifndef pdp11 /* * Potential race here with putchar() but since putchar should be *************** *** 68,81 **** { log_open = 0; logsoftc.sc_state = 0; - logsoftc.sc_selp = 0; - logsoftc.sc_pgrp = 0; } /*ARGSUSED*/ ! logread(dev, uio) dev_t dev; struct uio *uio; { register int l; register int s; --- 69,81 ---- { log_open = 0; logsoftc.sc_state = 0; } /*ARGSUSED*/ ! logread(dev, uio, flag) dev_t dev; struct uio *uio; + int flag; { register int l; register int s; *************** *** 86,92 **** s = splhigh(); while (msgbuf.msg_bufr == msgbuf.msg_bufx) { ! if (logsoftc.sc_state & LOG_NBIO) { splx(s); return (EWOULDBLOCK); } --- 86,92 ---- s = splhigh(); while (msgbuf.msg_bufr == msgbuf.msg_bufx) { ! if (flag & IO_NDELAY) { splx(s); return (EWOULDBLOCK); } *************** *** 108,117 **** 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); #endif if (error) break; --- 108,117 ---- mapseg5(msgbuf.msg_click, (btoc(MSG_BSIZE) << 8) | RW); bcopy(&msgbuf.msg_bufc[msgbuf.msg_bufr], buf, l); normalseg5(); ! error = uiomove(buf, l, uio); #else error = uiomove((caddr_t)&msgbuf.msg_bufc[msgbuf.msg_bufr], ! (int)l, uio); #endif if (error) break; *************** *** 127,133 **** dev_t dev; int rw; { ! int s = splhigh(); switch (rw) { --- 127,133 ---- dev_t dev; int rw; { ! register int s = splhigh(); switch (rw) { *************** *** 145,150 **** --- 145,151 ---- logwakeup() { + register struct proc *p; if (!log_open) return; *************** *** 152,159 **** selwakeup(logsoftc.sc_selp, (long) 0); logsoftc.sc_selp = 0; } ! if (logsoftc.sc_state & LOG_ASYNC) ! gsignal(logsoftc.sc_pgrp, SIGIO); if (logsoftc.sc_state & LOG_RDWAIT) { wakeup((caddr_t)&msgbuf); logsoftc.sc_state &= ~LOG_RDWAIT; --- 153,164 ---- selwakeup(logsoftc.sc_selp, (long) 0); logsoftc.sc_selp = 0; } ! if (logsoftc.sc_state & LOG_ASYNC) { ! if (logsoftc.sc_pgid < 0) ! gsignal(-logsoftc.sc_pgid, SIGIO); ! else if (p = pfind(logsoftc.sc_pgid)) ! psignal(p, SIGIO); ! } if (logsoftc.sc_state & LOG_RDWAIT) { wakeup((caddr_t)&msgbuf); logsoftc.sc_state &= ~LOG_RDWAIT; *************** *** 180,189 **** break; case FIONBIO: - if (*(int *)data) - logsoftc.sc_state |= LOG_NBIO; - else - logsoftc.sc_state &= ~LOG_NBIO; break; case FIOASYNC: --- 185,190 ---- *************** *** 194,204 **** break; case TIOCSPGRP: ! logsoftc.sc_pgrp = *(int *)data; break; case TIOCGPGRP: ! *(int *)data = logsoftc.sc_pgrp; break; default: --- 195,205 ---- break; case TIOCSPGRP: ! logsoftc.sc_pgid = *(int *)data; break; case TIOCGPGRP: ! *(int *)data = logsoftc.sc_pgid; break; default: *** /usr/src/sys/sys/sys_generic.c.old Fri Dec 31 23:34:28 1993 --- /usr/src/sys/sys/sys_generic.c Fri Dec 2 22:24:30 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)sys_generic.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. * ! * @(#)sys_generic.c 1.4 (2.11BSD GTE) 11/26/94 */ #include "param.h" *************** *** 49,55 **** aiov.iov_len = uap->count; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; ! rwuio(&auio, UIO_READ); } readv() --- 49,56 ---- aiov.iov_len = uap->count; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; ! auio.uio_rw = UIO_READ; ! rwuio(&auio); } readv() *************** *** 68,78 **** } 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); } /* --- 69,80 ---- } auio.uio_iov = aiov; auio.uio_iovcnt = uap->iovcnt; + auio.uio_rw = UIO_READ; u.u_error = copyin((caddr_t)uap->iovp, (caddr_t)aiov, uap->iovcnt * sizeof (struct iovec)); if (u.u_error) return; ! rwuio(&auio); } /* *************** *** 90,98 **** auio.uio_iov = &aiov; auio.uio_iovcnt = 1; aiov.iov_base = uap->cbuf; aiov.iov_len = uap->count; ! rwuio(&auio, UIO_WRITE); } writev() --- 92,101 ---- auio.uio_iov = &aiov; auio.uio_iovcnt = 1; + auio.uio_rw = UIO_WRITE; aiov.iov_base = uap->cbuf; aiov.iov_len = uap->count; ! rwuio(&auio); } writev() *************** *** 111,137 **** } 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; } --- 114,141 ---- } auio.uio_iov = aiov; auio.uio_iovcnt = uap->iovcnt; + auio.uio_rw = UIO_WRITE; u.u_error = copyin((caddr_t)uap->iovp, (caddr_t)aiov, uap->iovcnt * sizeof (struct iovec)); if (u.u_error) return; ! rwuio(&auio); } ! static ! rwuio(uio) register struct uio *uio; { struct a { int fdes; }; ! register 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 & (uio->uio_rw == UIO_READ ? FREAD : FWRITE)) == 0) { u.u_error = EBADF; return; } *************** *** 171,177 **** 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; } --- 175,181 ---- u.u_eosys = RESTARTSYS; } } else ! u.u_error = (*Fops[fp->f_type]->fo_rw)(fp, uio); u.u_r.r_val1 = count - uio->uio_resid; } *************** *** 181,198 **** ioctl() { register struct file *fp; ! struct a { int fdes; long cmd; caddr_t cmarg; } *uap; long com; ! register u_int k_com; register u_int size; char data[IOCPARM_MASK+1]; uap = (struct a *)u.u_ap; ! GETF(fp, uap->fdes); if ((fp->f_flag & (FREAD|FWRITE)) == 0) { u.u_error = EBADF; return; --- 185,203 ---- ioctl() { register struct file *fp; ! register struct a { int fdes; long cmd; caddr_t cmarg; } *uap; long com; ! u_int k_com; register u_int size; char data[IOCPARM_MASK+1]; uap = (struct a *)u.u_ap; ! if ((fp = getf(uap->fdes)) == NULL) ! return; if ((fp->f_flag & (FREAD|FWRITE)) == 0) { u.u_error = EBADF; return; *************** *** 199,205 **** } com = uap->cmd; ! /* THE 2.10 KERNEL STILL THINKS THAT IOCTL COMMANDS ARE 16 BITS */ k_com = (u_int)com; if (k_com == FIOCLEX) { --- 204,210 ---- } com = uap->cmd; ! /* THE 2.11 KERNEL STILL THINKS THAT IOCTL COMMANDS ARE 16 BITS */ k_com = (u_int)com; if (k_com == FIOCLEX) { *************** *** 245,251 **** switch (k_com) { case FIONBIO: ! u.u_error = fset(fp, FNDELAY, *(int *)data); return; case FIOASYNC: --- 250,256 ---- switch (k_com) { case FIONBIO: ! u.u_error = fset(fp, FNONBLOCK, *(int *)data); return; case FIOASYNC: *************** *** 287,293 **** } *uap = (struct uap *)u.u_ap; fd_set ibits[3], obits[3]; struct timeval atv; ! int s, ncoll, ni; label_t lqsave; bzero((caddr_t)ibits, sizeof(ibits)); --- 292,299 ---- } *uap = (struct uap *)u.u_ap; fd_set ibits[3], obits[3]; struct timeval atv; ! register int s, ni; ! int ncoll; label_t lqsave; bzero((caddr_t)ibits, sizeof(ibits)); *************** *** 397,404 **** int nfd; { register int i, j; ! register fd_mask bits; ! int which, flag; struct file *fp; int n = 0; --- 403,410 ---- int nfd; { register int i, j; ! fd_mask bits; ! register int which, flag; struct file *fp; int n = 0; *************** *** 467,479 **** restormap(map); } ! sorw(fp, rw, uio) register struct file *fp; - register enum uio_rw rw; register struct uio *uio; { #ifdef INET ! 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 --- 473,484 ---- restormap(map); } ! sorw(fp, uio) register struct file *fp; register struct uio *uio; { #ifdef INET ! if (uio->uio_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 *************** *** 482,490 **** } soctl(fp, com, data) ! register struct file *fp; ! register u_int com; ! register char *data; { #ifdef INET return (SOO_IOCTL(fp, com, data)); --- 487,495 ---- } soctl(fp, com, data) ! struct file *fp; ! u_int com; ! char *data; { #ifdef INET return (SOO_IOCTL(fp, com, data)); *************** *** 494,501 **** } sosel(fp, flag) ! register struct file *fp; ! register int flag; { #ifdef INET return (SOO_SELECT(fp, flag)); --- 499,506 ---- } sosel(fp, flag) ! struct file *fp; ! int flag; { #ifdef INET return (SOO_SELECT(fp, flag)); *** /usr/src/sys/sys/sys_inode.c.old Sat Jun 2 16:22:12 1990 --- /usr/src/sys/sys/sys_inode.c Thu Dec 15 19:59:30 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)sys_inode.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. * ! * @(#)sys_inode.c 1.2 (2.11BSD GTE) 12/8/94 */ #include "param.h" *************** *** 23,28 **** --- 23,29 ---- #include "tty.h" #include "kernel.h" #include "systm.h" + #include "syslog.h" #ifdef QUOTA #include "quota.h" #endif *************** *** 31,66 **** 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; --- 32,81 ---- struct fileops inodeops = { ino_rw, ino_ioctl, ino_select, ino_close }; ! ino_rw(fp, uio) struct file *fp; register struct uio *uio; { register struct inode *ip = (struct inode *)fp->f_data; u_int count, error; + int ioflag; if ((ip->i_mode&IFMT) != IFCHR) ILOCK(ip); uio->uio_offset = fp->f_offset; count = uio->uio_resid; ! if (uio->uio_rw == UIO_READ) ! { ! error = rwip(ip, uio, fp->f_flag & FNONBLOCK ? IO_NDELAY : 0); ! fp->f_offset += (count - uio->uio_resid); ! } ! else ! { ! ioflag = 0; ! if ((ip->i_mode&IFMT) == IFREG && (fp->f_flag & FAPPEND)) ! ioflag |= IO_APPEND; ! if (fp->f_flag & FNONBLOCK) ! ioflag |= IO_NDELAY; ! error = rwip(ip, uio, ioflag); ! if (ioflag & IO_APPEND) ! fp->f_offset = uio->uio_offset; ! else ! fp->f_offset += (count - uio->uio_resid); ! } if ((ip->i_mode&IFMT) != IFCHR) IUNLOCK(ip); return (error); } ! rdwri(rw, ip, base, len, offset, segflg, ioflg, aresid) ! enum uio_rw rw; struct inode *ip; caddr_t base; ! int len; off_t offset; + enum uio_seg segflg; + int ioflg; register int *aresid; { struct uio auio; struct iovec aiov; *************** *** 70,79 **** 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 --- 85,95 ---- auio.uio_iovcnt = 1; aiov.iov_base = base; aiov.iov_len = len; + auio.uio_rw = rw; auio.uio_resid = len; auio.uio_offset = offset; auio.uio_segflg = segflg; ! error = rwip(ip, &auio, ioflg); if (aresid) *aresid = auio.uio_resid; else *************** *** 82,121 **** 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); --- 98,169 ---- return (error); } ! rwip(ip, uio, ioflag) register struct inode *ip; register struct uio *uio; ! int ioflag; { dev_t dev = (dev_t)ip->i_rdev; ! register struct buf *bp; ! off_t osize; daddr_t lbn, bn; ! int n, on, type, resid; int error = 0; #ifdef DIAGNOSTIC ! if (uio->uio_rw != UIO_READ && uio->uio_rw != UIO_WRITE) panic("rwip"); #endif if (uio->uio_offset < 0) return (EINVAL); type = ip->i_mode&IFMT; + /* + * The write case below checks that i/o is done synchronously to directories + * and that i/o to append only files takes place at the end of file. The + * 'log()' statements below should be ifdef'd. Also, we do not panic on + * non-sync directory i/o - the sync bit is forced on. + */ + if (uio->uio_rw == UIO_READ) + ip->i_flag |= IACC; + else + { + switch (type) + { + case IFREG: + if (ioflag & IO_APPEND) + uio->uio_offset = ip->i_size; + if (ip->i_flags & APPEND && uio->uio_offset != ip->i_size) + return(EPERM); + break; + case IFDIR: + if ((ioflag & IO_SYNC) == 0) + { + log(LOG_ERR, "rwip sync\n"); + ioflag |= IO_SYNC; + } + break; + case IFLNK: + case IFBLK: + case IFCHR: + break; + default: + log(LOG_ERR, "rwip: %d\n", type); + return(EFTYPE); + } + } + if (type == IFCHR) { ! if (uio->uio_rw == UIO_READ) ! error = (*cdevsw[major(dev)].d_read)(dev, uio, ioflag); else { ip->i_flag |= IUPD|ICHG; ! error = (*cdevsw[major(dev)].d_write)(dev, uio, ioflag); } return (error); } if (uio->uio_resid == 0) return (0); ! if (uio->uio_rw == UIO_WRITE && type == IFREG && uio->uio_offset + uio->uio_resid > u.u_rlimit[RLIMIT_FSIZE].rlim_cur) { psignal(u.u_procp, SIGXFSZ); *************** *** 130,136 **** * 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, --- 178,184 ---- * can you say slow? i knew you could. SMS */ if ((type == IFREG || type == IFDIR || type == IFLNK) && ! uio->uio_rw == UIO_WRITE && !(ip->i_flag & IPIPE)) { if (uio->uio_offset + uio->uio_resid > ip->i_size) { QUOTAMAP(); error = chkdq(ip, *************** *** 143,154 **** #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); --- 191,205 ---- #endif if (type != IFBLK) dev = ip->i_dev; + resid = uio->uio_resid; + osize = ip->i_size; + 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 (uio->uio_rw == UIO_READ) { off_t diff = ip->i_size - uio->uio_offset; if (diff <= 0) return (0); *************** *** 158,166 **** } 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 { --- 209,217 ---- } else bn = bmap(ip,lbn,B_WRITE,n == DEV_BSIZE ? 0: 1); ! if (u.u_error || uio->uio_rw == UIO_WRITE && (long)bn<0) return (u.u_error); ! if (uio->uio_rw == UIO_WRITE && uio->uio_offset + n > ip->i_size && (type == IFDIR || type == IFREG || type == IFLNK)) ip->i_size = uio->uio_offset + n; } else { *************** *** 167,173 **** bn = lbn; rablock = bn + 1; } ! if (rw == UIO_READ) { if ((long)bn<0) { bp = geteblk(); clrbuf(bp); --- 218,224 ---- bn = lbn; rablock = bn + 1; } ! if (uio->uio_rw == UIO_READ) { if ((long)bn<0) { bp = geteblk(); clrbuf(bp); *************** *** 195,206 **** 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) --- 246,256 ---- if (bp->b_flags & B_ERROR) { error = EIO; brelse(bp); ! break; } ! u.u_error = uiomove(mapin(bp)+on, n, uio); mapout(bp); ! if (uio->uio_rw == UIO_READ) { if (n + on == DEV_BSIZE || uio->uio_offset == ip->i_size) { bp->b_flags |= B_AGE; if (ip->i_flag & IPIPE) *************** *** 208,214 **** } 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; --- 258,264 ---- } brelse(bp); } else { ! if (ioflag & IO_SYNC) bwrite(bp); else if (n + on == DEV_BSIZE && !(ip->i_flag & IPIPE)) { bp->b_flags |= B_AGE; *************** *** 222,242 **** } 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; caddr_t data; { register struct inode *ip = ((struct inode *)fp->f_data); - register int fmt = ip->i_mode & IFMT; dev_t dev; ! switch (fmt) { case IFREG: case IFDIR: --- 272,306 ---- } while (u.u_error == 0 && uio->uio_resid && n != 0); if (error == 0) /* XXX */ error = u.u_error; /* XXX */ ! if (error && (uio->uio_rw == UIO_WRITE) && (ioflag & IO_UNIT) && ! (type != IFBLK)) { ! itrunc(ip, osize); ! uio->uio_offset -= (resid - uio->uio_resid); ! uio->uio_resid = resid; ! /* ! * Should back out the change to the quota here but that would be a lot ! * of work for little benefit. Besides we've already made the assumption ! * that the entire write would succeed and users can't turn on the IO_UNIT ! * bit for their writes anyways. ! */ ! } ! #ifdef whybother ! if (!error && (ioflag & IO_SYNC)) ! IUPDAT(ip, &time, &time, 1); ! #endif return (error); } ino_ioctl(fp, com, data) ! register struct file *fp; register u_int com; caddr_t data; { register struct inode *ip = ((struct inode *)fp->f_data); dev_t dev; ! switch (ip->i_mode & IFMT) { case IFREG: case IFDIR: *************** *** 263,270 **** u.u_eosys = RESTARTSYS; return (0); } ! return ((*cdevsw[major(dev)].d_ioctl)(dev, com, data, ! fp->f_flag)); } } --- 327,333 ---- u.u_eosys = RESTARTSYS; return (0); } ! return((*cdevsw[major(dev)].d_ioctl)(dev,com,data,fp->f_flag)); } } *************** *** 290,330 **** register struct inode *ip; register struct stat *sb; { ! #ifndef EXTERNALITIMES ! ITIMES(ip, &time, &time); ! /* ! * Copy from inode table ! */ ! sb->st_dev = ip->i_dev; ! sb->st_ino = ip->i_number; ! sb->st_mode = ip->i_mode; ! sb->st_nlink = ip->i_nlink; ! sb->st_uid = ip->i_uid; ! sb->st_gid = ip->i_gid; ! sb->st_rdev = (dev_t)ip->i_rdev; ! sb->st_size = ip->i_size; ! sb->st_atime = ip->i_atime; ! sb->st_spare1 = 0; ! sb->st_mtime = ip->i_mtime; ! sb->st_spare2 = 0; ! sb->st_ctime = ip->i_ctime; ! sb->st_spare3 = 0; ! sb->st_blksize = MAXBSIZE; ! /* ! * blocks are too tough to do; it's not worth the effort. ! */ ! sb->st_blocks = btodb(ip->i_size + MAXBSIZE - 1); ! sb->st_spare4[0] = sb->st_spare4[1] = 0; #else ! /* ! * ITIMES is inlined to avoid mapping twice, once in the macro and a ! * second time to fill in the stat structure. ! */ ! struct icommon2 *ic2 = &((struct icommon2 *)SEG5)[ip - inode]; ! mapseg5(xitimes, xitdesc); ! if (ip->i_flag & (IUPD | IACC | ICHG)) { ip->i_flag |= IMOD; if (ip->i_flag & IACC) ic2->ic_atime = time.tv_sec; --- 353,371 ---- register struct inode *ip; register struct stat *sb; { + register struct icommon2 *ic2; ! #ifdef EXTERNALITIMES ! mapseg5(xitimes, xitdesc); ! ic2 = &((struct icommon2 *)SEG5)[ip - inode]; #else ! ic2 = &ip->i_ic2; ! #endif ! /* ! * inlined ITIMES which takes advantage of the common times pointer. ! */ ! if (ip->i_flag & (IUPD|IACC|ICHG)) { ip->i_flag |= IMOD; if (ip->i_flag & IACC) ic2->ic_atime = time.tv_sec; *************** *** 332,338 **** ic2->ic_mtime = time.tv_sec; if (ip->i_flag & ICHG) ic2->ic_ctime = time.tv_sec; ! ip->i_flag &= ~(IACC | IUPD | ICHG); } sb->st_dev = ip->i_dev; sb->st_ino = ip->i_number; --- 373,379 ---- ic2->ic_mtime = time.tv_sec; if (ip->i_flag & ICHG) ic2->ic_ctime = time.tv_sec; ! ip->i_flag &= ~(IUPD|IACC|ICHG); } sb->st_dev = ip->i_dev; sb->st_ino = ip->i_number; *************** *** 353,359 **** * blocks are too tough to do; it's not worth the effort. */ sb->st_blocks = btodb(ip->i_size + MAXBSIZE - 1); ! sb->st_spare4[0] = sb->st_spare4[1] = 0; normalseg5(); #endif return (0); --- 394,404 ---- * blocks are too tough to do; it's not worth the effort. */ sb->st_blocks = btodb(ip->i_size + MAXBSIZE - 1); ! sb->st_flags = ip->i_flags; ! sb->st_spare4[0] = 0; ! sb->st_spare4[1] = 0; ! sb->st_spare4[2] = 0; ! #ifdef EXTERNALITIMES normalseg5(); #endif return (0); *************** *** 368,375 **** dev_t dev; int (*cfunc)(); ! if (fp->f_flag & (FSHLOCK|FEXLOCK)) ! ino_unlock(fp, FSHLOCK|FEXLOCK); flag = fp->f_flag; dev = (dev_t)ip->i_rdev; mode = ip->i_mode & IFMT; --- 413,420 ---- dev_t dev; int (*cfunc)(); ! if (fp->f_flag & (FSHLOCK | FEXLOCK)) ! ino_unlock(fp, FSHLOCK | FEXLOCK); flag = fp->f_flag; dev = (dev_t)ip->i_rdev; mode = ip->i_mode & IFMT; *************** *** 500,507 **** --- 545,554 ---- sleep((caddr_t)&ip->i_shlockc, PLOCK); goto again; } + #ifdef DIAGNOSTIC if (fp->f_flag & FEXLOCK) panic("ino_lock"); + #endif if (cmd & LOCK_EX) { cmd &= ~LOCK_SH; ip->i_exlockc++; *************** *** 532,538 **** flags = ip->i_flag; if (kind & FSHLOCK) { if ((flags & ISHLOCK) == 0) ! panic("ino_unlock: SHLOCK"); if (--ip->i_shlockc == 0) { ip->i_flag &= ~ISHLOCK; if (flags & ILWAIT) --- 579,585 ---- flags = ip->i_flag; if (kind & FSHLOCK) { if ((flags & ISHLOCK) == 0) ! panic("SHLOCK"); if (--ip->i_shlockc == 0) { ip->i_flag &= ~ISHLOCK; if (flags & ILWAIT) *************** *** 542,548 **** } if (kind & FEXLOCK) { if ((flags & IEXLOCK) == 0) ! panic("ino_unlock: EXLOCK"); if (--ip->i_exlockc == 0) { ip->i_flag &= ~(IEXLOCK|ILWAIT); if (flags & ILWAIT) --- 589,595 ---- } if (kind & FEXLOCK) { if ((flags & IEXLOCK) == 0) ! panic("EXLOCK"); if (--ip->i_exlockc == 0) { ip->i_flag &= ~(IEXLOCK|ILWAIT); if (flags & ILWAIT) *************** *** 553,561 **** } /* ! * Openi called to allow handler ! * of special files to initialize and * validate before actual IO. */ openi(ip, mode) register struct inode *ip; --- 600,610 ---- } /* ! * Openi called to allow handler of special files to initialize and * validate before actual IO. + * + * Eventually the check for 'securelevel' and the MNT_NODEV mount option + * will go here. */ openi(ip, mode) register struct inode *ip; *** /usr/src/sys/sys/sys_net.c.old Sun Jan 3 00:50:01 1993 --- /usr/src/sys/sys/sys_net.c Thu Dec 15 20:03:22 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * %W% (Berkeley) %G% * 2.11BSD - map the I/O region with sufficient UMRs. this precludes * drivers such as the DEUNA from allocating a UMR per packet. * sms - 9/8/90 --- 3,13 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)sys_net.c 1.3 (2.11BSD GTE) 12/15/94 ! * ! * Change uiomove calling convention. The r/w type is now encapsulated ! * in the uio structure now. sms - 11/26/94 ! * * 2.11BSD - map the I/O region with sufficient UMRs. this precludes * drivers such as the DEUNA from allocating a UMR per packet. * sms - 9/8/90 *************** *** 262,271 **** * 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; --- 266,274 ---- * The 4.3BSD uio/iovec paradigm adopted, ureadc() and uwritec() inlined * at that time to speed things up. 3/90 sms */ ! uiomove(cp, n, uio) caddr_t cp; u_int n; register struct uio *uio; { register struct iovec *iov; *************** *** 288,294 **** 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); --- 291,297 ---- cnt = n; count = cnt; if ((cnt | (int)cp | (int)iov->iov_base) & 1) { ! if (uio->uio_rw == UIO_READ) { while (cnt--) if (subyte(iov->iov_base++, *cp++) < 0) return (EFAULT); *************** *** 303,309 **** cnt = count; /* use register */ } else { ! if (rw == UIO_READ) error = copyout(cp, iov->iov_base, cnt); else error = copyin(iov->iov_base, cp, cnt); --- 306,312 ---- cnt = count; /* use register */ } else { ! if (uio->uio_rw == UIO_READ) error = copyout(cp, iov->iov_base, cnt); else error = copyin(iov->iov_base, cp, cnt); *** /usr/src/sys/sys/sys_pipe.c.old Sun Dec 27 00:19:33 1992 --- /usr/src/sys/sys/sys_pipe.c Tue Nov 29 22:16:47 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)sys_pipe.c 1.2 (2.11BSD GTE) 12/27/92 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)sys_pipe.c 1.3 (2.11BSD GTE) 11/26/94 */ #include "param.h" *************** *** 85,104 **** 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; --- 85,105 ---- ip->i_flag = IACC|IUPD|ICHG|IPIPE; } ! pipe_rw(fp, uio, flag) register struct file *fp; register struct uio *uio; + int flag; { ! if (uio->uio_rw == UIO_READ) ! return (readp(fp, uio, flag)); ! return (writep(fp, uio, flag)); } ! readp(fp, uio, flag) register struct file *fp; register struct uio *uio; + int flag; { register struct inode *ip; int error; *************** *** 108,114 **** /* Very conservative locking. */ ILOCK(ip); ! /* If nothing in the pipe, wait (unless FNDELAY is set). */ if (ip->i_size == 0) { /* * If there are not both reader and writer active, --- 109,115 ---- /* Very conservative locking. */ ILOCK(ip); ! /* If nothing in the pipe, wait (unless FNONBLOCK is set). */ if (ip->i_size == 0) { /* * If there are not both reader and writer active, *************** *** 117,123 **** 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); --- 118,124 ---- IUNLOCK(ip); if (ip->i_count != 2) return (0); ! if (fp->f_flag & FNONBLOCK) return (EWOULDBLOCK); ip->i_mode |= IREAD; sleep((caddr_t)ip+2, PPIPE); *************** *** 124,132 **** goto loop; } - /* Read and return */ uio->uio_offset = fp->f_offset; ! error = rwip(ip, uio, UIO_READ); fp->f_offset = uio->uio_offset; /* --- 125,132 ---- goto loop; } uio->uio_offset = fp->f_offset; ! error = rwip(ip, uio, flag); fp->f_offset = uio->uio_offset; /* *************** *** 150,158 **** return (error); } ! writep(fp, uio) struct file *fp; register struct uio *uio; { register struct inode *ip; register int c; --- 150,159 ---- return (error); } ! writep(fp, uio, flag) struct file *fp; register struct uio *uio; + int flag; { register struct inode *ip; register int c; *************** *** 161,167 **** 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; } --- 162,168 ---- ip = (struct inode *)fp->f_data; c = uio->uio_resid; ILOCK(ip); ! if ((fp->f_flag & FNONBLOCK) && ip->i_size + c >= MAXPIPSIZ) { error = EWOULDBLOCK; goto done; } *************** *** 204,210 **** 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); --- 205,211 ---- uio->uio_offset = ip->i_size; uio->uio_resid = MIN((u_int)c, (u_int)MAXPIPSIZ); c -= uio->uio_resid; ! error = rwip(ip, uio, flag); if (ip->i_mode&IREAD) { ip->i_mode &= ~IREAD; wakeup((caddr_t)ip+2); *** /usr/src/sys/sys/syscalls.c.old Thu Apr 21 19:47:53 1994 --- /usr/src/sys/sys/syscalls.c Thu Dec 15 20:05:15 1994 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)syscalls.c 1.3 (2.11BSD GTE) 4/21/94 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)syscalls.c 1.4 (2.11BSD GTE) 11/26/94 */ /* *************** *** 28,35 **** "mknod", /* 14 = mknod */ "chmod", /* 15 = chmod */ "chown", /* 16 = chown; now 3 args */ ! "old break - nosys", /* 17 = old break */ ! "old stat - nosys", /* 18 = old stat */ "lseek", /* 19 = lseek */ "getpid", /* 20 = getpid */ "mount", /* 21 = mount */ --- 28,35 ---- "mknod", /* 14 = mknod */ "chmod", /* 15 = chmod */ "chown", /* 16 = chown; now 3 args */ ! "chflags", /* 17 = chflags */ ! "fchflags", /* 18 = fchflags */ "lseek", /* 19 = lseek */ "getpid", /* 20 = getpid */ "mount", /* 21 = mount */ *************** *** 102,111 **** "sethostname", /* 88 = sethostname */ "getdtablesize", /* 89 = getdtablesize */ "dup2", /* 90 = dup2 */ ! "getdopt", /* 91 = getdopt */ "fcntl", /* 92 = fcntl */ "select", /* 93 = select */ ! "setdopt", /* 94 = setdopt */ "fsync", /* 95 = fsync */ "setpriority", /* 96 = setpriority */ "socket", /* 97 = socket */ --- 102,111 ---- "sethostname", /* 88 = sethostname */ "getdtablesize", /* 89 = getdtablesize */ "dup2", /* 90 = dup2 */ ! "nosys", /* 91 = unused */ "fcntl", /* 92 = fcntl */ "select", /* 93 = select */ ! "nosys", /* 94 = unused */ "fsync", /* 95 = fsync */ "setpriority", /* 96 = setpriority */ "socket", /* 97 = socket */