From e57c3b7bf6723016308497bd9377eb2de9ab6c14 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Thu, 29 Apr 2010 19:06:37 +0100 Subject: [PATCH] Unix CM: Use macros for process name and id access This patch uses the new osi_procname() macro to obtain the process name for setpag() warnings on BSD and Darwin, and osi_curproc() to obtain the process identity, simplifying the code. Change-Id: I1f8a4d4bbcdb09eaeea3712b1fffd1aaa3cd2fa7 Reviewed-on: http://gerrit.openafs.org/1878 Reviewed-by: Derrick Brashear Reviewed-by: Matt Benjamin Tested-by: Derrick Brashear --- src/afs/FBSD/osi_machdep.h | 1 + src/afs/afs_pag_cred.c | 14 +++----------- src/afs/afs_pioctl.c | 16 ++-------------- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/afs/FBSD/osi_machdep.h b/src/afs/FBSD/osi_machdep.h index 15cea310b0..68a462270f 100644 --- a/src/afs/FBSD/osi_machdep.h +++ b/src/afs/FBSD/osi_machdep.h @@ -108,6 +108,7 @@ extern void osi_fbsd_free(void *p); #define VROOT VV_ROOT #define v_flag v_vflag #define osi_curcred() (curthread->td_ucred) +#define osi_curproc() (curthread) #define osi_getpid() (curthread->td_proc->p_pid) #define simple_lock(x) mtx_lock(x) #define simple_unlock(x) mtx_unlock(x) diff --git a/src/afs/afs_pag_cred.c b/src/afs/afs_pag_cred.c index 491a0368e1..e08e8e7997 100644 --- a/src/afs/afs_pag_cred.c +++ b/src/afs/afs_pag_cred.c @@ -177,20 +177,12 @@ afspag_PSetTokens(char *ain, afs_int32 ainSize, afs_ucred_t **acred) if (!tcell) return ESRCH; if (set_parent_pag) { #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) -# if defined(AFS_DARWIN_ENV) - afs_proc_t *p = current_proc(); /* XXX */ char procname[256]; - proc_selfname(procname, 256); -# elif defined(AFS_FBSD_ENV) - struct thread *p = curthread; - char *procname = p->td_proc->p_comm; -# else - afs_proc_t *p = curproc; /* XXX */ - char *procname = p->p_comm; -# endif + osi_procname(procname, 256); + afs_warnuser("Process %d (%s) tried to change pags in PSetTokens\n", MyPidxx2Pid(MyPidxx), procname); - setpag(p, acred, -1, &pag, 1); + setpag(osi_curproc(), acred, -1, &pag, 1); #else setpag(acred, -1, &pag, 1); #endif diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index 57555d624e..df338d0b45 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -1862,23 +1862,11 @@ DECL_PIOCTL(PSetTokens) if (set_parent_pag) { afs_uint32 pag; #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) -# if defined(AFS_DARWIN_ENV) - afs_proc_t *p = current_proc(); /* XXX */ char procname[256]; - proc_selfname(procname, 256); -# elif defined(AFS_FBSD_ENV) - struct thread *p = curthread; - char *procname = p->td_proc->p_comm; -# elif defined(AFS_NBSD40_ENV) - afs_proc_t *p = curproc; /* XXX */ - char *procname = p->l_proc->p_comm; -# else - afs_proc_t *p = curproc; /* XXX */ - char *procname = p->p_comm; -# endif + osi_procname(procname, 256); afs_warnuser("Process %d (%s) tried to change pags in PSetTokens\n", MyPidxx2Pid(MyPidxx), procname); - if (!setpag(p, acred, -1, &pag, 1)) { + if (!setpag(osi_curproc(), acred, -1, &pag, 1)) { #else if (!setpag(acred, -1, &pag, 1)) { #endif