From: art Date: Fri, 3 Mar 2000 11:31:42 +0000 (+0000) Subject: Use LIST_ macros instead of internal field names to walk the allproc list. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6d09544f8647a6ac0b849a182d239c18be3aa5ce;p=openbsd Use LIST_ macros instead of internal field names to walk the allproc list. --- diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 2ac3e9a75d7..f7ebb0d6fe1 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.28 2000/02/21 20:00:09 art Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.29 2000/03/03 11:31:42 art Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -211,9 +211,9 @@ retry: * is in use. Remember the lowest pid that's greater * than lastpid, so we can avoid checking for a while. */ - p2 = allproc.lh_first; + p2 = LIST_FIRST(&allproc); again: - for (; p2 != 0; p2 = p2->p_list.le_next) { + for (; p2 != 0; p2 = LIST_NEXT(p2, p_list)) { while (p2->p_pid == lastpid || p2->p_pgrp->pg_id == lastpid) { lastpid++; diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index d08e09a840d..6d2524b179a 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.11 1999/02/11 20:34:04 deraadt Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.12 2000/03/03 11:31:42 art Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -306,7 +306,7 @@ sys_ktrace(curp, v, retval) * Clear all uses of the tracefile */ if (ops == KTROP_CLEARFILE) { - for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { + for (p = LIST_FIRST(&allproc); p; p = LIST_NEXT(p, p_list)) { if (p->p_tracep == vp) { if (ktrcanset(curp, p)) { p->p_tracep = NULL; @@ -479,7 +479,7 @@ ktrwrite(vp, kth) */ log(LOG_NOTICE, "ktrace write failed, errno %d, tracing stopped\n", error); - for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { + for (p = LIST_FIRST(&allproc); p != NULL; p = LIST_NEXT(p, p_list)) { if (p->p_tracep == vp) { p->p_tracep = NULL; p->p_traceflag = 0; diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 4db024054c9..dd0cea5da63 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_resource.c,v 1.10 1999/11/05 01:18:01 mickey Exp $ */ +/* $OpenBSD: kern_resource.c,v 1.11 2000/03/03 11:31:43 art Exp $ */ /* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */ /*- @@ -105,7 +105,7 @@ sys_getpriority(curp, v, retval) case PRIO_USER: if (SCARG(uap, who) == 0) SCARG(uap, who) = curp->p_ucred->cr_uid; - for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) + for (p = LIST_FIRST(&allproc); p; p = LIST_NEXT(p, p_list)) if (p->p_ucred->cr_uid == SCARG(uap, who) && p->p_nice < low) low = p->p_nice; @@ -166,7 +166,7 @@ sys_setpriority(curp, v, retval) case PRIO_USER: if (SCARG(uap, who) == 0) SCARG(uap, who) = curp->p_ucred->cr_uid; - for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) + for (p = LIST_FIRST(&allproc); p; p = LIST_NEXT(p, p_list)) if (p->p_ucred->cr_uid == SCARG(uap, who)) { error = donice(curp, p, SCARG(uap, prio)); found++; diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 660b1603e95..41c7badf86f 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.35 1999/11/05 01:18:01 mickey Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.36 2000/03/03 11:31:43 art Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -518,7 +518,7 @@ killpg1(cp, signum, pgid, all) /* * broadcast */ - for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { + for (p = LIST_FIRST(&allproc); p; p = LIST_NEXT(p, p_list)) { if (p->p_pid <= 1 || p->p_flag & P_SYSTEM || p == cp || !cansignal(cp, pc, p, signum)) continue; diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 759a141a6b6..a43a53a51c8 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.17 1999/09/05 22:20:45 tholo Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.18 2000/03/03 11:31:43 art Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -189,7 +189,7 @@ schedcpu(arg) */ phz = stathz ? stathz : profhz; - for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { + for (p = LIST_FIRST(&allproc); p != 0; p = LIST_NEXT(p, p_list)) { /* * Increment time in/out of memory and sleep time * (if sleeping). We ignore overflow; with 16-bit int's @@ -764,7 +764,7 @@ db_show_all_procs(addr, haddr, count, modif) return; } - p = allproc.lh_first; + p = LIST_FIRST(&allproc); switch (*mode) { @@ -813,7 +813,7 @@ db_show_all_procs(addr, haddr, count, modif) } } - p = p->p_list.le_next; + p = LIST_NEXT(p, p_list); if (p == 0 && doingzomb == 0) { doingzomb = 1; p = zombproc.lh_first; diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 6afca527cb8..c3e93058743 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.30 2000/02/22 19:28:03 deraadt Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.31 2000/03/03 11:31:43 art Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -717,10 +717,10 @@ sysctl_doproc(name, namelen, where, sizep) if (namelen != 2 && !(namelen == 1 && name[0] == KERN_PROC_ALL)) return (EINVAL); - p = allproc.lh_first; + p = LIST_FIRST(&allproc); doingzomb = 0; again: - for (; p != 0; p = p->p_list.le_next) { + for (; p != 0; p = LIST_NEXT(p, p_list)) { /* * Skip embryonic processes. */ diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index caec7dbdf3f..0c0fd129028 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.62 2000/02/07 04:55:19 assar Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.63 2000/03/03 11:31:43 art Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -336,7 +336,11 @@ checkdirs(olddp) return; if (VFS_ROOT(olddp->v_mountedhere, &newdp)) panic("mount: lost mount"); - for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { + for (p = LIST_FIRST(&allproc); p != 0; p = LIST_NEXT(p, p_list)) { + /* + * XXX - we have a race with fork here. We should probably + * check if the process is SIDL before we fiddle with it. + */ fdp = p->p_fd; if (fdp->fd_cdir == olddp) { vrele(fdp->fd_cdir);