Merge 1.8.0~pre4 packaging into master
[pkg-k5-afs_openafs.git] / src / afs / HPUX / osi_gcpags.c
blob554a30b6b0b48a32f37257782f9f1f0c0aee597a
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
10 #include <afsconfig.h>
11 #include "afs/param.h"
14 #include "afs/sysincludes.h" /* Standard vendor system headers */
15 #include "afsincludes.h" /* Afs-based standard headers */
16 #include "afs/afs_stats.h" /* afs statistics */
18 #if AFS_GCPAGS
20 /* afs_osi_TraverseProcTable() - Walk through the systems process
21 * table, calling afs_GCPAGs_perproc_func() for each process.
26 * NOTE: h/proc_private.h gives the process table locking rules
27 * It indicates that access to p_cred must be protected by
28 * mp_mtproc_lock(p);
29 * mp_mtproc_unlock(p);
31 * The code in sys/pm_prot.c uses pcred_lock() to protect access to
32 * the process creds, and uses mp_mtproc_lock() only for audit-related
33 * changes. To be safe, we use both.
36 void
37 afs_osi_TraverseProcTable(void)
39 proc_t *p;
40 int endchain = 0;
42 MP_SPINLOCK(activeproc_lock);
43 MP_SPINLOCK(sched_lock);
44 pcred_lock();
47 * Instead of iterating through all of proc[], traverse only
48 * the list of active processes. As an example of this,
49 * see foreach_process() in sys/vm_sched.c.
51 * We hold the locks for the entire scan in order to get a
52 * consistent view of the current set of creds.
55 for (p = proc; endchain == 0; p = &proc[p->p_fandx]) {
56 if (p->p_fandx == 0) {
57 endchain = 1;
60 if (system_proc(p))
61 continue;
63 mp_mtproc_lock(p);
64 afs_GCPAGs_perproc_func(p);
65 mp_mtproc_unlock(p);
68 pcred_unlock();
69 MP_SPINUNLOCK(sched_lock);
70 MP_SPINUNLOCK(activeproc_lock);
73 /* return a pointer (sometimes a static copy ) to the cred for a
74 * given afs_proc_t.
75 * subsequent calls may overwrite the previously returned value.
77 const afs_ucred_t *
78 afs_osi_proc2cred(afs_proc_t * p)
80 if (!p)
81 return;
84 * Cannot use afs_warnuser() here, as the code path
85 * eventually wants to grab sched_lock, which is
86 * already held here
89 return p_cred(p);
92 #endif /* AFS_GCPAGS */