2 * Copyright 2000, International Business Machines Corporation and others.
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
10 #include <afsconfig.h>
11 #include "afs/param.h"
13 #include "afs/sysincludes.h" /* Standard vendor system headers */
14 #include "afsincludes.h" /* Afs-based standard headers */
15 #include "afs/afs_stats.h" /* afs statistics */
19 /* afs_osi_TraverseProcTable() - Walk through the systems process
20 * table, calling afs_GCPAGs_perproc_func() for each process.
23 #ifdef EXPORTED_TASKLIST_LOCK
24 extern rwlock_t tasklist_lock __attribute__((weak));
27 afs_osi_TraverseProcTable(void)
29 #if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_HAS_CRED) || defined(EXPORTED_RCU_READ_LOCK))
30 struct task_struct *p;
32 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK)
34 read_lock(&tasklist_lock);
35 #endif /* EXPORTED_TASKLIST_LOCK */
37 #ifdef DEFINED_FOR_EACH_PROCESS
38 for_each_process(p) if (p->pid) {
39 #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
43 if (p->state & TASK_ZOMBIE)
46 afs_GCPAGs_perproc_func(p);
49 for_each_task(p) if (p->pid) {
50 #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
54 if (p->state & TASK_ZOMBIE)
57 afs_GCPAGs_perproc_func(p);
60 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK)
62 read_unlock(&tasklist_lock);
63 #endif /* EXPORTED_TASKLIST_LOCK */
67 /* return a pointer (sometimes a static copy ) to the cred for a
69 * subsequent calls may overwrite the previously returned value.
73 afs_osi_proc2cred(afs_proc_t * pr)
75 afs_ucred_t *rv = NULL;
76 static afs_ucred_t cr;
82 if ((pr->state == TASK_RUNNING) || (pr->state == TASK_INTERRUPTIBLE)
83 || (pr->state == TASK_UNINTERRUPTIBLE)
84 || (pr->state == TASK_STOPPED)) {
86 /* This is dangerous. If anyone ever crfree's the cred that's
87 * returned from here, we'll go boom, because it's statically
90 atomic_set(&cr.cr_ref, 1);
91 afs_set_cr_uid(&cr, task_uid(pr));
93 cr.cr_ngroups = pr->ngroups;
94 memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));
102 #endif /* AFS_GCPAGS */