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"
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 */
20 /* afs_osi_TraverseProcTable() - Walk through the systems process
21 * table, calling afs_GCPAGs_perproc_func() for each process.
25 #ifdef EXPORTED_TASKLIST_LOCK
26 extern rwlock_t tasklist_lock __attribute__((weak));
29 afs_osi_TraverseProcTable(void)
31 #if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_STRUCT_HAS_CRED) || defined(HAVE_LINUX_RCU_READ_LOCK))
32 struct task_struct *p;
36 #if defined(for_each_process)
37 for_each_process(p) if (p->pid) {
38 #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
42 if (p->state & TASK_ZOMBIE)
45 afs_GCPAGs_perproc_func(p);
48 for_each_task(p) if (p->pid) {
49 #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
53 if (p->state & TASK_ZOMBIE)
56 afs_GCPAGs_perproc_func(p);
64 /* return a pointer (sometimes a static copy ) to the cred for a
66 * subsequent calls may overwrite the previously returned value.
69 #if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_STRUCT_HAS_CRED) || defined(HAVE_LINUX_RCU_READ_LOCK))
71 afs_osi_proc2cred(afs_proc_t * pr)
73 afs_ucred_t *rv = NULL;
74 static afs_ucred_t cr;
80 if ((pr->state == TASK_RUNNING) || (pr->state == TASK_INTERRUPTIBLE)
81 || (pr->state == TASK_UNINTERRUPTIBLE)
82 || (pr->state == TASK_STOPPED)) {
83 /* This is dangerous. If anyone ever crfree's the cred that's
84 * returned from here, we'll go boom, because it's statically
86 atomic_set(&cr.cr_ref, 1);
87 afs_set_cr_uid(&cr, task_uid(pr));
88 #if defined(STRUCT_TASK_STRUCT_HAS_CRED)
89 get_group_info(pr->cred->group_info);
90 afs_set_cr_group_info(&cr, pr->cred->group_info);
92 get_group_info(pr->group_info);
93 afs_set_cr_group_info(&cr, pr->group_info);
102 #endif /* AFS_GCPAGS */