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;
79 init_et_to_sys_error();
82 int osi_Active(register struct vcache *avc)
84 AFS_STATCNT(osi_Active);
85 #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)
86 if ((avc->opens > 0) || (avc->states & CMAPPED)) return 1; /* XXX: Warning, verify this XXX */
87 #elif defined(AFS_MACH_ENV)
88 if (avc->opens > 0 || ((avc->v.v_flag & VTEXT) && !inode_uncache_try(avc))) return 1;
89 #elif defined(AFS_SGI_ENV)
90 if ((avc->opens > 0) || AFS_VN_MAPPED(AFSTOV(avc)))
93 if (avc->opens > 0 || (AFSTOV(avc)->v_flag & VTEXT)) return(1);
98 /* this call, unlike osi_FlushText, is supposed to discard caches that may
99 contain invalid information if a file is written remotely, but that may
100 contain valid information that needs to be written back if the file is
101 being written locally. It doesn't subsume osi_FlushText, since the latter
102 function may be needed to flush caches that are invalidated by local writes.
104 avc->pvnLock is already held, avc->lock is guaranteed not to be held (by
107 void osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp)
110 ObtainReadLock(&avc->lock);
111 /* If we've already purged this version, or if we're the ones
112 writing this version, don't flush it (could lose the
113 data we're writing). */
114 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) ||
115 ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
116 ReleaseReadLock(&avc->lock);
119 ReleaseReadLock(&avc->lock);
120 ObtainWriteLock(&avc->lock,10);
122 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) ||
123 ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
124 ReleaseWriteLock(&avc->lock);
127 if (hiszero(avc->mapDV)) {
128 hset(avc->mapDV, avc->m.DataVersion);
129 ReleaseWriteLock(&avc->lock);
133 AFS_STATCNT(osi_FlushPages);
134 hset(origDV, avc->m.DataVersion);
135 afs_Trace3(afs_iclSetp, CM_TRACE_FLUSHPAGES, ICL_TYPE_POINTER, avc,
136 ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->m.Length);
138 ReleaseWriteLock(&avc->lock);
140 osi_VM_FlushPages(avc, credp);
142 ObtainWriteLock(&avc->lock,88);
144 /* do this last, and to original version, since stores may occur
145 while executing above PUTPAGE call */
146 hset(avc->mapDV, origDV);
147 ReleaseWriteLock(&avc->lock);
150 afs_lock_t afs_ftf; /* flush text lock */
154 /* This call is supposed to flush all caches that might be invalidated
155 * by either a local write operation or a write operation done on
156 * another client. This call may be called repeatedly on the same
157 * version of a file, even while a file is being written, so it
158 * shouldn't do anything that would discard newly written data before
159 * it is written to the file system. */
161 void osi_FlushText_really(register struct vcache *vp)
163 afs_hyper_t fdv; /* version before which we'll flush */
165 AFS_STATCNT(osi_FlushText);
166 /* see if we've already flushed this data version */
167 if (hcmp(vp->m.DataVersion, vp->flushDV) <= 0) return;
171 void afs_gfs_FlushText();
172 afs_gfs_FlushText(vp);
177 MObtainWriteLock(&afs_ftf,317);
178 hset(fdv, vp->m.DataVersion);
180 /* why this disgusting code below?
181 * xuntext, called by xrele, doesn't notice when it is called
182 * with a freed text object. Sun continually calls xrele or xuntext
183 * without any locking, as long as VTEXT is set on the
184 * corresponding vnode.
185 * But, if the text object is locked when you check the VTEXT
186 * flag, several processes can wait in xuntext, waiting for the
187 * text lock; when the second one finally enters xuntext's
188 * critical region, the text object is already free, but the check
189 * was already done by xuntext's caller.
190 * Even worse, it turns out that xalloc locks the text object
191 * before reading or stating a file via the vnode layer. Thus, we
192 * could end up in getdcache, being asked to bring in a new
193 * version of a file, but the corresponding text object could be
194 * locked. We can't flush the text object without causing
195 * deadlock, so now we just don't try to lock the text object
196 * unless it is guaranteed to work. And we try to flush the text
197 * when we need to a bit more often at the vnode layer. Sun
198 * really blew the vm-cache flushing interface.
201 #if defined (AFS_HPUX_ENV)
202 if (vp->v.v_flag & VTEXT) {
205 if (vp->v.v_flag & VTEXT) { /* still has a text object? */
206 MReleaseWriteLock(&afs_ftf);
212 /* next do the stuff that need not check for deadlock problems */
215 /* finally, record that we've done it */
216 hset(vp->flushDV, fdv);
217 MReleaseWriteLock(&afs_ftf);
219 #endif /* AFS_DEC_ENV */
223 /* I don't really like using xinval() here, because it kills processes
224 * a bit aggressively. Previous incarnations of this functionality
225 * used to use xrele() instead of xinval, and didn't invoke
226 * cacheinval(). But they would panic. So it might be worth looking
227 * into some middle ground...
229 static void afs_gfs_FlushText(register struct vcache *vp)
231 afs_hyper_t fdv; /* version before which we'll flush */
232 register struct text *xp;
235 MObtainWriteLock(&afs_ftf,318);
236 hset(fdv, vp->m.DataVersion);
240 /* this happens frequently after cores are created. */
241 MReleaseWriteLock(&afs_ftf);
245 if (gp->g_flag & GTEXT) {
247 xp = (struct text *) gp->g_textp ;
248 /* if text object is locked, give up */
249 if (xp && (xp->x_flag & XLOCK)) {
250 MReleaseWriteLock(&afs_ftf);
256 if (gp->g_flag & GTEXT) { /* still has a text object? */
261 /* next do the stuff that need not check for deadlock problems */
262 /* maybe xinval(gp); here instead of above */
265 /* finally, record that we've done it */
266 hset(vp->flushDV, fdv);
268 MReleaseWriteLock(&afs_ftf);
270 #endif /* AFS_DEC_ENV */
272 #endif /* AFS_TEXT_ENV */
274 /* mask signals in afsds */
275 void afs_osi_MaskSignals(void)
277 #ifdef AFS_LINUX22_ENV
282 /* unmask signals in rxk listener */
283 void afs_osi_UnmaskRxkSignals(void)
287 /* register rxk listener proc info */
288 void afs_osi_RxkRegister(void)
290 #ifdef AFS_LINUX22_ENV
295 /* procedure for making our processes as invisible as we can */
296 void afs_osi_Invisible(void)
298 #ifdef AFS_LINUX22_ENV
299 afs_osi_MaskSignals();
300 #elif defined(AFS_DEC_ENV)
301 u.u_procp->p_type |= SSYS;
302 #elif defined(AFS_SUN5_ENV)
303 curproc->p_flag |= SSYS;
304 #elif defined(AFS_HPUX101_ENV)
305 set_system_proc(u.u_procp);
306 #elif defined(AFS_DARWIN_ENV)
307 /* maybe call init_process instead? */
308 current_proc()->p_flag |= P_SYSTEM;
309 #elif defined(AFS_XBSD_ENV)
310 curproc->p_flag |= P_SYSTEM;
311 #elif defined(AFS_SGI_ENV)
315 AFS_STATCNT(osi_Invisible);
319 #ifndef AFS_LINUX20_ENV /* Linux version in osi_misc.c */
320 /* set the real time */
321 void afs_osi_SetTime(osi_timeval_t *atv)
324 struct timestruc_t t;
326 t.tv_sec = atv->tv_sec;
327 t.tv_nsec = atv->tv_usec * 1000;
328 ksettimer(&t); /* Was -> settimer(TIMEOFDAY, &t); */
335 * To get more than second resolution we can use adjtime. The problem
336 * is that the usecs from the server are wrong (by now) so it isn't
337 * worth complicating the following code.
343 sta.time = atv->tv_sec;
347 #if defined(AFS_SGI_ENV)
353 sta.time = atv->tv_sec;
357 #if defined(AFS_FBSD_ENV)
358 /* does not impliment security features of kern_time.c:settime() */
360 struct timeval tv,delta;
366 timevalsub(&delta, &tv);
367 ts.tv_sec=atv->tv_sec;
368 ts.tv_nsec=atv->tv_usec * 1000;
369 set_timecounter(&ts);
370 (void) splsoftclock();
371 lease_updatetime(delta.tv_sec);
376 #if defined(AFS_DARWIN_ENV)
381 /* stolen from kern_time.c */
383 boottime.tv_sec += atv->tv_sec - time.tv_sec;
387 #if !defined(AFS_HPUX1122_ENV)
388 /* drop the setting of the clock for now. spl7 is not
393 t.tv_sec = atv->tv_sec;
394 t.tv_usec = atv->tv_usec;
395 s = spl7(); time = t; (void) splx(s);
402 s = splclock(); time = *atv; (void) splx(s);
407 logtchg(atv->tv_sec);
409 #endif /* AFS_DARWIN_ENV */
410 #endif /* AFS_FBSD_ENV */
411 #endif /* AFS_SGI_ENV */
412 #endif /* AFS_SUN55_ENV */
413 #endif /* AFS_SUN5_ENV */
414 #endif /* AFS_AIX32_ENV */
415 AFS_STATCNT(osi_SetTime);
417 #endif /* AFS_LINUX20_ENV */
420 void *afs_osi_Alloc(size_t x)
422 register struct osimem *tm = NULL;
425 AFS_STATCNT(osi_Alloc);
426 /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
427 things so that NULL returned iff an error occurred */
428 if (x == 0) return &memZero;
430 AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
431 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
432 #ifdef AFS_LINUX20_ENV
433 return osi_linux_alloc(x, 1);
436 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);
461 tm = (struct osimem *) AFS_KALLOC_NOSLEEP(size);
465 #endif /* SUN || SGI */
467 void afs_osi_Free(void *x, size_t asize)
469 AFS_STATCNT(osi_Free);
470 if (x == &memZero) return; /* check for putting memZero back */
472 AFS_STATS(afs_stats_cmperf.OutStandingAllocs--);
473 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage -= asize);
474 #if defined(AFS_LINUX20_ENV)
477 AFS_KFREE((struct osimem *)x, asize);
481 void afs_osi_FreeStr(char *x)
483 afs_osi_Free(x, strlen(x) + 1);
486 /* ? is it moderately likely that there are dirty VM pages associated with
489 * Prereqs: avc must be write-locked
491 * System Dependencies: - *must* support each type of system for which
492 * memory mapped files are supported, even if all
493 * it does is return TRUE;
495 * NB: this routine should err on the side of caution for ProcessFS to work
496 * correctly (or at least, not to introduce worse bugs than already exist)
499 int osi_VMDirty_p(struct vcache *avc)
503 if (avc->execsOrWriters <= 0)
504 return 0; /* can't be many dirty pages here, I guess */
506 #if defined (AFS_AIX32_ENV)
508 /* because of the level of hardware involvment with VM and all the
509 * warnings about "This routine must be called at VMM interrupt
510 * level", I thought it would be safest to disable interrupts while
511 * looking at the software page fault table. */
513 /* convert vm handle into index into array: I think that stoinio is
514 * always zero... Look into this XXX */
515 #define VMHASH(handle) ( \
516 ( ((handle) & ~vmker.stoinio) \
517 ^ ((((handle) & ~vmker.stoinio) & vmker.stoimask) << vmker.stoihash) \
521 unsigned int pagef, pri, index, next;
523 index = VMHASH(avc->vmh);
524 if (scb_valid(index)) { /* could almost be an ASSERT */
526 pri = disable_ints();
527 for (pagef = scb_sidlist(index); pagef >= 0; pagef = next) {
528 next = pft_sidfwd(pagef);
529 if (pft_modbit(pagef)) { /* has page frame been modified? */
539 #endif /* AFS_AIX32_ENV */
541 #if defined (AFS_SUN_ENV)
542 if (avc->states & CMAPPED) {
544 for (pg = avc->v.v_s.v_Pages ; pg ; pg = pg->p_vpnext) {
557 * Solaris osi_ReleaseVM should not drop and re-obtain the vcache entry lock.
558 * This leads to bad races when osi_ReleaseVM() is called from
559 * afs_InvalidateAllSegments().
561 * We can do this because Solaris osi_VM_Truncate() doesn't care whether the
562 * vcache entry lock is held or not.
564 * For other platforms, in some cases osi_VM_Truncate() doesn't care, but
565 * there may be cases where it does care. If so, it would be good to fix
566 * them so they don't care. Until then, we assume the worst.
568 * Locking: the vcache entry lock is held. It is dropped and re-obtained.
570 void osi_ReleaseVM(struct vcache *avc, struct AFS_UCRED *acred)
574 osi_VM_Truncate(avc, 0, acred);
577 ReleaseWriteLock(&avc->lock);
579 osi_VM_Truncate(avc, 0, acred);
581 ObtainWriteLock(&avc->lock, 80);
586 void shutdown_osi(void)
588 AFS_STATCNT(shutdown_osi);
589 if (afs_cold_shutdown) {
590 LOCK_INIT(&afs_ftf, "afs_ftf");
595 int afs_osi_suser(void *credp)
597 #if defined(AFS_SUN5_ENV)
598 return afs_suser(credp);
607 /* afs_osi_TraverseProcTable() - Walk through the systems process
608 * table, calling afs_GCPAGs_perproc_func() for each process.
611 #if defined(AFS_SUN5_ENV)
612 void afs_osi_TraverseProcTable(void)
615 for (prp = practive; prp != NULL; prp = prp->p_next) {
616 afs_GCPAGs_perproc_func(prp);
621 #if defined(AFS_HPUX_ENV)
624 * NOTE: h/proc_private.h gives the process table locking rules
625 * It indicates that access to p_cred must be protected by
627 * mp_mtproc_unlock(p);
629 * The code in sys/pm_prot.c uses pcred_lock() to protect access to
630 * the process creds, and uses mp_mtproc_lock() only for audit-related
631 * changes. To be safe, we use both.
634 void afs_osi_TraverseProcTable(void)
639 MP_SPINLOCK(activeproc_lock);
640 MP_SPINLOCK(sched_lock);
644 * Instead of iterating through all of proc[], traverse only
645 * the list of active processes. As an example of this,
646 * see foreach_process() in sys/vm_sched.c.
648 * We hold the locks for the entire scan in order to get a
649 * consistent view of the current set of creds.
652 for(p = proc; endchain == 0; p = &proc[p->p_fandx]) {
653 if (p->p_fandx == 0) {
661 afs_GCPAGs_perproc_func(p);
666 MP_SPINUNLOCK(sched_lock);
667 MP_SPINUNLOCK(activeproc_lock);
671 #if defined(AFS_SGI_ENV)
674 /* TODO: Fix this later. */
675 static int SGI_ProcScanFunc(void *p, void *arg, int mode)
679 #else /* AFS_SGI65_ENV */
680 static int SGI_ProcScanFunc(proc_t *p, void *arg, int mode)
682 afs_int32 (*perproc_func)(struct proc *) = arg;
684 /* we pass in the function pointer for arg,
685 * mode ==0 for startup call, ==1 for each valid proc,
686 * and ==2 for terminate call.
689 code = perproc_func(p);
693 #endif /* AFS_SGI65_ENV */
695 void afs_osi_TraverseProcTable(void)
697 procscan(SGI_ProcScanFunc, afs_GCPAGs_perproc_func);
699 #endif /* AFS_SGI_ENV */
701 #if defined(AFS_AIX_ENV)
703 #define max_proc v.ve_proc
705 void afs_osi_TraverseProcTable(void)
711 * For binary compatibility, on AIX we need to be careful to use the
712 * proper size of a struct proc, even if it is different from what
713 * we were compiled with.
715 if (!afs_gcpags_procsize)
718 #ifndef AFS_AIX51_ENV
719 simple_lock(&proc_tbl_lock);
721 for (p = (struct proc *)v.vb_proc, i = 0;
723 p = (struct proc *)((char *)p + afs_gcpags_procsize), i++) {
726 if (p->p_pvprocp->pv_stat == SNONE)
728 if (p->p_pvprocp->pv_stat == SIDL)
730 if (p->p_pvprocp->pv_stat == SEXIT)
733 if (p->p_stat == SNONE)
735 if (p->p_stat == SIDL)
737 if (p->p_stat == SEXIT)
743 if (PROCMASK(p->p_pid) != i) {
744 afs_gcpags = AFS_GCPAGS_EPIDCHECK;
750 if ((p->p_nice < P_NICE_MIN) || (P_NICE_MAX < p->p_nice)) {
751 afs_gcpags = AFS_GCPAGS_ENICECHECK;
755 afs_GCPAGs_perproc_func(p);
757 #ifndef AFS_AIX51_ENV
758 simple_unlock(&proc_tbl_lock);
763 #if defined(AFS_OSF_ENV)
764 void afs_osi_TraverseProcTable(void)
766 struct pid_entry *pe;
768 #define pidNPID (pidtab + npid)
773 for (pe = pidtab; pe < pidNPID; ++pe) {
774 if (pe->pe_proc != PROC_NULL)
775 afs_GCPAGs_perproc_func(pe->pe_proc);
781 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
782 void afs_osi_TraverseProcTable(void)
785 LIST_FOREACH(p, &allproc, p_list) {
786 if (p->p_stat == SIDL)
788 if (p->p_stat == SZOMB)
790 if (p->p_flag & P_SYSTEM)
792 afs_GCPAGs_perproc_func(p);
797 #if defined(AFS_LINUX22_ENV)
798 void afs_osi_TraverseProcTable()
800 struct task_struct *p;
802 #ifdef EXPORTED_TASKLIST_LOCK
803 read_lock(&tasklist_lock);
805 #ifdef DEFINED_FOR_EACH_PROCESS
806 for_each_process(p) if (p->pid) {
807 if (p->state & TASK_ZOMBIE)
809 afs_GCPAGs_perproc_func(p);
812 for_each_task(p) if (p->pid) {
813 if (p->state & TASK_ZOMBIE)
815 afs_GCPAGs_perproc_func(p);
818 #ifdef EXPORTED_TASKLIST_LOCK
819 read_unlock(&tasklist_lock);
824 /* return a pointer (sometimes a static copy ) to the cred for a
826 * subsequent calls may overwrite the previously returned value.
829 #if defined(AFS_SGI65_ENV)
830 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *p)
834 #elif defined(AFS_HPUX_ENV)
835 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *p)
841 * Cannot use afs_warnuser() here, as the code path
842 * eventually wants to grab sched_lock, which is
848 #elif defined(AFS_AIX_ENV)
850 /* GLOBAL DECLARATIONS */
853 * LOCKS: the caller must do
854 * simple_lock(&proc_tbl_lock);
855 * simple_unlock(&proc_tbl_lock);
856 * around calls to this function.
859 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pproc)
861 struct AFS_UCRED *pcred = 0;
864 * pointer to process user structure valid in *our*
867 * The user structure for a process is stored in the user
868 * address space (as distinct from the kernel address
869 * space), and so to refer to the user structure of a
870 * different process we must employ special measures.
872 * I followed the example used in the AIX getproc() system
873 * call in bos/kernel/proc/getproc.c
875 struct user *xmem_userp;
877 struct xmem dp; /* ptr to xmem descriptor */
878 int xm; /* xmem result */
885 * The process private segment in which the user
886 * area is located may disappear. We need to increment
887 * its use count. Therefore we
888 * - get the proc_tbl_lock to hold the segment.
889 * - get the p_lock to lockout vm_cleardata.
890 * - vm_att to load the segment register (no check)
891 * - xmattach to bump its use count.
892 * - release the p_lock.
893 * - release the proc_tbl_lock.
894 * - do whatever we need.
895 * - xmdetach to decrement the use count.
896 * - vm_det to free the segment register (no check)
901 /* simple_lock(&proc_tbl_lock); */
902 if (pproc->p_adspace != NULLSEGVAL) {
905 simple_lock(&pproc->p_pvprocp->pv_lock);
907 simple_lock(&pproc->p_lock);
910 if (pproc->p_threadcount &&
912 pproc->p_pvprocp->pv_threadlist) {
914 pproc->p_threadlist) {
918 * arbitrarily pick the first thread in pproc
920 struct thread *pproc_thread =
922 pproc->p_pvprocp->pv_threadlist;
928 * location of 'struct user' in pproc's
931 struct user *pproc_userp =
932 pproc_thread->t_userp;
935 * create a pointer valid in my own address space
939 (struct user *)vm_att(pproc->p_adspace,
942 dp.aspace_id = XMEM_INVAL;
943 xm = xmattach(xmem_userp,
949 simple_unlock(&pproc->p_pvprocp->pv_lock);
951 simple_unlock(&pproc->p_lock);
954 /* simple_unlock(&proc_tbl_lock); */
955 if (xm == XMEM_SUCC) {
957 static struct AFS_UCRED cred;
960 * What locking should we use to protect access to the user
961 * area? If needed also change the code in AIX/osi_groups.c.
964 /* copy cred to local address space */
965 cred = *xmem_userp->U_cred;
971 vm_det((void *)xmem_userp);
977 #elif defined(AFS_OSF_ENV)
978 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
980 struct AFS_UCRED *rv=NULL;
986 if((pr->p_stat == SSLEEP) ||
987 (pr->p_stat == SRUN) ||
988 (pr->p_stat == SSTOP))
993 #elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
994 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
996 struct AFS_UCRED *rv=NULL;
997 static struct AFS_UCRED cr;
1003 if((pr->p_stat == SSLEEP) ||
1004 (pr->p_stat == SRUN) ||
1005 (pr->p_stat == SSTOP)) {
1008 cr.cr_uid=pr->p_cred->pc_ucred->cr_uid;
1009 cr.cr_ngroups=pr->p_cred->pc_ucred->cr_ngroups;
1010 memcpy(cr.cr_groups, pr->p_cred->pc_ucred->cr_groups, NGROUPS *
1018 #elif defined(AFS_LINUX22_ENV)
1019 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
1021 struct AFS_UCRED *rv=NULL;
1022 static struct AFS_UCRED cr;
1028 if ((pr->state == TASK_RUNNING) ||
1029 (pr->state == TASK_INTERRUPTIBLE) ||
1030 (pr->state == TASK_UNINTERRUPTIBLE) ||
1031 (pr->state == TASK_STOPPED)) {
1034 cr.cr_ngroups=pr->ngroups;
1035 memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));
1042 const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
1044 struct AFS_UCRED *rv=NULL;
1055 #endif /* AFS_GCPAGS */