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"
15 #include "afs/sysincludes.h" /* Standard vendor system headers */
16 #include "afsincludes.h" /* Afs-based standard headers */
17 #include "afs/afs_stats.h" /* afs statistics */
19 #include <sys/adspace.h> /* for vm_att(), vm_det() */
22 static char memZero; /* address of 0 bytes for kmem_alloc */
28 /* osi_Init -- do once per kernel installation initialization.
29 * -- On Solaris this is called from modload initialization.
30 * -- On AIX called from afs_config.
31 * -- On HP called from afsc_link.
32 * -- On SGI called from afs_init. */
35 lock_t afs_event_lock;
45 if (once++ > 0) /* just in case */
47 #if defined(AFS_HPUX_ENV)
49 #else /* AFS_HPUX_ENV */
50 #if defined(AFS_GLOBAL_SUNLOCK)
51 #if defined(AFS_SGI62_ENV)
52 mutex_init(&afs_global_lock, MUTEX_DEFAULT, "afs_global_lock");
53 #elif defined(AFS_OSF_ENV)
54 usimple_lock_init(&afs_global_lock);
55 afs_global_owner = (thread_t)0;
56 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
57 lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0);
59 #elif defined(AFS_AIX41_ENV)
60 lock_alloc((void*)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1);
61 simple_lock_init((void *)&afs_global_lock);
62 #elif !defined(AFS_LINUX22_ENV)
63 /* Linux initialization in osi directory. Should move the others. */
64 mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
66 /* afs_rxglobal_lock is initialized in rx_Init. */
67 #endif /* AFS_GLOBAL_SUNLOCK */
68 #endif /* AFS_HPUX_ENV */
70 if ( !afs_osicred_initialized ) {
71 memset((char *)&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
72 crhold(&afs_osi_cred); /* don't let it evaporate */
73 afs_osicred_initialized = 1;
76 osi_flid.fl_pid = osi_flid.fl_sysid = 0;
80 int osi_Active(register struct vcache *avc)
82 AFS_STATCNT(osi_Active);
83 #if defined(AFS_SUN_ENV) || defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV) || (AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
84 if ((avc->opens > 0) || (avc->states & CMAPPED)) return 1; /* XXX: Warning, verify this XXX */
85 #elif defined(AFS_MACH_ENV)
86 if (avc->opens > 0 || ((avc->v.v_flag & VTEXT) && !inode_uncache_try(avc))) return 1;
87 #elif defined(AFS_SGI_ENV)
88 if ((avc->opens > 0) || AFS_VN_MAPPED(AFSTOV(avc)))
91 if (avc->opens > 0 || (AFSTOV(avc)->v_flag & VTEXT)) return(1);
96 /* this call, unlike osi_FlushText, is supposed to discard caches that may
97 contain invalid information if a file is written remotely, but that may
98 contain valid information that needs to be written back if the file is
99 being written locally. It doesn't subsume osi_FlushText, since the latter
100 function may be needed to flush caches that are invalidated by local writes.
102 avc->pvnLock is already held, avc->lock is guaranteed not to be held (by
105 void osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp)
108 ObtainReadLock(&avc->lock);
109 /* If we've already purged this version, or if we're the ones
110 writing this version, don't flush it (could lose the
111 data we're writing). */
112 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) ||
113 ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
114 ReleaseReadLock(&avc->lock);
117 ReleaseReadLock(&avc->lock);
118 ObtainWriteLock(&avc->lock,10);
120 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) ||
121 ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
122 ReleaseWriteLock(&avc->lock);
125 if (hiszero(avc->mapDV)) {
126 hset(avc->mapDV, avc->m.DataVersion);
127 ReleaseWriteLock(&avc->lock);
131 AFS_STATCNT(osi_FlushPages);
132 hset(origDV, avc->m.DataVersion);
133 afs_Trace3(afs_iclSetp, CM_TRACE_FLUSHPAGES, ICL_TYPE_POINTER, avc,
134 ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->m.Length);
136 ReleaseWriteLock(&avc->lock);
138 osi_VM_FlushPages(avc, credp);
140 ObtainWriteLock(&avc->lock,88);
142 /* do this last, and to original version, since stores may occur
143 while executing above PUTPAGE call */
144 hset(avc->mapDV, origDV);
145 ReleaseWriteLock(&avc->lock);
148 afs_lock_t afs_ftf; /* flush text lock */
152 /* This call is supposed to flush all caches that might be invalidated
153 * by either a local write operation or a write operation done on
154 * another client. This call may be called repeatedly on the same
155 * version of a file, even while a file is being written, so it
156 * shouldn't do anything that would discard newly written data before
157 * it is written to the file system. */
159 void osi_FlushText_really(register struct vcache *vp)
161 afs_hyper_t fdv; /* version before which we'll flush */
163 AFS_STATCNT(osi_FlushText);
164 /* see if we've already flushed this data version */
165 if (hcmp(vp->m.DataVersion, vp->flushDV) <= 0) return;
169 void afs_gfs_FlushText();
170 afs_gfs_FlushText(vp);
175 MObtainWriteLock(&afs_ftf,317);
176 hset(fdv, vp->m.DataVersion);
178 /* why this disgusting code below?
179 * xuntext, called by xrele, doesn't notice when it is called
180 * with a freed text object. Sun continually calls xrele or xuntext
181 * without any locking, as long as VTEXT is set on the
182 * corresponding vnode.
183 * But, if the text object is locked when you check the VTEXT
184 * flag, several processes can wait in xuntext, waiting for the
185 * text lock; when the second one finally enters xuntext's
186 * critical region, the text object is already free, but the check
187 * was already done by xuntext's caller.
188 * Even worse, it turns out that xalloc locks the text object
189 * before reading or stating a file via the vnode layer. Thus, we
190 * could end up in getdcache, being asked to bring in a new
191 * version of a file, but the corresponding text object could be
192 * locked. We can't flush the text object without causing
193 * deadlock, so now we just don't try to lock the text object
194 * unless it is guaranteed to work. And we try to flush the text
195 * when we need to a bit more often at the vnode layer. Sun
196 * really blew the vm-cache flushing interface.
199 #if defined (AFS_HPUX_ENV)
200 if (vp->v.v_flag & VTEXT) {
203 if (vp->v.v_flag & VTEXT) { /* still has a text object? */
204 MReleaseWriteLock(&afs_ftf);
210 /* next do the stuff that need not check for deadlock problems */
213 /* finally, record that we've done it */
214 hset(vp->flushDV, fdv);
215 MReleaseWriteLock(&afs_ftf);
217 #endif /* AFS_DEC_ENV */
221 /* I don't really like using xinval() here, because it kills processes
222 * a bit aggressively. Previous incarnations of this functionality
223 * used to use xrele() instead of xinval, and didn't invoke
224 * cacheinval(). But they would panic. So it might be worth looking
225 * into some middle ground...
227 static void afs_gfs_FlushText(register struct vcache *vp)
229 afs_hyper_t fdv; /* version before which we'll flush */
230 register struct text *xp;
233 MObtainWriteLock(&afs_ftf,318);
234 hset(fdv, vp->m.DataVersion);
238 /* this happens frequently after cores are created. */
239 MReleaseWriteLock(&afs_ftf);
243 if (gp->g_flag & GTEXT) {
245 xp = (struct text *) gp->g_textp ;
246 /* if text object is locked, give up */
247 if (xp && (xp->x_flag & XLOCK)) {
248 MReleaseWriteLock(&afs_ftf);
254 if (gp->g_flag & GTEXT) { /* still has a text object? */
259 /* next do the stuff that need not check for deadlock problems */
260 /* maybe xinval(gp); here instead of above */
263 /* finally, record that we've done it */
264 hset(vp->flushDV, fdv);
266 MReleaseWriteLock(&afs_ftf);
268 #endif /* AFS_DEC_ENV */
270 #endif /* AFS_TEXT_ENV */
272 /* mask signals in afsds */
273 void afs_osi_MaskSignals(void)
275 #ifdef AFS_LINUX22_ENV
280 /* unmask signals in rxk listener */
281 void afs_osi_UnmaskRxkSignals(void)
283 #ifdef AFS_LINUX22_ENV
288 /* register rxk listener proc info */
289 void afs_osi_RxkRegister(void)
291 #ifdef AFS_LINUX22_ENV
296 /* procedure for making our processes as invisible as we can */
297 void afs_osi_Invisible(void)
299 #ifdef AFS_LINUX22_ENV
300 afs_osi_MaskSignals();
301 #elif defined(AFS_DEC_ENV)
302 u.u_procp->p_type |= SSYS;
303 #elif defined(AFS_SUN5_ENV)
304 curproc->p_flag |= SSYS;
305 #elif defined(AFS_HPUX101_ENV)
306 set_system_proc(u.u_procp);
307 #elif defined(AFS_DARWIN_ENV)
308 /* maybe call init_process instead? */
309 current_proc()->p_flag |= P_SYSTEM;
310 #elif defined(AFS_XBSD_ENV)
311 curproc->p_flag |= P_SYSTEM;
312 #elif defined(AFS_SGI_ENV)
316 AFS_STATCNT(osi_Invisible);
320 #ifndef AFS_LINUX20_ENV /* Linux version in osi_misc.c */
321 /* set the real time */
322 void afs_osi_SetTime(osi_timeval_t *atv)
325 struct timestruc_t t;
327 t.tv_sec = atv->tv_sec;
328 t.tv_nsec = atv->tv_usec * 1000;
329 ksettimer(&t); /* Was -> settimer(TIMEOFDAY, &t); */
336 * To get more than second resolution we can use adjtime. The problem
337 * is that the usecs from the server are wrong (by now) so it isn't
338 * worth complicating the following code.
344 sta.time = atv->tv_sec;
348 #if defined(AFS_SGI_ENV)
354 sta.time = atv->tv_sec;
358 #if defined(AFS_FBSD_ENV)
359 /* does not impliment security features of kern_time.c:settime() */
361 struct timeval tv,delta;
367 timevalsub(&delta, &tv);
368 ts.tv_sec=atv->tv_sec;
369 ts.tv_nsec=atv->tv_usec * 1000;
370 set_timecounter(&ts);
371 (void) splsoftclock();
372 lease_updatetime(delta.tv_sec);
377 #if defined(AFS_DARWIN_ENV)
382 /* stolen from kern_time.c */
384 boottime.tv_sec += atv->tv_sec - time.tv_sec;
390 t.tv_sec = atv->tv_sec;
391 t.tv_usec = atv->tv_usec;
392 s = spl7(); time = t; (void) splx(s);
398 s = splclock(); time = *atv; (void) splx(s);
403 logtchg(atv->tv_sec);
405 #endif /* AFS_DARWIN_ENV */
406 #endif /* AFS_FBSD_ENV */
407 #endif /* AFS_SGI_ENV */
408 #endif /* AFS_SUN55_ENV */
409 #endif /* AFS_SUN5_ENV */
410 #endif /* AFS_AIX32_ENV */
411 AFS_STATCNT(osi_SetTime);
413 #endif /* AFS_LINUX20_ENV */
416 void *afs_osi_Alloc(size_t x)
418 register struct osimem *tm = NULL;
421 AFS_STATCNT(osi_Alloc);
422 /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
423 things so that NULL returned iff an error occurred */
424 if (x == 0) return &memZero;
426 AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
427 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
428 #ifdef AFS_LINUX20_ENV
429 return osi_linux_alloc(x, 1);
433 MALLOC(tm, struct osimem *, size, M_AFSGENERIC, M_WAITOK);
435 tm = (struct osimem *) AFS_KALLOC(size);
439 osi_Panic("osi_Alloc: Couldn't allocate %d bytes; out of memory!\n",
446 #if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV)
448 void *afs_osi_Alloc_NoSleep(size_t x)
450 register struct osimem *tm;
453 AFS_STATCNT(osi_Alloc);
454 /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
455 things so that NULL returned iff an error occurred */
456 if (x == 0) return &memZero;
459 AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
460 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
462 MALLOC(tm, struct osimem *, size, M_AFSGENERIC, 0);
464 tm = (struct osimem *) AFS_KALLOC_NOSLEEP(size);
469 #endif /* SUN || SGI */
471 void afs_osi_Free(void *x, size_t asize)
473 AFS_STATCNT(osi_Free);
474 if (x == &memZero) return; /* check for putting memZero back */
476 AFS_STATS(afs_stats_cmperf.OutStandingAllocs--);
477 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage -= asize);
478 #if defined(AFS_LINUX20_ENV)
480 #elif defined(AFS_OBSD_ENV)
481 FREE(x, M_AFSGENERIC);
483 AFS_KFREE((struct osimem *)x, asize);
487 void afs_osi_FreeStr(char *x)
489 afs_osi_Free(x, strlen(x) + 1);
492 /* ? is it moderately likely that there are dirty VM pages associated with
495 * Prereqs: avc must be write-locked
497 * System Dependencies: - *must* support each type of system for which
498 * memory mapped files are supported, even if all
499 * it does is return TRUE;
501 * NB: this routine should err on the side of caution for ProcessFS to work
502 * correctly (or at least, not to introduce worse bugs than already exist)
505 int osi_VMDirty_p(struct vcache *avc)
509 if (avc->execsOrWriters <= 0)
510 return 0; /* can't be many dirty pages here, I guess */
512 #if defined (AFS_AIX32_ENV)
514 /* because of the level of hardware involvment with VM and all the
515 * warnings about "This routine must be called at VMM interrupt
516 * level", I thought it would be safest to disable interrupts while
517 * looking at the software page fault table. */
519 /* convert vm handle into index into array: I think that stoinio is
520 * always zero... Look into this XXX */
521 #define VMHASH(handle) ( \
522 ( ((handle) & ~vmker.stoinio) \
523 ^ ((((handle) & ~vmker.stoinio) & vmker.stoimask) << vmker.stoihash) \
527 unsigned int pagef, pri, index, next;
529 index = VMHASH(avc->vmh);
530 if (scb_valid(index)) { /* could almost be an ASSERT */
532 pri = disable_ints();
533 for (pagef = scb_sidlist(index); pagef >= 0; pagef = next) {
534 next = pft_sidfwd(pagef);
535 if (pft_modbit(pagef)) { /* has page frame been modified? */
545 #endif /* AFS_AIX32_ENV */
547 #if defined (AFS_SUN_ENV)
548 if (avc->states & CMAPPED) {
550 for (pg = avc->v.v_s.v_Pages ; pg ; pg = pg->p_vpnext) {
563 * Solaris osi_ReleaseVM should not drop and re-obtain the vcache entry lock.
564 * This leads to bad races when osi_ReleaseVM() is called from
565 * afs_InvalidateAllSegments().
567 * We can do this because Solaris osi_VM_Truncate() doesn't care whether the
568 * vcache entry lock is held or not.
570 * For other platforms, in some cases osi_VM_Truncate() doesn't care, but
571 * there may be cases where it does care. If so, it would be good to fix
572 * them so they don't care. Until then, we assume the worst.
574 * Locking: the vcache entry lock is held. It is dropped and re-obtained.
576 void osi_ReleaseVM(struct vcache *avc, struct AFS_UCRED *acred)
580 osi_VM_Truncate(avc, 0, acred);
583 ReleaseWriteLock(&avc->lock);
585 osi_VM_Truncate(avc, 0, acred);
587 ObtainWriteLock(&avc->lock, 80);
592 void shutdown_osi(void)
594 AFS_STATCNT(shutdown_osi);
595 if (afs_cold_shutdown) {
596 LOCK_INIT(&afs_ftf, "afs_ftf");
601 int afs_osi_suser(void *credp)
603 #if defined(AFS_SUN5_ENV)
604 return afs_suser(credp);
613 /* afs_osi_TraverseProcTable() - Walk through the systems process
614 * table, calling afs_GCPAGs_perproc_func() for each process.
617 #if defined(AFS_SUN5_ENV)
618 void afs_osi_TraverseProcTable(void)
621 for (prp = practive; prp != NULL; prp = prp->p_next) {
622 afs_GCPAGs_perproc_func(prp);
627 #if defined(AFS_HPUX_ENV)
630 * NOTE: h/proc_private.h gives the process table locking rules
631 * It indicates that access to p_cred must be protected by
633 * mp_mtproc_unlock(p);
635 * The code in sys/pm_prot.c uses pcred_lock() to protect access to
636 * the process creds, and uses mp_mtproc_lock() only for audit-related
637 * changes. To be safe, we use both.
640 void afs_osi_TraverseProcTable(void)
645 MP_SPINLOCK(activeproc_lock);
646 MP_SPINLOCK(sched_lock);
650 * Instead of iterating through all of proc[], traverse only
651 * the list of active processes. As an example of this,
652 * see foreach_process() in sys/vm_sched.c.
654 * We hold the locks for the entire scan in order to get a
655 * consistent view of the current set of creds.
658 for(p = proc; endchain == 0; p = &proc[p->p_fandx]) {
659 if (p->p_fandx == 0) {
667 afs_GCPAGs_perproc_func(p);
672 MP_SPINUNLOCK(sched_lock);
673 MP_SPINUNLOCK(activeproc_lock);
677 #if defined(AFS_SGI_ENV)
680 /* TODO: Fix this later. */
681 static int SGI_ProcScanFunc(void *p, void *arg, int mode)
685 #else /* AFS_SGI65_ENV */
686 static int SGI_ProcScanFunc(proc_t *p, void *arg, int mode)
688 afs_int32 (*perproc_func)(struct proc *) = arg;
690 /* we pass in the function pointer for arg,
691 * mode ==0 for startup call, ==1 for each valid proc,
692 * and ==2 for terminate call.
695 code = perproc_func(p);
699 #endif /* AFS_SGI65_ENV */
701 void afs_osi_TraverseProcTable(void)
703 procscan(SGI_ProcScanFunc, afs_GCPAGs_perproc_func);
705 #endif /* AFS_SGI_ENV */
707 #if defined(AFS_AIX_ENV)
709 #define max_proc v.ve_proc
711 void afs_osi_TraverseProcTable(void)
717 * For binary compatibility, on AIX we need to be careful to use the
718 * proper size of a struct proc, even if it is different from what
719 * we were compiled with.
721 if (!afs_gcpags_procsize)
724 #ifndef AFS_AIX51_ENV
725 simple_lock(&proc_tbl_lock);
727 for (p = (struct proc *)v.vb_proc, i = 0;
729 p = (struct proc *)((char *)p + afs_gcpags_procsize), i++) {
732 if (p->p_pvprocp->pv_stat == SNONE)
734 if (p->p_pvprocp->pv_stat == SIDL)
736 if (p->p_pvprocp->pv_stat == SEXIT)
739 if (p->p_stat == SNONE)
741 if (p->p_stat == SIDL)
743 if (p->p_stat == SEXIT)
749 if (PROCMASK(p->p_pid) != i) {
750 afs_gcpags = AFS_GCPAGS_EPIDCHECK;
756 if ((p->p_nice < P_NICE_MIN) || (P_NICE_MAX < p->p_nice)) {
757 afs_gcpags = AFS_GCPAGS_ENICECHECK;
761 afs_GCPAGs_perproc_func(p);
763 #ifndef AFS_AIX51_ENV
764 simple_unlock(&proc_tbl_lock);
769 #if defined(AFS_OSF_ENV)
770 void afs_osi_TraverseProcTable(void)
772 struct pid_entry *pe;
774 #define pidNPID (pidtab + npid)
779 for (pe = pidtab; pe < pidNPID; ++pe) {
780 if (pe->pe_proc != PROC_NULL)
781 afs_GCPAGs_perproc_func(pe->pe_proc);
787 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
788 void afs_osi_TraverseProcTable(void)
791 LIST_FOREACH(p, &allproc, p_list) {
792 if (p->p_stat == SIDL)
794 if (p->p_stat == SZOMB)
796 if (p->p_flag & P_SYSTEM)
798 afs_GCPAGs_perproc_func(p);
803 #if defined(AFS_LINUX22_ENV)
804 void afs_osi_TraverseProcTable()
806 struct task_struct *p;
808 #ifdef EXPORTED_TASKLIST_LOCK
809 read_lock(&tasklist_lock);
811 for_each_task(p) if (p->pid) {
812 if (p->state & TASK_ZOMBIE)
814 afs_GCPAGs_perproc_func(p);
816 #ifdef EXPORTED_TASKLIST_LOCK
817 read_unlock(&tasklist_lock);
822 /* return a pointer (sometimes a static copy ) to the cred for a
824 * subsequent calls may overwrite the previously returned value.
827 #if defined(AFS_SGI65_ENV)
828 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *p)
832 #elif defined(AFS_HPUX_ENV)
833 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *p)
839 * Cannot use afs_warnuser() here, as the code path
840 * eventually wants to grab sched_lock, which is
846 #elif defined(AFS_AIX_ENV)
848 /* GLOBAL DECLARATIONS */
851 * LOCKS: the caller must do
852 * simple_lock(&proc_tbl_lock);
853 * simple_unlock(&proc_tbl_lock);
854 * around calls to this function.
857 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pproc)
859 struct AFS_UCRED *pcred = 0;
862 * pointer to process user structure valid in *our*
865 * The user structure for a process is stored in the user
866 * address space (as distinct from the kernel address
867 * space), and so to refer to the user structure of a
868 * different process we must employ special measures.
870 * I followed the example used in the AIX getproc() system
871 * call in bos/kernel/proc/getproc.c
873 struct user *xmem_userp;
875 struct xmem dp; /* ptr to xmem descriptor */
876 int xm; /* xmem result */
883 * The process private segment in which the user
884 * area is located may disappear. We need to increment
885 * its use count. Therefore we
886 * - get the proc_tbl_lock to hold the segment.
887 * - get the p_lock to lockout vm_cleardata.
888 * - vm_att to load the segment register (no check)
889 * - xmattach to bump its use count.
890 * - release the p_lock.
891 * - release the proc_tbl_lock.
892 * - do whatever we need.
893 * - xmdetach to decrement the use count.
894 * - vm_det to free the segment register (no check)
899 /* simple_lock(&proc_tbl_lock); */
900 if (pproc->p_adspace != NULLSEGVAL) {
903 simple_lock(&pproc->p_pvprocp->pv_lock);
905 simple_lock(&pproc->p_lock);
908 if (pproc->p_threadcount &&
910 pproc->p_pvprocp->pv_threadlist) {
912 pproc->p_threadlist) {
916 * arbitrarily pick the first thread in pproc
918 struct thread *pproc_thread =
920 pproc->p_pvprocp->pv_threadlist;
926 * location of 'struct user' in pproc's
929 struct user *pproc_userp =
930 pproc_thread->t_userp;
933 * create a pointer valid in my own address space
937 (struct user *)vm_att(pproc->p_adspace,
940 dp.aspace_id = XMEM_INVAL;
941 xm = xmattach(xmem_userp,
947 simple_unlock(&pproc->p_pvprocp->pv_lock);
949 simple_unlock(&pproc->p_lock);
952 /* simple_unlock(&proc_tbl_lock); */
953 if (xm == XMEM_SUCC) {
955 static struct AFS_UCRED cred;
958 * What locking should we use to protect access to the user
959 * area? If needed also change the code in AIX/osi_groups.c.
962 /* copy cred to local address space */
963 cred = *xmem_userp->U_cred;
969 vm_det((void *)xmem_userp);
975 #elif defined(AFS_OSF_ENV)
976 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
978 struct AFS_UCRED *rv=NULL;
984 if((pr->p_stat == SSLEEP) ||
985 (pr->p_stat == SRUN) ||
986 (pr->p_stat == SSTOP))
991 #elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
992 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
994 struct AFS_UCRED *rv=NULL;
995 static struct AFS_UCRED cr;
1001 if((pr->p_stat == SSLEEP) ||
1002 (pr->p_stat == SRUN) ||
1003 (pr->p_stat == SSTOP)) {
1006 cr.cr_uid=pr->p_cred->pc_ucred->cr_uid;
1007 cr.cr_ngroups=pr->p_cred->pc_ucred->cr_ngroups;
1008 memcpy(cr.cr_groups, pr->p_cred->pc_ucred->cr_groups, NGROUPS *
1016 #elif defined(AFS_LINUX22_ENV)
1017 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
1019 struct AFS_UCRED *rv=NULL;
1020 static struct AFS_UCRED cr;
1026 if ((pr->state == TASK_RUNNING) ||
1027 (pr->state == TASK_INTERRUPTIBLE) ||
1028 (pr->state == TASK_UNINTERRUPTIBLE) ||
1029 (pr->state == TASK_STOPPED)) {
1032 cr.cr_ngroups=pr->ngroups;
1033 memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));
1040 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
1042 struct AFS_UCRED *rv=NULL;
1053 #endif /* AFS_GCPAGS */