All of this is cosmetic. prototypes, #includes, printfs and so on. Makes

GCC a lot more silent.
This commit is contained in:
Poul-Henning Kamp 1994-10-02 17:35:40 +00:00
parent abd358cd49
commit 797f2d22f0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3308
36 changed files with 1004 additions and 761 deletions

View File

@ -37,7 +37,7 @@
* SUCH DAMAGE.
*
* @(#)kern_acct.c 8.1 (Berkeley) 6/14/93
* $Id$
* $Id: kern_acct.c,v 1.5 1994/09/26 21:09:00 davidg Exp $
*/
#include <sys/param.h>
@ -105,7 +105,8 @@ acct(p, uap, retval)
int error;
/* Make sure that the caller is root. */
if (error = suser(p->p_ucred, &p->p_acflag))
error = suser(p->p_ucred, &p->p_acflag);
if (error)
return (error);
/*
@ -114,7 +115,8 @@ acct(p, uap, retval)
*/
if (uap->path != NULL) {
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, p);
if (error = vn_open(&nd, FWRITE, 0))
error = vn_open(&nd, FWRITE, 0);
if (error)
return (error);
VOP_UNLOCK(nd.ni_vp);
if (nd.ni_vp->v_type != VREG) {

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
* $Id: kern_clock.c,v 1.7 1994/09/25 19:33:34 phk Exp $
* $Id: kern_clock.c,v 1.8 1994/09/29 00:52:06 wollman Exp $
*/
/* Portions of this software are covered by the following: */
@ -63,8 +63,10 @@
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/timex.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
#include <machine/clock.h>

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
* $Id: kern_descrip.c,v 1.4 1994/09/02 10:17:30 davidg Exp $
* $Id: kern_descrip.c,v 1.5 1994/09/25 19:33:35 phk Exp $
*/
#include <sys/param.h>
@ -55,6 +55,7 @@
#include <sys/syslog.h>
#include <sys/unistd.h>
#include <sys/resourcevar.h>
#include <vm/vm.h>
int finishdup(struct filedesc *fdp, int old, int new, int *retval);
/*

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kern_exec.c,v 1.8 1994/09/24 16:58:43 davidg Exp $
* $Id: kern_exec.c,v 1.9 1994/09/25 19:33:36 phk Exp $
*/
#include <sys/param.h>
@ -37,6 +37,7 @@
#include <sys/resourcevar.h>
#include <sys/kernel.h>
#include <sys/mount.h>
#include <sys/filedesc.h>
#include <sys/file.h>
#include <sys/acct.h>
#include <sys/exec.h>
@ -46,6 +47,7 @@
#include <sys/mman.h>
#include <sys/malloc.h>
#include <sys/syslog.h>
#include <sys/shm.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
@ -289,7 +291,7 @@ execve(p, uap, retval)
p->p_acflag &= ~AFORK;
/* Set entry address */
setregs(p, iparams->entry_addr, stack_base);
setregs(p, iparams->entry_addr, (u_long)stack_base);
/*
* free various allocated resources

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
* $Id: kern_exit.c,v 1.6 1994/09/12 11:27:03 davidg Exp $
* $Id: kern_exit.c,v 1.7 1994/09/25 19:33:37 phk Exp $
*/
#include <sys/param.h>
@ -56,7 +56,10 @@
#include <sys/syslog.h>
#include <sys/malloc.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/ptrace.h>
#include <sys/shm.h>
#include <sys/filedesc.h>
#include <machine/cpu.h>
#ifdef COMPAT_43
@ -67,9 +70,6 @@
#include <vm/vm.h>
#include <vm/vm_kern.h>
__dead void cpu_exit __P((struct proc *));
__dead void exit1 __P((struct proc *, int));
/*
* exit --
* Death of process.

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_ktrace.c 8.2 (Berkeley) 9/23/93
* $Id: kern_ktrace.c,v 1.3 1994/08/02 07:42:02 davidg Exp $
* $Id: kern_ktrace.c,v 1.4 1994/08/18 22:35:01 wollman Exp $
*/
#ifdef KTRACE
@ -46,8 +46,6 @@
#include <sys/malloc.h>
#include <sys/syslog.h>
void ktrwrite __P((struct vnode *, struct ktr_header *));
struct ktr_header *
ktrgetheader(type)
int type;
@ -254,7 +252,8 @@ ktrace(curp, uap, retval)
* an operation which requires a file argument.
*/
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, curp);
if (error = vn_open(&nd, FREAD|FWRITE, 0)) {
error = vn_open(&nd, FREAD|FWRITE, 0);
if (error) {
curp->p_traceflag &= ~KTRFAC_ACTIVE;
return (error);
}

View File

@ -105,7 +105,8 @@ lkmcopen(dev, flag, devtype, p)
* Sleep pending unlock; we use tsleep() to allow
* an alarm out of the open.
*/
if (error = tsleep((caddr_t)&lkm_v, TTIPRI|PCATCH, "lkmopn", 0))
error = tsleep((caddr_t)&lkm_v, TTIPRI|PCATCH, "lkmopn", 0);
if (error)
return(error); /* leave LKM_WANT set -- no problem */
}
lkm_v |= LKM_ALLOC;
@ -181,7 +182,6 @@ lkmcioctl(dev, cmd, data, flag)
struct lmc_loadbuf *loadbufp;
struct lmc_unload *unloadp;
struct lmc_stat *statp;
int (*funcp)();
char istr[MAXLKMNAME];
switch(cmd) {
@ -240,7 +240,9 @@ lkmcioctl(dev, cmd, data, flag)
}
/* copy in buffer full of data */
if (err = copyin((caddr_t)loadbufp->data, (caddr_t)curp->area + curp->offset, i))
err = copyin((caddr_t)loadbufp->data,
(caddr_t)curp->area + curp->offset, i);
if (err)
break;
if ((curp->offset + i) < curp->size) {
@ -291,7 +293,8 @@ lkmcioctl(dev, cmd, data, flag)
curp->entry = (int (*)()) (*((int *) (data)));
/* call entry(load)... (assigns "private" portion) */
if (err = (*(curp->entry))(curp, LKM_E_LOAD, LKM_VERSION)) {
err = (*(curp->entry))(curp, LKM_E_LOAD, LKM_VERSION);
if (err) {
/*
* Module may refuse loading or may have a
* version mismatch...
@ -320,7 +323,8 @@ lkmcioctl(dev, cmd, data, flag)
* Copy name and lookup id from all loaded
* modules. May fail.
*/
if (err = copyinstr(unloadp->name, istr, MAXLKMNAME-1, NULL))
err =copyinstr(unloadp->name, istr, MAXLKMNAME-1, NULL);
if (err)
break;
/*

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94
* $Id$
* $Id: kern_malloc.c,v 1.3 1994/08/02 07:42:04 davidg Exp $
*/
#include <sys/param.h>
@ -196,7 +196,7 @@ malloc(size, type, flags)
memname[freep->type] : "???";
if (kbp->kb_next &&
!kernacc(kbp->kb_next, sizeof(struct freelist), 0)) {
printf("%s of object 0x%x size %d %s %s (invalid addr 0x%x)\n",
printf("%s of object %p size %ld %s %s (invalid addr %p)\n",
"Data modified on freelist: word 2.5", va, size,
"previous type", savedtype, kbp->kb_next);
kbp->kb_next = NULL;
@ -215,7 +215,7 @@ malloc(size, type, flags)
for (lp = (long *)va; lp < end; lp++) {
if (*lp == WEIRD_ADDR)
continue;
printf("%s %d of object 0x%x size %d %s %s (0x%x != 0x%x)\n",
printf("%s %d of object %p size %ld %s %s (0x%lx != 0x%x)\n",
"Data modified on freelist: word", lp - (long *)va,
va, size, "previous type", savedtype, *lp, WEIRD_ADDR);
break;
@ -308,7 +308,7 @@ free(addr, type)
for (cp = kbp->kb_next; cp; cp = *(caddr_t *)cp) {
if (addr != cp)
continue;
printf("multiply freed item 0x%x\n", addr);
printf("multiply freed item %p\n", addr);
panic("free: duplicated free");
}
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_synch.c 8.6 (Berkeley) 1/21/94
* $Id: kern_synch.c,v 1.5 1994/09/25 19:33:44 phk Exp $
* $Id: kern_synch.c,v 1.6 1994/10/02 04:45:50 davidg Exp $
*/
#include <sys/param.h>
@ -46,7 +46,8 @@
#include <sys/buf.h>
#include <sys/signalvar.h>
#include <sys/resourcevar.h>
#include <sys/vmmeter.h>
#include <sys/signalvar.h>
#include <vm/vm.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
@ -420,7 +421,7 @@ sleep(ident, priority)
#ifdef DIAGNOSTIC
if (priority > PZERO) {
printf("sleep called with priority %d > PZERO, wchan: %x\n",
printf("sleep called with priority %d > PZERO, wchan: %p\n",
priority, ident);
panic("old sleep");
}
@ -504,9 +505,10 @@ wakeup(ident)
s = splhigh();
qp = &slpque[LOOKUP(ident)];
restart:
for (q = &qp->sq_head; p = *q; ) {
for (q = &qp->sq_head; *q; ) {
p = *q;
#ifdef DIAGNOSTIC
if (p->p_back || p->p_stat != SSLEEP && p->p_stat != SSTOP)
if (p->p_back || (p->p_stat != SSLEEP && p->p_stat != SSTOP))
panic("wakeup");
#endif
if (p->p_wchan == ident) {

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
* $Id: kern_sysctl.c,v 1.14 1994/09/21 03:46:46 wollman Exp $
* $Id: kern_sysctl.c,v 1.15 1994/09/23 19:07:17 wollman Exp $
*/
/*
@ -102,7 +102,8 @@ __sysctl(p, uap, retval)
*/
if (uap->namelen > CTL_MAXNAME || uap->namelen < 2)
return (EINVAL);
if (error = copyin(uap->name, &name, uap->namelen * sizeof(int)))
error = copyin(uap->name, &name, uap->namelen * sizeof(int));
if (error)
return (error);
switch (name[0]) {
@ -571,7 +572,8 @@ sysctl_file(where, sizep)
*sizep = 0;
return (0);
}
if (error = copyout((caddr_t)&filehead, where, sizeof(filehead)))
error = copyout((caddr_t)&filehead, where, sizeof(filehead));
if (error)
return (error);
buflen -= sizeof(filehead);
where += sizeof(filehead);
@ -584,7 +586,8 @@ sysctl_file(where, sizep)
*sizep = where - start;
return (ENOMEM);
}
if (error = copyout((caddr_t)fp, where, sizeof (struct file)))
error = copyout((caddr_t)fp, where, sizeof (struct file));
if (error)
return (error);
buflen -= sizeof(struct file);
where += sizeof(struct file);
@ -661,11 +664,13 @@ sysctl_doproc(name, namelen, where, sizep)
}
if (buflen >= sizeof(struct kinfo_proc)) {
fill_eproc(p, &eproc);
if (error = copyout((caddr_t)p, &dp->kp_proc,
sizeof(struct proc)))
error = copyout((caddr_t)p, &dp->kp_proc,
sizeof(struct proc));
if (error)
return (error);
if (error = copyout((caddr_t)&eproc, &dp->kp_eproc,
sizeof(eproc)))
error = copyout((caddr_t)&eproc, &dp->kp_eproc,
sizeof(eproc));
if (error)
return (error);
dp++;
buflen -= sizeof(struct kinfo_proc);

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
* $Id: kern_clock.c,v 1.7 1994/09/25 19:33:34 phk Exp $
* $Id: kern_clock.c,v 1.8 1994/09/29 00:52:06 wollman Exp $
*/
/* Portions of this software are covered by the following: */
@ -63,8 +63,10 @@
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/timex.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
#include <machine/clock.h>

View File

@ -31,11 +31,12 @@
* SUCH DAMAGE.
*
* @(#)kern_time.c 8.1 (Berkeley) 6/10/93
* $Id: kern_time.c,v 1.3 1994/08/02 07:42:21 davidg Exp $
* $Id: kern_time.c,v 1.4 1994/09/25 19:33:45 phk Exp $
*/
#include <sys/param.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/proc.h>
@ -43,10 +44,6 @@
#include <machine/cpu.h>
void timevaladd __P((struct timeval *, struct timeval *));
void timevalsub __P((struct timeval *, struct timeval *));
void timevalfix __P((struct timeval *));
/*
* Time of day and interval timer support.
*

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
* $Id: kern_clock.c,v 1.7 1994/09/25 19:33:34 phk Exp $
* $Id: kern_clock.c,v 1.8 1994/09/29 00:52:06 wollman Exp $
*/
/* Portions of this software are covered by the following: */
@ -63,8 +63,10 @@
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/timex.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
#include <machine/clock.h>

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93
* $Id: kern_xxx.c,v 1.6 1994/09/19 21:15:14 ache Exp $
* $Id: kern_xxx.c,v 1.7 1994/09/25 19:33:46 phk Exp $
*/
#include <sys/param.h>
@ -42,6 +42,7 @@
#include <vm/vm.h>
#include <sys/sysctl.h>
#include <sys/utsname.h>
#include <sys/signalvar.h>
struct reboot_args {
int opt;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)subr_log.c 8.1 (Berkeley) 6/10/93
* $Id: subr_log.c,v 1.3 1994/08/02 07:42:29 davidg Exp $
* $Id: subr_log.c,v 1.4 1994/09/25 19:33:47 phk Exp $
*/
/*
@ -45,6 +45,7 @@
#include <sys/ioctl.h>
#include <sys/msgbuf.h>
#include <sys/file.h>
#include <sys/signalvar.h>
#define LOG_RDPRI (PZERO + 1)

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
* $Id: subr_prf.c,v 1.5 1994/08/27 16:14:27 davidg Exp $
* $Id: subr_prf.c,v 1.6 1994/09/28 19:22:32 phk Exp $
*/
#include <sys/param.h>
@ -270,12 +270,11 @@ void
logpri(level)
int level;
{
register int ch;
register char *p;
putchar('<', TOLOG, NULL);
for (p = ksprintn((u_long)level, 10, NULL); ch = *p--;)
putchar(ch, TOLOG, NULL);
for (p = ksprintn((u_long)level, 10, NULL); *p;)
putchar(*p--, TOLOG, NULL);
putchar('>', TOLOG, NULL);
}
@ -401,13 +400,14 @@ reswitch: switch (ch = *(u_char *)fmt++) {
case 'b':
ul = va_arg(ap, int);
p = va_arg(ap, char *);
for (q = ksprintn(ul, *p++, NULL); ch = *q--;)
putchar(ch, flags, tp);
for (q = ksprintn(ul, *p++, NULL); *q;)
putchar(*q--, flags, tp);
if (!ul)
break;
for (tmp = 0; n = *p++;) {
for (tmp = 0; *p;) {
n = *p++;
if (ul & (1 << (n - 1))) {
putchar(tmp ? ',' : '<', flags, tp);
for (; (n = *p) > ' '; ++p)
@ -429,8 +429,8 @@ reswitch: switch (ch = *(u_char *)fmt++) {
break;
case 's':
p = va_arg(ap, char *);
while (ch = *p++)
putchar(ch, flags, tp);
while (*p)
putchar(*p++, flags, tp);
break;
case 'd':
ul = lflag ? va_arg(ap, long) : va_arg(ap, int);
@ -462,8 +462,8 @@ number: p = ksprintn(ul, base, &tmp);
if (width && (width -= tmp) > 0)
while (width--)
putchar(padc, flags, tp);
while (ch = *p--)
putchar(ch, flags, tp);
while (*p)
putchar(*p--, flags, tp);
break;
default:
putchar('%', flags, tp);
@ -549,9 +549,8 @@ reswitch: switch (ch = *(u_char *)fmt++) {
break;
case 's':
p = va_arg(ap, char *);
while (*bp++ = *p++)
continue;
--bp;
while (*p)
*bp++ = *p++;
break;
case 'd':
ul = lflag ? va_arg(ap, long) : va_arg(ap, int);
@ -575,8 +574,8 @@ reswitch: switch (ch = *(u_char *)fmt++) {
case 'x':
ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int);
base = 16;
number: for (p = ksprintn(ul, base, NULL); ch = *p--;)
*bp++ = ch;
number: for (p = ksprintn(ul, base, NULL); *p;)
*bp++ = *p--;
break;
default:
*bp++ = '%';

View File

@ -45,7 +45,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: subr_rlist.c,v 1.5 1993/12/22 12:51:39 davidg Exp $
* $Id: subr_rlist.c,v 1.6 1994/08/13 03:50:24 wollman Exp $
*/
#include <sys/param.h>
@ -53,6 +53,7 @@
#include <sys/cdefs.h>
#include <sys/malloc.h>
#include <sys/rlist.h>
#include <sys/proc.h>
#include <vm/vm.h>
#include <vm/vm_map.h>

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
* $Id: sys_generic.c,v 1.5 1994/09/02 15:06:39 davidg Exp $
* $Id: sys_generic.c,v 1.6 1994/09/25 19:33:48 phk Exp $
*/
#include <sys/param.h>
@ -45,6 +45,9 @@
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/proc.h>
#include <sys/stat.h>
#include <sys/signalvar.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/uio.h>
#include <sys/kernel.h>

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)sys_socket.c 8.1 (Berkeley) 6/10/93
* $Id$
* $Id: sys_socket.c,v 1.3 1994/08/02 07:42:42 davidg Exp $
*/
#include <sys/param.h>
@ -41,6 +41,7 @@
#include <sys/mbuf.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/socketvar.h>
#include <sys/ioctl.h>
#include <sys/stat.h>

View File

@ -1,4 +1,4 @@
/* $Id: sysv_msg.c,v 1.1 1994/09/13 14:46:57 dfr Exp $ */
/* $Id: sysv_msg.c,v 1.2 1994/09/17 13:24:16 davidg Exp $ */
/*
* Implementation of SVID messages
@ -41,7 +41,6 @@ void
msginit()
{
register int i;
vm_offset_t whocares1, whocares2;
/*
* msginfo.msgssz should be a power of two for efficiency reasons.
@ -154,7 +153,7 @@ msgctl(p, uap, retval)
int cmd = uap->cmd;
struct msqid_ds *user_msqptr = uap->user_msqptr;
struct ucred *cred = p->p_ucred;
int i, rval, eval;
int rval, eval;
struct msqid_ds msqbuf;
register struct msqid_ds *msqptr;

View File

@ -1,4 +1,4 @@
/* $Id: sysv_sem.c,v 1.1 1994/09/13 14:47:00 dfr Exp $ */
/* $Id: sysv_sem.c,v 1.2 1994/09/17 13:24:17 davidg Exp $ */
/*
* Implementation of SVID semaphores
@ -25,7 +25,6 @@ void
seminit()
{
register int i;
vm_offset_t whocares1, whocares2;
if (sema == NULL)
panic("sema is NULL");
@ -582,7 +581,7 @@ semop(p, uap, retval)
struct sem_undo *suptr = NULL;
struct ucred *cred = p->p_ucred;
int i, j, eval;
int all_ok, do_wakeup, do_undos;
int do_wakeup, do_undos;
#ifdef SEM_DEBUG
printf("call to semop(%d, 0x%x, %d)\n", semid, sops, nsops);

View File

@ -1,4 +1,4 @@
/* $Id: sysv_shm.c,v 1.1 1994/09/13 14:47:03 dfr Exp $ */
/* $Id: sysv_shm.c,v 1.2 1994/09/16 17:43:22 dfr Exp $ */
/* $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $ */
/*
@ -212,8 +212,9 @@ shmat(p, uap, retval)
shmseg = shm_find_segment_by_shmid(uap->shmid);
if (shmseg == NULL)
return EINVAL;
if (error = ipcperm(cred, &shmseg->shm_perm,
(uap->shmflg & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W))
error = ipcperm(cred, &shmseg->shm_perm,
(uap->shmflg & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W);
if (error)
return error;
for (i = 0; i < shminfo.shmseg; i++) {
if (shmmap_s->shmid == -1)
@ -277,7 +278,7 @@ oshmctl(p, uap, retval)
int *retval;
{
#ifdef COMPAT_43
int error, segnum;
int error;
struct ucred *cred = p->p_ucred;
struct shmid_ds *shmseg;
struct oshmid_ds outbuf;
@ -287,7 +288,8 @@ oshmctl(p, uap, retval)
return EINVAL;
switch (uap->cmd) {
case IPC_STAT:
if (error = ipcperm(cred, &shmseg->shm_perm, IPC_R))
error = ipcperm(cred, &shmseg->shm_perm, IPC_R);
if (error)
return error;
outbuf.shm_perm = shmseg->shm_perm;
outbuf.shm_segsz = shmseg->shm_segsz;
@ -298,7 +300,8 @@ oshmctl(p, uap, retval)
outbuf.shm_dtime = shmseg->shm_dtime;
outbuf.shm_ctime = shmseg->shm_ctime;
outbuf.shm_handle = shmseg->shm_internal;
if (error = copyout((caddr_t)&outbuf, uap->ubuf, sizeof(outbuf)))
error = copyout((caddr_t)&outbuf, uap->ubuf, sizeof(outbuf));
if (error)
return error;
break;
default:
@ -321,7 +324,7 @@ shmctl(p, uap, retval)
struct shmctl_args *uap;
int *retval;
{
int error, segnum;
int error;
struct ucred *cred = p->p_ucred;
struct shmid_ds inbuf;
struct shmid_ds *shmseg;
@ -331,15 +334,19 @@ shmctl(p, uap, retval)
return EINVAL;
switch (uap->cmd) {
case IPC_STAT:
if (error = ipcperm(cred, &shmseg->shm_perm, IPC_R))
error = ipcperm(cred, &shmseg->shm_perm, IPC_R);
if (error)
return error;
if (error = copyout((caddr_t)shmseg, uap->ubuf, sizeof(inbuf)))
error = copyout((caddr_t)shmseg, uap->ubuf, sizeof(inbuf));
if (error)
return error;
break;
case IPC_SET:
if (error = ipcperm(cred, &shmseg->shm_perm, IPC_M))
error = ipcperm(cred, &shmseg->shm_perm, IPC_M);
if (error)
return error;
if (error = copyin(uap->ubuf, (caddr_t)&inbuf, sizeof(inbuf)))
error = copyin(uap->ubuf, (caddr_t)&inbuf, sizeof(inbuf));
if (error)
return error;
shmseg->shm_perm.uid = inbuf.shm_perm.uid;
shmseg->shm_perm.gid = inbuf.shm_perm.gid;
@ -349,7 +356,8 @@ shmctl(p, uap, retval)
shmseg->shm_ctime = time.tv_sec;
break;
case IPC_RMID:
if (error = ipcperm(cred, &shmseg->shm_perm, IPC_M))
error = ipcperm(cred, &shmseg->shm_perm, IPC_M);
if (error)
return error;
shmseg->shm_perm.key = IPC_PRIVATE;
shmseg->shm_perm.mode |= SHMSEG_REMOVED;
@ -393,12 +401,13 @@ shmget_existing(p, uap, mode, segnum, retval)
* allocation failed or it was freed).
*/
shmseg->shm_perm.mode |= SHMSEG_WANTED;
if (error =
tsleep((caddr_t)shmseg, PLOCK | PCATCH, "shmget", 0))
error = tsleep((caddr_t)shmseg, PLOCK | PCATCH, "shmget", 0);
if (error)
return error;
return EAGAIN;
}
if (error = ipcperm(cred, &shmseg->shm_perm, mode))
error = ipcperm(cred, &shmseg->shm_perm, mode);
if (error)
return error;
if (uap->size && uap->size > shmseg->shm_segsz)
return EINVAL;
@ -490,7 +499,6 @@ shmget(p, uap, retval)
int *retval;
{
int segnum, mode, error;
struct shmid_ds *shmseg;
mode = uap->shmflg & ACCESSPERMS;
if (uap->key != IPC_PRIVATE) {
@ -546,7 +554,6 @@ shmexit(p)
struct proc *p;
{
struct shmmap_state *shmmap_s;
struct shmid_ds *shmseg;
int i;
shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
* $Id: tty.c,v 1.5 1994/08/02 07:42:46 davidg Exp $
* $Id: tty.c,v 1.6 1994/08/18 09:16:21 davidg Exp $
*/
#include <sys/param.h>
@ -53,6 +53,8 @@
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/syslog.h>
#include <sys/signalvar.h>
#include <sys/resourcevar.h>
#include <vm/vm.h>
@ -214,8 +216,8 @@ ttyclose(tp)
/* Is 'c' a line delimiter ("break" character)? */
#define TTBREAKC(c) \
((c) == '\n' || ((c) == cc[VEOF] || \
(c) == cc[VEOL] || (c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE)
((c) == '\n' || (((c) == cc[VEOF] || \
(c) == cc[VEOL] || (c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE))
/*
@ -251,7 +253,8 @@ ttyinput(c, tp)
/* Handle exceptional conditions (break, parity, framing). */
cc = tp->t_cc;
iflag = tp->t_iflag;
if (err = (ISSET(c, TTY_ERRORMASK))) {
err = (ISSET(c, TTY_ERRORMASK));
if (err) {
CLR(c, TTY_ERRORMASK);
if (ISSET(err, TTY_FE) && !c) { /* Break. */
if (ISSET(iflag, IGNBRK))
@ -262,8 +265,8 @@ ttyinput(c, tp)
c = cc[VINTR];
else if (ISSET(iflag, PARMRK))
goto parmrk;
} else if (ISSET(err, TTY_PE) &&
ISSET(iflag, INPCK) || ISSET(err, TTY_FE)) {
} else if ((ISSET(err, TTY_PE) && ISSET(iflag, INPCK))
|| ISSET(err, TTY_FE)) {
if (ISSET(iflag, IGNPAR))
goto endcase;
else if (ISSET(iflag, PARMRK)) {
@ -667,8 +670,8 @@ ttioctl(tp, cmd, data, flag)
(p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
(p->p_sigmask & sigmask(SIGTTOU)) == 0) {
pgsignal(p->p_pgrp, SIGTTOU, 1);
if (error = ttysleep(tp,
&lbolt, TTOPRI | PCATCH, ttybg, 0))
error = ttysleep(tp, &lbolt, TTOPRI | PCATCH, ttybg, 0);
if (error)
return (error);
}
break;
@ -718,7 +721,8 @@ ttioctl(tp, cmd, data, flag)
constty = NULL;
break;
case TIOCDRAIN: /* wait till output drained */
if (error = ttywait(tp))
error = ttywait(tp);
if (error)
return (error);
break;
case TIOCGETA: { /* get termios struct */
@ -760,7 +764,8 @@ ttioctl(tp, cmd, data, flag)
s = spltty();
if (cmd == TIOCSETAW || cmd == TIOCSETAF) {
if (error = ttywait(tp)) {
error = ttywait(tp);
if (error) {
splx(s);
return (error);
}
@ -870,8 +875,8 @@ ttioctl(tp, cmd, data, flag)
case TIOCSCTTY: /* become controlling tty */
/* Session ctty vnode pointer set in vnode layer. */
if (!SESS_LEADER(p) ||
(p->p_session->s_ttyvp || tp->t_session) &&
(tp->t_session != p->p_session))
((p->p_session->s_ttyvp || tp->t_session) &&
(tp->t_session != p->p_session)))
return (EPERM);
tp->t_session = p->p_session;
tp->t_pgrp = p->p_pgrp;
@ -923,8 +928,8 @@ ttselect(device, rw, p)
switch (rw) {
case FREAD:
nread = ttnread(tp);
if (nread > 0 || !ISSET(tp->t_cflag, CLOCAL) &&
!ISSET(tp->t_state, TS_CARR_ON))
if (nread > 0 || (!ISSET(tp->t_cflag, CLOCAL) &&
!ISSET(tp->t_state, TS_CARR_ON)))
goto win;
selrecord(p, &tp->t_rsel);
break;
@ -970,8 +975,8 @@ ttywait(tp)
&& tp->t_oproc) {
(*tp->t_oproc)(tp);
SET(tp->t_state, TS_ASLEEP);
if (error = ttysleep(tp,
&tp->t_outq, TTOPRI | PCATCH, ttyout, 0))
error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, ttyout, 0);
if (error)
break;
}
splx(s);
@ -1054,10 +1059,10 @@ ttyblock(tp)
* Block further input iff: current input > threshold
* AND input is available to user program.
*/
if (total >= TTYHOG / 2 &&
if ((total >= TTYHOG / 2 &&
!ISSET(tp->t_state, TS_TBLOCK) &&
!ISSET(tp->t_lflag, ICANON) || tp->t_canq.c_cc > 0 &&
tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
!ISSET(tp->t_lflag, ICANON)) || (tp->t_canq.c_cc > 0 &&
tp->t_cc[VSTOP] != _POSIX_VDISABLE)) {
if (putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
SET(tp->t_state, TS_TBLOCK);
ttstart(tp);
@ -1237,7 +1242,8 @@ loop: lflag = tp->t_lflag;
p->p_flag & P_PPWAIT || p->p_pgrp->pg_jobc == 0)
return (EIO);
pgsignal(p->p_pgrp, SIGTTIN, 1);
if (error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0))
error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0);
if (error)
return (error);
goto loop;
}
@ -1289,8 +1295,9 @@ loop: lflag = tp->t_lflag;
if (CCEQ(cc[VDSUSP], c) && ISSET(lflag, ISIG)) {
pgsignal(tp->t_pgrp, SIGTSTP, 1);
if (first) {
if (error = ttysleep(tp,
&lbolt, TTIPRI | PCATCH, ttybg, 0))
error = ttysleep(tp,
&lbolt, TTIPRI | PCATCH, ttybg, 0);
if (error)
break;
goto loop;
}
@ -1417,7 +1424,8 @@ ttwrite(tp, uio, flag)
(p->p_sigmask & sigmask(SIGTTOU)) == 0 &&
p->p_pgrp->pg_jobc) {
pgsignal(p->p_pgrp, SIGTTOU, 1);
if (error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0))
error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0);
if (error)
goto out;
goto loop;
}
@ -1470,8 +1478,9 @@ ttwrite(tp, uio, flag)
if (ttyoutput(*cp, tp) >= 0) {
/* No Clists, wait a bit. */
ttstart(tp);
if (error = ttysleep(tp, &lbolt,
TTOPRI | PCATCH, ttybuf, 0))
error = ttysleep(tp, &lbolt,
TTOPRI | PCATCH, ttybuf, 0);
if (error)
break;
goto loop;
}
@ -1500,8 +1509,9 @@ ttwrite(tp, uio, flag)
if (i > 0) {
/* No Clists, wait a bit. */
ttstart(tp);
if (error = ttysleep(tp,
&lbolt, TTOPRI | PCATCH, ttybuf, 0))
error = ttysleep(tp,
&lbolt, TTOPRI | PCATCH, ttybuf, 0);
if (error)
break;
goto loop;
}
@ -1701,7 +1711,7 @@ ttyecho(c, tp)
ISSET(tp->t_lflag, EXTPROC))
return;
if (ISSET(tp->t_lflag, ECHOCTL) &&
(ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n' ||
((ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n') ||
ISSET(c, TTY_CHARMASK) == 0177)) {
(void)ttyoutput('^', tp);
CLR(c, ~TTY_CHARMASK);
@ -1812,7 +1822,7 @@ ttyinfo(tp)
#define pgtok(a) (((a) * NBPG) / 1024)
/* Print percentage cpu, resident set size. */
tmp = pick->p_pctcpu * 10000 + FSCALE / 2 >> FSHIFT;
tmp = (pick->p_pctcpu * 10000 + FSCALE / 2) >> FSHIFT;
ttyprintf(tp, "%d%% %dk\n",
tmp / 100,
pick->p_stat == SIDL || pick->p_stat == SZOMB ? 0 :
@ -1939,7 +1949,8 @@ ttysleep(tp, chan, pri, wmesg, timo)
short gen;
gen = tp->t_gen;
if (error = tsleep(chan, pri, wmesg, timo))
error = tsleep(chan, pri, wmesg, timo);
if (error)
return (error);
return (tp->t_gen == gen ? 0 : ERESTART);
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.2 (Berkeley) 9/23/93
* $Id: tty_pty.c,v 1.3 1994/08/02 07:42:51 davidg Exp $
* $Id: tty_pty.c,v 1.4 1994/09/15 19:47:16 bde Exp $
*/
/*
@ -50,6 +50,7 @@
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/signalvar.h>
#if NPTY == 1
#undef NPTY
@ -137,8 +138,9 @@ ptsopen(dev, flag, devtype, p)
tp->t_state |= TS_WOPEN;
if (flag&FNONBLOCK)
break;
if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
ttopen, 0))
error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
ttopen, 0);
if (error)
return (error);
}
error = (*linesw[tp->t_line].l_open)(dev, tp);
@ -182,15 +184,17 @@ ptsread(dev, uio, flag)
p->p_flag & P_PPWAIT)
return (EIO);
pgsignal(p->p_pgrp, SIGTTIN, 1);
if (error = ttysleep(tp, (caddr_t)&lbolt,
TTIPRI | PCATCH, ttybg, 0))
error = ttysleep(tp, (caddr_t)&lbolt,
TTIPRI | PCATCH, ttybg, 0);
if (error)
return (error);
}
if (tp->t_canq.c_cc == 0) {
if (flag & IO_NDELAY)
return (EWOULDBLOCK);
if (error = ttysleep(tp, (caddr_t)&tp->t_canq,
TTIPRI | PCATCH, ttyin, 0))
error = ttysleep(tp, (caddr_t)&tp->t_canq,
TTIPRI | PCATCH, ttyin, 0);
if (error)
return (error);
goto again;
}
@ -358,8 +362,9 @@ ptcread(dev, uio, flag)
return (0); /* EOF */
if (flag & IO_NDELAY)
return (EWOULDBLOCK);
if (error = tsleep((caddr_t)&tp->t_outq.c_cf, TTIPRI | PCATCH,
ttyin, 0))
error = tsleep((caddr_t)&tp->t_outq.c_cf, TTIPRI | PCATCH,
ttyin, 0);
if (error)
return (error);
}
if (pti->pt_flags & (PF_PKT|PF_UCNTL))
@ -433,8 +438,8 @@ ptcselect(dev, rw, p)
case 0: /* exceptional */
if ((tp->t_state&TS_ISOPEN) &&
(pti->pt_flags&PF_PKT && pti->pt_send ||
pti->pt_flags&PF_UCNTL && pti->pt_ucntl))
((pti->pt_flags&PF_PKT && pti->pt_send) ||
(pti->pt_flags&PF_UCNTL && pti->pt_ucntl)))
return (1);
selrecord(p, &pti->pt_selr);
break;
@ -538,8 +543,8 @@ ptcwrite(dev, uio, flag)
return (EWOULDBLOCK);
return (0);
}
if (error = tsleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI | PCATCH,
ttyout, 0)) {
error = tsleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI | PCATCH, ttyout, 0);
if (error) {
/* adjust for data copied in but not written */
uio->uio_resid += cc;
return (error);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
* $Id$
* $Id: uipc_mbuf.c,v 1.3 1994/08/02 07:43:02 davidg Exp $
*/
#include <sys/param.h>
@ -48,8 +48,6 @@
#include <vm/vm.h>
void m_reclaim __P(());
extern vm_map_t mb_map;
struct mbuf *mbutl;
char *mclrefcnt;
@ -215,7 +213,8 @@ m_freem(m)
return;
do {
MFREE(m, n);
} while (m = n);
m = n;
} while (m);
}
/*
@ -455,8 +454,8 @@ m_adj(mp, req_len)
}
count -= m->m_len;
}
while (m = m->m_next)
m->m_len = 0;
while (m->m_next)
(m = m->m_next) ->m_len = 0;
}
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
* $Id$
* $Id: uipc_socket2.c,v 1.3 1994/08/02 07:43:08 davidg Exp $
*/
#include <sys/param.h>
@ -42,16 +42,10 @@
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
void soqinsque __P((struct socket *, struct socket *, int));
void sowakeup __P((struct socket *, struct sockbuf *));
void sbrelease __P((struct sockbuf *));
void sbappendrecord __P((struct sockbuf *, struct mbuf *));
void sbcompress __P((struct sockbuf *, struct mbuf *, struct mbuf *));
void sbflush __P((struct sockbuf *));
void sbdrop __P((struct sockbuf *, int));
#include <sys/signalvar.h>
/*
* Primitive routines for operating on sockets and socket buffers
@ -299,9 +293,10 @@ sb_lock(sb)
while (sb->sb_flags & SB_LOCK) {
sb->sb_flags |= SB_WANT;
if (error = tsleep((caddr_t)&sb->sb_flags,
error = tsleep((caddr_t)&sb->sb_flags,
(sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK|PCATCH,
netio, 0))
netio, 0);
if (error)
return (error);
}
sb->sb_flags |= SB_LOCK;
@ -461,7 +456,8 @@ sbappend(sb, m)
if (m == 0)
return;
if (n = sb->sb_mb) {
n = sb->sb_mb;
if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
do {
@ -511,7 +507,8 @@ sbappendrecord(sb, m0)
if (m0 == 0)
return;
if (m = sb->sb_mb)
m = sb->sb_mb;
if (m)
while (m->m_nextpkt)
m = m->m_nextpkt;
/*
@ -547,7 +544,8 @@ sbinsertoob(sb, m0)
if (m0 == 0)
return;
for (mp = &sb->sb_mb; m = *mp; mp = &((*mp)->m_nextpkt)) {
for (mp = &sb->sb_mb; *mp ; mp = &((*mp)->m_nextpkt)) {
m = *mp;
again:
switch (m->m_type) {
@ -555,7 +553,8 @@ sbinsertoob(sb, m0)
continue; /* WANT next train */
case MT_CONTROL:
if (m = m->m_next)
m = m->m_next;
if (m)
goto again; /* inspect THIS train further */
}
break;
@ -616,7 +615,8 @@ panic("sbappendaddr");
m->m_next = control;
for (n = m; n; n = n->m_next)
sballoc(sb, n);
if (n = sb->sb_mb) {
n = sb->sb_mb;
if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = m;
@ -648,7 +648,8 @@ sbappendcontrol(sb, m0, control)
n->m_next = m0; /* concatenate data to control */
for (m = control; m; m = m->m_next)
sballoc(sb, m);
if (n = sb->sb_mb) {
n = sb->sb_mb;
if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = control;
@ -783,6 +784,7 @@ sbdroprecord(sb)
do {
sbfree(sb, m);
MFREE(m, mn);
} while (m = mn);
m = mn;
} while (m);
}
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94
* $Id$
* $Id: uipc_socket.c,v 1.4 1994/08/02 07:43:06 davidg Exp $
*/
#include <sys/param.h>
@ -46,9 +46,7 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/resourcevar.h>
void sofree __P((struct socket *));
void sorflush __P((struct socket *));
#include <sys/signalvar.h>
/*
* Socket operation routines.
@ -181,10 +179,12 @@ soclose(so)
if ((so->so_state & SS_ISDISCONNECTING) &&
(so->so_state & SS_NBIO))
goto drop;
while (so->so_state & SS_ISCONNECTED)
if (error = tsleep((caddr_t)&so->so_timeo,
PSOCK | PCATCH, netcls, so->so_linger))
while (so->so_state & SS_ISCONNECTED) {
error = tsleep((caddr_t)&so->so_timeo,
PSOCK | PCATCH, netcls, so->so_linger);
if (error)
break;
}
}
}
drop:
@ -354,7 +354,8 @@ sosend(so, addr, uio, top, control, flags)
#define snderr(errno) { error = errno; splx(s); goto release; }
restart:
if (error = sblock(&so->so_snd, SBLOCKWAIT(flags)))
error = sblock(&so->so_snd, SBLOCKWAIT(flags));
if (error)
goto out;
do {
s = splnet();
@ -373,7 +374,7 @@ sosend(so, addr, uio, top, control, flags)
space = sbspace(&so->so_snd);
if (flags & MSG_OOB)
space += 1024;
if (atomic && resid > so->so_snd.sb_hiwat ||
if ((atomic && resid > so->so_snd.sb_hiwat) ||
clen > so->so_snd.sb_hiwat)
snderr(EMSGSIZE);
if (space < resid + clen && uio &&
@ -531,7 +532,8 @@ soreceive(so, paddr, uio, mp0, controlp, flagsp)
(struct mbuf *)0, (struct mbuf *)0);
restart:
if (error = sblock(&so->so_rcv, SBLOCKWAIT(flags)))
error = sblock(&so->so_rcv, SBLOCKWAIT(flags));
if (error)
return (error);
s = splnet();
@ -547,11 +549,11 @@ soreceive(so, paddr, uio, mp0, controlp, flagsp)
* we have to do the receive in sections, and thus risk returning
* a short count if a timeout or signal occurs after we start.
*/
if (m == 0 || ((flags & MSG_DONTWAIT) == 0 &&
if (m == 0 || (((flags & MSG_DONTWAIT) == 0 &&
so->so_rcv.sb_cc < uio->uio_resid) &&
(so->so_rcv.sb_cc < so->so_rcv.sb_lowat ||
((flags & MSG_WAITALL) && uio->uio_resid <= so->so_rcv.sb_hiwat)) &&
m->m_nextpkt == 0 && (pr->pr_flags & PR_ATOMIC) == 0) {
m->m_nextpkt == 0 && (pr->pr_flags & PR_ATOMIC) == 0)) {
#ifdef DIAGNOSTIC
if (m == 0 && so->so_rcv.sb_cc)
panic("receive 1");
@ -749,7 +751,8 @@ soreceive(so, paddr, uio, mp0, controlp, flagsp)
splx(s);
return (0);
}
if (m = so->so_rcv.sb_mb)
m = so->so_rcv.sb_mb;
if (m)
nextrecord = m->m_nextpkt;
}
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
* $Id$
* $Id: uipc_socket2.c,v 1.3 1994/08/02 07:43:08 davidg Exp $
*/
#include <sys/param.h>
@ -42,16 +42,10 @@
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
void soqinsque __P((struct socket *, struct socket *, int));
void sowakeup __P((struct socket *, struct sockbuf *));
void sbrelease __P((struct sockbuf *));
void sbappendrecord __P((struct sockbuf *, struct mbuf *));
void sbcompress __P((struct sockbuf *, struct mbuf *, struct mbuf *));
void sbflush __P((struct sockbuf *));
void sbdrop __P((struct sockbuf *, int));
#include <sys/signalvar.h>
/*
* Primitive routines for operating on sockets and socket buffers
@ -299,9 +293,10 @@ sb_lock(sb)
while (sb->sb_flags & SB_LOCK) {
sb->sb_flags |= SB_WANT;
if (error = tsleep((caddr_t)&sb->sb_flags,
error = tsleep((caddr_t)&sb->sb_flags,
(sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK|PCATCH,
netio, 0))
netio, 0);
if (error)
return (error);
}
sb->sb_flags |= SB_LOCK;
@ -461,7 +456,8 @@ sbappend(sb, m)
if (m == 0)
return;
if (n = sb->sb_mb) {
n = sb->sb_mb;
if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
do {
@ -511,7 +507,8 @@ sbappendrecord(sb, m0)
if (m0 == 0)
return;
if (m = sb->sb_mb)
m = sb->sb_mb;
if (m)
while (m->m_nextpkt)
m = m->m_nextpkt;
/*
@ -547,7 +544,8 @@ sbinsertoob(sb, m0)
if (m0 == 0)
return;
for (mp = &sb->sb_mb; m = *mp; mp = &((*mp)->m_nextpkt)) {
for (mp = &sb->sb_mb; *mp ; mp = &((*mp)->m_nextpkt)) {
m = *mp;
again:
switch (m->m_type) {
@ -555,7 +553,8 @@ sbinsertoob(sb, m0)
continue; /* WANT next train */
case MT_CONTROL:
if (m = m->m_next)
m = m->m_next;
if (m)
goto again; /* inspect THIS train further */
}
break;
@ -616,7 +615,8 @@ panic("sbappendaddr");
m->m_next = control;
for (n = m; n; n = n->m_next)
sballoc(sb, n);
if (n = sb->sb_mb) {
n = sb->sb_mb;
if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = m;
@ -648,7 +648,8 @@ sbappendcontrol(sb, m0, control)
n->m_next = m0; /* concatenate data to control */
for (m = control; m; m = m->m_next)
sballoc(sb, m);
if (n = sb->sb_mb) {
n = sb->sb_mb;
if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = control;
@ -783,6 +784,7 @@ sbdroprecord(sb)
do {
sbfree(sb, m);
MFREE(m, mn);
} while (m = mn);
m = mn;
} while (m);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94
* $Id: uipc_usrreq.c,v 1.3 1994/08/02 07:43:12 davidg Exp $
* $Id: uipc_usrreq.c,v 1.4 1994/09/28 19:55:10 phk Exp $
*/
#include <sys/param.h>
@ -40,6 +40,7 @@
#include <sys/filedesc.h>
#include <sys/domain.h>
#include <sys/protosw.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/unpcb.h>
@ -50,15 +51,6 @@
#include <sys/stat.h>
#include <sys/mbuf.h>
void unp_detach __P((struct unpcb *));
void unp_disconnect __P((struct unpcb *));
void unp_shutdown __P((struct unpcb *));
void unp_drop __P((struct unpcb *, int));
void unp_gc __P((void));
void unp_scan __P((struct mbuf *, void (*)(struct file *)));
void unp_mark __P((struct file *));
void unp_discard __P((struct file *));
/*
* Unix communications domain.
*
@ -411,7 +403,8 @@ unp_bind(unp, nam, p)
} else
*(mtod(nam, caddr_t) + nam->m_len) = 0;
/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL) {
@ -427,7 +420,8 @@ unp_bind(unp, nam, p)
vattr.va_type = VSOCK;
vattr.va_mode = ACCESSPERMS;
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr))
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
if (error)
return (error);
vp = nd.ni_vp;
vp->v_socket = unp->unp_socket;
@ -456,14 +450,16 @@ unp_connect(so, nam, p)
return (EMSGSIZE);
} else
*(mtod(nam, caddr_t) + nam->m_len) = 0;
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VSOCK) {
error = ENOTSOCK;
goto bad;
}
if (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p))
error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p);
if (error)
goto bad;
so2 = vp->v_socket;
if (so2 == 0) {

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_cache.c 8.1 (Berkeley) 6/10/93
* $Id$
* $Id: vfs_cache.c,v 1.3 1994/08/02 07:43:15 davidg Exp $
*/
#include <sys/param.h>
@ -161,20 +161,23 @@ cache_lookup(dvp, vpp, cnp)
* want cache entry to exist.
*/
/* remove from LRU chain */
if (ncq = ncp->nc_nxt)
ncq = ncp->nc_nxt;
if (ncq)
ncq->nc_prev = ncp->nc_prev;
else
nchtail = ncp->nc_prev;
*ncp->nc_prev = ncq;
/* remove from hash chain */
if (ncq = ncp->nc_forw)
ncq = ncp->nc_forw;
if (ncq)
ncq->nc_back = ncp->nc_back;
*ncp->nc_back = ncq;
/* and make a dummy hash chain */
ncp->nc_forw = NULL;
ncp->nc_back = NULL;
/* insert at head of LRU list (first to grab) */
if (ncq = nchhead)
ncq = nchhead;
if (ncq)
ncq->nc_prev = &ncp->nc_nxt;
else
nchtail = &ncp->nc_nxt;
@ -209,23 +212,27 @@ cache_enter(dvp, vp, cnp)
malloc((u_long)sizeof *ncp, M_CACHE, M_WAITOK);
bzero((char *)ncp, sizeof *ncp);
numcache++;
} else if (ncp = nchhead) {
} else if (!nchhead) {
return;
} else {
ncp = nchhead;
/* remove from lru chain */
if (ncq = ncp->nc_nxt)
ncq = ncp->nc_nxt;
if (ncq)
ncq->nc_prev = ncp->nc_prev;
else
nchtail = ncp->nc_prev;
*ncp->nc_prev = ncq;
/* remove from old hash chain, if on one */
if (ncp->nc_back) {
if (ncq = ncp->nc_forw)
ncq = ncp->nc_forw;
if (ncq)
ncq->nc_back = ncp->nc_back;
*ncp->nc_back = ncq;
ncp->nc_forw = NULL;
ncp->nc_back = NULL;
}
} else
return;
}
/* grab the vnode we just found */
ncp->nc_vp = vp;
if (vp)
@ -244,7 +251,8 @@ cache_enter(dvp, vp, cnp)
nchtail = &ncp->nc_nxt;
/* and insert on hash chain */
ncpp = &nchashtbl[cnp->cn_hash & nchash];
if (ncq = *ncpp)
ncq = *ncpp;
if (ncq)
ncq->nc_back = &ncp->nc_forw;
ncp->nc_forw = ncq;
ncp->nc_back = ncpp;
@ -308,21 +316,24 @@ cache_purgevfs(mp)
ncp->nc_dvp = NULL;
/* remove from old hash chain, if on one */
if (ncp->nc_back) {
if (nxtcp = ncp->nc_forw)
nxtcp = ncp->nc_forw;
if (nxtcp)
nxtcp->nc_back = ncp->nc_back;
*ncp->nc_back = nxtcp;
ncp->nc_forw = NULL;
ncp->nc_back = NULL;
}
/* delete this entry from LRU chain */
if (nxtcp = ncp->nc_nxt)
nxtcp = ncp->nc_nxt;
if (nxtcp)
nxtcp->nc_prev = ncp->nc_prev;
else
nchtail = ncp->nc_prev;
*ncp->nc_prev = nxtcp;
/* cause rescan of list, it may have altered */
/* also put the now-free entry at head of LRU */
if (nxtcp = nchhead)
nxtcp = nchhead;
if (nxtcp)
nxtcp->nc_prev = &ncp->nc_nxt;
else
nchtail = &ncp->nc_nxt;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94
* $Id: vfs_subr.c,v 1.8 1994/08/29 06:08:51 davidg Exp $
* $Id: vfs_subr.c,v 1.9 1994/09/25 19:33:52 phk Exp $
*/
/*
@ -347,12 +347,15 @@ getnewvnode(tag, mp, vops, vpp)
if (vp->v_type != VBAD)
vgone(vp);
#ifdef DIAGNOSTIC
{
int s;
if (vp->v_data)
panic("cleaned vnode isn't");
s = splbio();
if (vp->v_numoutput)
panic("Clean vnode has pending I/O's");
splx(s);
}
#endif
vp->v_flag = 0;
vp->v_lastr = 0;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
* $Id: vfs_syscalls.c,v 1.8 1994/09/22 19:37:56 wollman Exp $
* $Id: vfs_syscalls.c,v 1.9 1994/09/28 16:45:11 dfr Exp $
*/
#include <sys/param.h>
@ -56,7 +56,6 @@
#include <vm/vm.h>
#include <sys/sysctl.h>
void cvtstat __P((struct stat *, struct ostat *));
static int change_dir __P((struct nameidata *ndp, struct proc *p));
/*
@ -87,13 +86,15 @@ mount(p, uap, retval)
/*
* Must be super user
*/
if (error = suser(p->p_ucred, &p->p_acflag))
error = suser(p->p_ucred, &p->p_acflag);
if (error)
return (error);
/*
* Get vnode to be covered
*/
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (uap->flags & MNT_UPDATE) {
@ -117,7 +118,8 @@ mount(p, uap, retval)
VOP_UNLOCK(vp);
goto update;
}
if (error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0))
error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0);
if (error)
return (error);
if (vp->v_type != VDIR) {
vput(vp);
@ -136,7 +138,8 @@ mount(p, uap, retval)
bzero((char *)mp, (u_long)sizeof(struct mount));
mp->mnt_op = vfssw[uap->type];
mp->mnt_vfc = vfsconf[uap->type];
if (error = vfs_lock(mp)) {
error = vfs_lock(mp);
if (error) {
free((caddr_t)mp, M_MOUNT);
vput(vp);
return (error);
@ -219,7 +222,8 @@ unmount(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
@ -268,7 +272,8 @@ dounmount(mp, flags, p)
if (vfs_busy(mp))
return (EBUSY);
mp->mnt_flag |= MNT_UNMOUNT;
if (error = vfs_lock(mp))
error = vfs_lock(mp);
if (error)
return (error);
mp->mnt_flag &=~ MNT_ASYNC;
@ -359,7 +364,8 @@ quotactl(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
mp = nd.ni_vp->v_mount;
vrele(nd.ni_vp);
@ -386,12 +392,14 @@ statfs(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
mp = nd.ni_vp->v_mount;
sp = &mp->mnt_stat;
vrele(nd.ni_vp);
if (error = VFS_STATFS(mp, sp, p))
error = VFS_STATFS(mp, sp, p);
if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
@ -416,11 +424,13 @@ fstatfs(p, uap, retval)
register struct statfs *sp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
if (error = VFS_STATFS(mp, sp, p))
error = VFS_STATFS(mp, sp, p);
if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
@ -492,7 +502,8 @@ fchdir(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(fdp, uap->fd, &fp))
error = getvnode(fdp, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
@ -527,7 +538,8 @@ chdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = change_dir(&nd, p))
error = change_dir(&nd, p);
if (error)
return (error);
vrele(fdp->fd_cdir);
fdp->fd_cdir = nd.ni_vp;
@ -551,10 +563,12 @@ chroot(p, uap, retval)
int error;
struct nameidata nd;
if (error = suser(p->p_ucred, &p->p_acflag))
error = suser(p->p_ucred, &p->p_acflag);
if (error)
return (error);
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = change_dir(&nd, p))
error = change_dir(&nd, p);
if (error)
return (error);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
@ -573,7 +587,8 @@ change_dir(ndp, p)
struct vnode *vp;
int error;
if (error = namei(ndp))
error = namei(ndp);
if (error)
return (error);
vp = ndp->ni_vp;
if (vp->v_type != VDIR)
@ -611,14 +626,16 @@ open(p, uap, retval)
struct nameidata nd;
extern struct fileops vnops;
if (error = falloc(p, &nfp, &indx))
error = falloc(p, &nfp, &indx);
if (error)
return (error);
fp = nfp;
flags = FFLAGS(uap->flags);
cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
if (error = vn_open(&nd, flags, cmode)) {
error = vn_open(&nd, flags, cmode);
if (error) {
ffree(fp);
if ((error == ENODEV || error == ENXIO) &&
p->p_dupfd >= 0 && /* XXX from fdopen */
@ -650,7 +667,8 @@ open(p, uap, retval)
if ((flags & FNONBLOCK) == 0)
type |= F_WAIT;
VOP_UNLOCK(vp);
if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type);
if (error) {
(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
ffree(fp);
fdp->fd_ofiles[indx] = NULL;
@ -707,10 +725,12 @@ mknod(p, uap, retval)
int error;
struct nameidata nd;
if (error = suser(p->p_ucred, &p->p_acflag))
error = suser(p->p_ucred, &p->p_acflag);
if (error)
return (error);
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL)
@ -769,7 +789,8 @@ mkfifo(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
if (nd.ni_vp != NULL) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@ -806,7 +827,8 @@ link(p, uap, retval)
int error;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VDIR ||
@ -814,7 +836,8 @@ link(p, uap, retval)
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT;
nd.ni_dirp = uap->link;
if ((error = namei(&nd)) == 0) {
error = namei(&nd);
if (!error) {
if (nd.ni_vp != NULL)
error = EEXIST;
if (!error) {
@ -858,10 +881,12 @@ symlink(p, uap, retval)
struct nameidata nd;
MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
if (error = copyinstr(uap->path, path, MAXPATHLEN, NULL))
error = copyinstr(uap->path, path, MAXPATHLEN, NULL);
if (error)
goto out;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
goto out;
if (nd.ni_vp) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@ -900,7 +925,8 @@ unlink(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -962,8 +988,8 @@ lseek(p, uap, retval)
fp->f_offset += uap->offset;
break;
case L_XTND:
if (error =
VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p))
error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
if (error)
return (error);
fp->f_offset = uap->offset + vattr.va_size;
break;
@ -1028,7 +1054,8 @@ access(p, uap, retval)
cred->cr_uid = p->p_cred->p_ruid;
cred->cr_groups[0] = p->p_cred->p_rgid;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
goto out1;
vp = nd.ni_vp;
@ -1072,7 +1099,8 @@ ostat(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
@ -1105,7 +1133,8 @@ olstat(p, uap, retval)
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
/*
* For symbolic links, always return the attributes of its
@ -1193,7 +1222,8 @@ stat(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
@ -1224,7 +1254,8 @@ lstat(p, uap, retval)
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
/*
* For symbolic links, always return the attributes of its
@ -1280,7 +1311,8 @@ pathconf(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
vput(nd.ni_vp);
@ -1309,7 +1341,8 @@ readlink(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VLNK)
@ -1351,7 +1384,8 @@ chflags(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1386,7 +1420,8 @@ fchflags(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1422,7 +1457,8 @@ chmod(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1457,7 +1493,8 @@ fchmod(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1494,7 +1531,8 @@ chown(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1531,7 +1569,8 @@ fchown(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1573,10 +1612,14 @@ utimes(p, uap, retval)
microtime(&tv[0]);
tv[1] = tv[0];
vattr.va_vaflags |= VA_UTIMES_NULL;
} else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
return (error);
} else {
error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
if (error)
return (error);
}
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1617,7 +1660,8 @@ truncate(p, uap, retval)
if (uap->length < 0)
return(EINVAL);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1656,7 +1700,8 @@ ftruncate(p, uap, retval)
if (uap->length < 0)
return(EINVAL);
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
if ((fp->f_flag & FWRITE) == 0)
return (EINVAL);
@ -1735,7 +1780,8 @@ fsync(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
@ -1765,12 +1811,14 @@ rename(p, uap, retval)
NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
uap->from, p);
if (error = namei(&fromnd))
error = namei(&fromnd);
if (error)
return (error);
fvp = fromnd.ni_vp;
NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
UIO_USERSPACE, uap->to, p);
if (error = namei(&tond)) {
error = namei(&tond);
if (error) {
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
vrele(fromnd.ni_dvp);
vrele(fvp);
@ -1851,7 +1899,8 @@ mkdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL) {
@ -1891,7 +1940,8 @@ rmdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VDIR) {
@ -1951,7 +2001,8 @@ ogetdirentries(p, uap, retval)
int error, readcnt;
long loff;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
@ -2048,7 +2099,8 @@ getdirentries(p, uap, retval)
long loff;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
@ -2158,14 +2210,16 @@ revoke(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VCHR && vp->v_type != VBLK) {
error = EINVAL;
goto out;
}
if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p))
error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
if (error)
goto out;
if (p->p_ucred->cr_uid != vattr.va_uid &&
(error = suser(p->p_ucred, &p->p_acflag)))

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94
* $Id: vfs_subr.c,v 1.8 1994/08/29 06:08:51 davidg Exp $
* $Id: vfs_subr.c,v 1.9 1994/09/25 19:33:52 phk Exp $
*/
/*
@ -347,12 +347,15 @@ getnewvnode(tag, mp, vops, vpp)
if (vp->v_type != VBAD)
vgone(vp);
#ifdef DIAGNOSTIC
{
int s;
if (vp->v_data)
panic("cleaned vnode isn't");
s = splbio();
if (vp->v_numoutput)
panic("Clean vnode has pending I/O's");
splx(s);
}
#endif
vp->v_flag = 0;
vp->v_lastr = 0;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
* $Id: vfs_syscalls.c,v 1.8 1994/09/22 19:37:56 wollman Exp $
* $Id: vfs_syscalls.c,v 1.9 1994/09/28 16:45:11 dfr Exp $
*/
#include <sys/param.h>
@ -56,7 +56,6 @@
#include <vm/vm.h>
#include <sys/sysctl.h>
void cvtstat __P((struct stat *, struct ostat *));
static int change_dir __P((struct nameidata *ndp, struct proc *p));
/*
@ -87,13 +86,15 @@ mount(p, uap, retval)
/*
* Must be super user
*/
if (error = suser(p->p_ucred, &p->p_acflag))
error = suser(p->p_ucred, &p->p_acflag);
if (error)
return (error);
/*
* Get vnode to be covered
*/
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (uap->flags & MNT_UPDATE) {
@ -117,7 +118,8 @@ mount(p, uap, retval)
VOP_UNLOCK(vp);
goto update;
}
if (error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0))
error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0);
if (error)
return (error);
if (vp->v_type != VDIR) {
vput(vp);
@ -136,7 +138,8 @@ mount(p, uap, retval)
bzero((char *)mp, (u_long)sizeof(struct mount));
mp->mnt_op = vfssw[uap->type];
mp->mnt_vfc = vfsconf[uap->type];
if (error = vfs_lock(mp)) {
error = vfs_lock(mp);
if (error) {
free((caddr_t)mp, M_MOUNT);
vput(vp);
return (error);
@ -219,7 +222,8 @@ unmount(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
@ -268,7 +272,8 @@ dounmount(mp, flags, p)
if (vfs_busy(mp))
return (EBUSY);
mp->mnt_flag |= MNT_UNMOUNT;
if (error = vfs_lock(mp))
error = vfs_lock(mp);
if (error)
return (error);
mp->mnt_flag &=~ MNT_ASYNC;
@ -359,7 +364,8 @@ quotactl(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
mp = nd.ni_vp->v_mount;
vrele(nd.ni_vp);
@ -386,12 +392,14 @@ statfs(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
mp = nd.ni_vp->v_mount;
sp = &mp->mnt_stat;
vrele(nd.ni_vp);
if (error = VFS_STATFS(mp, sp, p))
error = VFS_STATFS(mp, sp, p);
if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
@ -416,11 +424,13 @@ fstatfs(p, uap, retval)
register struct statfs *sp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
if (error = VFS_STATFS(mp, sp, p))
error = VFS_STATFS(mp, sp, p);
if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
@ -492,7 +502,8 @@ fchdir(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(fdp, uap->fd, &fp))
error = getvnode(fdp, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
@ -527,7 +538,8 @@ chdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = change_dir(&nd, p))
error = change_dir(&nd, p);
if (error)
return (error);
vrele(fdp->fd_cdir);
fdp->fd_cdir = nd.ni_vp;
@ -551,10 +563,12 @@ chroot(p, uap, retval)
int error;
struct nameidata nd;
if (error = suser(p->p_ucred, &p->p_acflag))
error = suser(p->p_ucred, &p->p_acflag);
if (error)
return (error);
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = change_dir(&nd, p))
error = change_dir(&nd, p);
if (error)
return (error);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
@ -573,7 +587,8 @@ change_dir(ndp, p)
struct vnode *vp;
int error;
if (error = namei(ndp))
error = namei(ndp);
if (error)
return (error);
vp = ndp->ni_vp;
if (vp->v_type != VDIR)
@ -611,14 +626,16 @@ open(p, uap, retval)
struct nameidata nd;
extern struct fileops vnops;
if (error = falloc(p, &nfp, &indx))
error = falloc(p, &nfp, &indx);
if (error)
return (error);
fp = nfp;
flags = FFLAGS(uap->flags);
cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
if (error = vn_open(&nd, flags, cmode)) {
error = vn_open(&nd, flags, cmode);
if (error) {
ffree(fp);
if ((error == ENODEV || error == ENXIO) &&
p->p_dupfd >= 0 && /* XXX from fdopen */
@ -650,7 +667,8 @@ open(p, uap, retval)
if ((flags & FNONBLOCK) == 0)
type |= F_WAIT;
VOP_UNLOCK(vp);
if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type);
if (error) {
(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
ffree(fp);
fdp->fd_ofiles[indx] = NULL;
@ -707,10 +725,12 @@ mknod(p, uap, retval)
int error;
struct nameidata nd;
if (error = suser(p->p_ucred, &p->p_acflag))
error = suser(p->p_ucred, &p->p_acflag);
if (error)
return (error);
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL)
@ -769,7 +789,8 @@ mkfifo(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
if (nd.ni_vp != NULL) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@ -806,7 +827,8 @@ link(p, uap, retval)
int error;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VDIR ||
@ -814,7 +836,8 @@ link(p, uap, retval)
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT;
nd.ni_dirp = uap->link;
if ((error = namei(&nd)) == 0) {
error = namei(&nd);
if (!error) {
if (nd.ni_vp != NULL)
error = EEXIST;
if (!error) {
@ -858,10 +881,12 @@ symlink(p, uap, retval)
struct nameidata nd;
MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
if (error = copyinstr(uap->path, path, MAXPATHLEN, NULL))
error = copyinstr(uap->path, path, MAXPATHLEN, NULL);
if (error)
goto out;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
goto out;
if (nd.ni_vp) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@ -900,7 +925,8 @@ unlink(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -962,8 +988,8 @@ lseek(p, uap, retval)
fp->f_offset += uap->offset;
break;
case L_XTND:
if (error =
VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p))
error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
if (error)
return (error);
fp->f_offset = uap->offset + vattr.va_size;
break;
@ -1028,7 +1054,8 @@ access(p, uap, retval)
cred->cr_uid = p->p_cred->p_ruid;
cred->cr_groups[0] = p->p_cred->p_rgid;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
goto out1;
vp = nd.ni_vp;
@ -1072,7 +1099,8 @@ ostat(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
@ -1105,7 +1133,8 @@ olstat(p, uap, retval)
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
/*
* For symbolic links, always return the attributes of its
@ -1193,7 +1222,8 @@ stat(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
@ -1224,7 +1254,8 @@ lstat(p, uap, retval)
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
/*
* For symbolic links, always return the attributes of its
@ -1280,7 +1311,8 @@ pathconf(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
vput(nd.ni_vp);
@ -1309,7 +1341,8 @@ readlink(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VLNK)
@ -1351,7 +1384,8 @@ chflags(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1386,7 +1420,8 @@ fchflags(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1422,7 +1457,8 @@ chmod(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1457,7 +1493,8 @@ fchmod(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1494,7 +1531,8 @@ chown(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1531,7 +1569,8 @@ fchown(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1573,10 +1612,14 @@ utimes(p, uap, retval)
microtime(&tv[0]);
tv[1] = tv[0];
vattr.va_vaflags |= VA_UTIMES_NULL;
} else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
return (error);
} else {
error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
if (error)
return (error);
}
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1617,7 +1660,8 @@ truncate(p, uap, retval)
if (uap->length < 0)
return(EINVAL);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@ -1656,7 +1700,8 @@ ftruncate(p, uap, retval)
if (uap->length < 0)
return(EINVAL);
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
if ((fp->f_flag & FWRITE) == 0)
return (EINVAL);
@ -1735,7 +1780,8 @@ fsync(p, uap, retval)
struct file *fp;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
@ -1765,12 +1811,14 @@ rename(p, uap, retval)
NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
uap->from, p);
if (error = namei(&fromnd))
error = namei(&fromnd);
if (error)
return (error);
fvp = fromnd.ni_vp;
NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
UIO_USERSPACE, uap->to, p);
if (error = namei(&tond)) {
error = namei(&tond);
if (error) {
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
vrele(fromnd.ni_dvp);
vrele(fvp);
@ -1851,7 +1899,8 @@ mkdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL) {
@ -1891,7 +1940,8 @@ rmdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VDIR) {
@ -1951,7 +2001,8 @@ ogetdirentries(p, uap, retval)
int error, readcnt;
long loff;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
@ -2048,7 +2099,8 @@ getdirentries(p, uap, retval)
long loff;
int error;
if (error = getvnode(p->p_fd, uap->fd, &fp))
error = getvnode(p->p_fd, uap->fd, &fp);
if (error)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
@ -2158,14 +2210,16 @@ revoke(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
error = namei(&nd);
if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VCHR && vp->v_type != VBLK) {
error = EINVAL;
goto out;
}
if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p))
error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
if (error)
goto out;
if (p->p_ucred->cr_uid != vattr.va_uid &&
(error = suser(p->p_ucred, &p->p_acflag)))

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94
* $Id: vfs_vnops.c,v 1.3 1994/08/02 07:43:33 davidg Exp $
* $Id: vfs_vnops.c,v 1.4 1994/08/18 03:53:38 davidg Exp $
*/
#include <sys/param.h>
@ -78,15 +78,17 @@ vn_open(ndp, fmode, cmode)
ndp->ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
if ((fmode & O_EXCL) == 0)
ndp->ni_cnd.cn_flags |= FOLLOW;
if (error = namei(ndp))
error = namei(ndp);
if (error)
return (error);
if (ndp->ni_vp == NULL) {
VATTR_NULL(vap);
vap->va_type = VREG;
vap->va_mode = cmode;
LEASE_CHECK(ndp->ni_dvp, p, cred, LEASE_WRITE);
if (error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
&ndp->ni_cnd, vap))
error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
&ndp->ni_cnd, vap);
if (error)
return (error);
fmode &= ~O_TRUNC;
vp = ndp->ni_vp;
@ -107,7 +109,8 @@ vn_open(ndp, fmode, cmode)
} else {
ndp->ni_cnd.cn_nameiop = LOOKUP;
ndp->ni_cnd.cn_flags = FOLLOW | LOCKLEAF;
if (error = namei(ndp))
error = namei(ndp);
if (error)
return (error);
vp = ndp->ni_vp;
}
@ -117,7 +120,8 @@ vn_open(ndp, fmode, cmode)
}
if ((fmode & O_CREAT) == 0) {
if (fmode & FREAD) {
if (error = VOP_ACCESS(vp, VREAD, cred, p))
error = VOP_ACCESS(vp, VREAD, cred, p);
if (error)
goto bad;
}
if (fmode & (FWRITE | O_TRUNC)) {
@ -125,8 +129,11 @@ vn_open(ndp, fmode, cmode)
error = EISDIR;
goto bad;
}
if ((error = vn_writechk(vp)) ||
(error = VOP_ACCESS(vp, VWRITE, cred, p)))
error = vn_writechk(vp);
if(error)
goto bad;
error = VOP_ACCESS(vp, VWRITE, cred, p);
if(error)
goto bad;
}
}
@ -136,10 +143,12 @@ vn_open(ndp, fmode, cmode)
VOP_LOCK(vp); /* XXX */
VATTR_NULL(vap);
vap->va_size = 0;
if (error = VOP_SETATTR(vp, vap, cred, p))
error = VOP_SETATTR(vp, vap, cred, p);
if (error)
goto bad;
}
if (error = VOP_OPEN(vp, fmode, cred, p))
error = VOP_OPEN(vp, fmode, cred, p);
if (error)
goto bad;
if (fmode & FWRITE)
vp->v_writecount++;
@ -168,6 +177,8 @@ vn_writechk(vp)
switch (vp->v_type) {
case VREG: case VDIR: case VLNK:
return (EROFS);
default:
break;
}
}
/*
@ -381,7 +392,8 @@ vn_ioctl(fp, com, data, p)
case VREG:
case VDIR:
if (com == FIONREAD) {
if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p))
error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
if (error)
return (error);
*(int *)data = vattr.va_size - fp->f_offset;
return (0);