void afs_osi_TraverseProcTable(void) { #if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_STRUCT_HAS_CRED) || defined(HAVE_LINUX_RCU_READ_LOCK)) struct task_struct *p; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK) if (&tasklist_lock) read_lock(&tasklist_lock); #endif /* EXPORTED_TASKLIST_LOCK */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK) else #endif /* EXPORTED_TASKLIST_LOCK && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */ rcu_read_lock(); #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */ #if defined(for_each_process) for_each_process(p) if (p->pid) { #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE if (p->exit_state) continue; #else if (p->state & TASK_ZOMBIE) continue; #endif afs_GCPAGs_perproc_func(p); } #else for_each_task(p) if (p->pid) { #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE if (p->exit_state) continue; #else if (p->state & TASK_ZOMBIE) continue; #endif afs_GCPAGs_perproc_func(p); } #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK) if (&tasklist_lock) read_unlock(&tasklist_lock); #endif /* EXPORTED_TASKLIST_LOCK */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK) else #endif /* EXPORTED_TASKLIST_LOCK && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */ rcu_read_unlock(); #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */ #endif }
void afs_osi_TraverseProcTable(void) { proc_t *p; int endchain = 0; MP_SPINLOCK(activeproc_lock); MP_SPINLOCK(sched_lock); pcred_lock(); /* * Instead of iterating through all of proc[], traverse only * the list of active processes. As an example of this, * see foreach_process() in sys/vm_sched.c. * * We hold the locks for the entire scan in order to get a * consistent view of the current set of creds. */ for (p = proc; endchain == 0; p = &proc[p->p_fandx]) { if (p->p_fandx == 0) { endchain = 1; } if (system_proc(p)) continue; mp_mtproc_lock(p); afs_GCPAGs_perproc_func(p); mp_mtproc_unlock(p); } pcred_unlock(); MP_SPINUNLOCK(sched_lock); MP_SPINUNLOCK(activeproc_lock); }