Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / afs / FBSD / osi_gcpags.c
CommitLineData
805e021f
CE
1/*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
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 */
9
10#include <afsconfig.h>
11#include "afs/param.h"
12
13
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 */
17
18#if AFS_GCPAGS
19
20/* afs_osi_TraverseProcTable() - Walk through the systems process
21 * table, calling afs_GCPAGs_perproc_func() for each process.
22 */
23
24void
25afs_osi_TraverseProcTable(void)
26{
27 afs_proc_t *p;
28 LIST_FOREACH(p, &allproc, p_list) {
29 if (p->p_stat == SIDL)
30 continue;
31 if (p->p_stat == SZOMB)
32 continue;
33 if (p->p_flag & P_SYSTEM)
34 continue;
35 afs_GCPAGs_perproc_func(p);
36 }
37}
38
39/* return a pointer (sometimes a static copy ) to the cred for a
40 * given afs_proc_t.
41 * subsequent calls may overwrite the previously returned value.
42 */
43const afs_ucred_t *
44afs_osi_proc2cred(afs_proc_t * pr)
45{
46 afs_ucred_t *rv = NULL;
47 static afs_ucred_t cr;
48
49 if (pr == NULL) {
50 return NULL;
51 }
52
53 if ((pr->p_stat == SSLEEP) || (pr->p_stat == SRUN)
54 || (pr->p_stat == SSTOP)) {
55 pcred_readlock(pr);
56 cr.cr_ref = 1;
57 afs_set_cr_uid(&cr, afs_cr_uid(pr->p_cred->pc_ucred));
58 cr.cr_ngroups = pr->p_cred->pc_ucred->cr_ngroups;
59 memcpy(cr.cr_groups, pr->p_cred->pc_ucred->cr_groups,
60 NGROUPS * sizeof(gid_t));
61 pcred_unlock(pr);
62 rv = &cr;
63 }
64
65 return rv;
66}
67
68#endif /* AFS_GCPAGS */