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
;
34 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK)
36 read_lock(&tasklist_lock
);
37 #endif /* EXPORTED_TASKLIST_LOCK */
38 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
39 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK)
41 #endif /* EXPORTED_TASKLIST_LOCK && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */
43 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */
45 #if defined(for_each_process)
46 for_each_process(p
) if (p
->pid
) {
47 #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
51 if (p
->state
& TASK_ZOMBIE
)
54 afs_GCPAGs_perproc_func(p
);
57 for_each_task(p
) if (p
->pid
) {
58 #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
62 if (p
->state
& TASK_ZOMBIE
)
65 afs_GCPAGs_perproc_func(p
);
68 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK)
70 read_unlock(&tasklist_lock
);
71 #endif /* EXPORTED_TASKLIST_LOCK */
72 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
73 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK)
75 #endif /* EXPORTED_TASKLIST_LOCK && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */
77 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */
81 /* return a pointer (sometimes a static copy ) to the cred for a
83 * subsequent calls may overwrite the previously returned value.
86 #if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_STRUCT_HAS_CRED) || defined(HAVE_LINUX_RCU_READ_LOCK))
88 afs_osi_proc2cred(afs_proc_t
* pr
)
90 afs_ucred_t
*rv
= NULL
;
91 static afs_ucred_t cr
;
97 if ((pr
->state
== TASK_RUNNING
) || (pr
->state
== TASK_INTERRUPTIBLE
)
98 || (pr
->state
== TASK_UNINTERRUPTIBLE
)
99 || (pr
->state
== TASK_STOPPED
)) {
100 /* This is dangerous. If anyone ever crfree's the cred that's
101 * returned from here, we'll go boom, because it's statically
103 atomic_set(&cr
.cr_ref
, 1);
104 afs_set_cr_uid(&cr
, task_uid(pr
));
105 #if defined(STRUCT_TASK_STRUCT_HAS_CRED)
106 get_group_info(pr
->cred
->group_info
);
107 afs_set_cr_group_info(&cr
, pr
->cred
->group_info
);
109 get_group_info(pr
->group_info
);
110 afs_set_cr_group_info(&cr
, pr
->group_info
);
119 #endif /* AFS_GCPAGS */