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"
16 #include "afs/sysincludes.h" /* Standard vendor system headers */
17 #include "afsincludes.h" /* Afs-based standard headers */
18 #include "afs/afs_stats.h" /* afs statistics */
20 #include <sys/adspace.h> /* for vm_att(), vm_det() */
23 static char memZero; /* address of 0 bytes for kmem_alloc */
29 /* osi_Init -- do once per kernel installation initialization.
30 * -- On Solaris this is called from modload initialization.
31 * -- On AIX called from afs_config.
32 * -- On HP called from afsc_link.
33 * -- On SGI called from afs_init. */
36 lock_t afs_event_lock;
43 struct AFS_UCRED *afs_osi_credp;
49 if (once++ > 0) /* just in case */
51 #if defined(AFS_HPUX_ENV)
53 #else /* AFS_HPUX_ENV */
54 #if defined(AFS_GLOBAL_SUNLOCK)
55 #if defined(AFS_SGI62_ENV)
56 mutex_init(&afs_global_lock, MUTEX_DEFAULT, "afs_global_lock");
57 #elif defined(AFS_OSF_ENV)
58 usimple_lock_init(&afs_global_lock);
59 afs_global_owner = (thread_t) 0;
60 #elif defined(AFS_FBSD50_ENV)
61 mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF);
62 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
63 lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0);
65 #elif defined(AFS_AIX41_ENV)
66 lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1);
67 simple_lock_init((void *)&afs_global_lock);
68 #elif !defined(AFS_LINUX22_ENV)
69 /* Linux initialization in osi directory. Should move the others. */
70 mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
72 /* afs_rxglobal_lock is initialized in rx_Init. */
73 #endif /* AFS_GLOBAL_SUNLOCK */
74 #endif /* AFS_HPUX_ENV */
76 if (!afs_osicred_initialized) {
77 #if defined(AFS_LINUX26_ENV)
78 afs_osi_credp = crref();
79 #elif defined(AFS_XBSD_ENV)
80 /* Can't just invent one, must use crget() because of mutex */
81 afs_osi_credp = crdup(osi_curcred());
83 memset(&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
84 crhold(&afs_osi_cred); /* don't let it evaporate */
85 afs_osi_credp = &afs_osi_cred;
87 afs_osicred_initialized = 1;
90 osi_flid.fl_pid = osi_flid.fl_sysid = 0;
93 init_et_to_sys_error();
97 osi_Active(register struct vcache *avc)
99 AFS_STATCNT(osi_Active);
100 #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)
101 if ((avc->opens > 0) || (avc->states & CMAPPED))
102 return 1; /* XXX: Warning, verify this XXX */
103 #elif defined(AFS_MACH_ENV)
105 || ((avc->v.v_flag & VTEXT) && !inode_uncache_try(avc)))
107 #elif defined(AFS_SGI_ENV)
108 if ((avc->opens > 0) || AFS_VN_MAPPED(AFSTOV(avc)))
111 if (avc->opens > 0 || (AFSTOV(avc)->v_flag & VTEXT))
117 /* this call, unlike osi_FlushText, is supposed to discard caches that may
118 contain invalid information if a file is written remotely, but that may
119 contain valid information that needs to be written back if the file is
120 being written locally. It doesn't subsume osi_FlushText, since the latter
121 function may be needed to flush caches that are invalidated by local writes.
123 avc->pvnLock is already held, avc->lock is guaranteed not to be held (by
127 osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp)
130 ObtainReadLock(&avc->lock);
131 /* If we've already purged this version, or if we're the ones
132 * writing this version, don't flush it (could lose the
133 * data we're writing). */
134 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0)
135 || ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
136 ReleaseReadLock(&avc->lock);
139 ReleaseReadLock(&avc->lock);
140 ObtainWriteLock(&avc->lock, 10);
142 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0)
143 || ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
144 ReleaseWriteLock(&avc->lock);
147 if (hiszero(avc->mapDV)) {
148 hset(avc->mapDV, avc->m.DataVersion);
149 ReleaseWriteLock(&avc->lock);
153 AFS_STATCNT(osi_FlushPages);
154 hset(origDV, avc->m.DataVersion);
155 afs_Trace3(afs_iclSetp, CM_TRACE_FLUSHPAGES, ICL_TYPE_POINTER, avc,
156 ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->m.Length);
158 ReleaseWriteLock(&avc->lock);
160 osi_VM_FlushPages(avc, credp);
162 ObtainWriteLock(&avc->lock, 88);
164 /* do this last, and to original version, since stores may occur
165 * while executing above PUTPAGE call */
166 hset(avc->mapDV, origDV);
167 ReleaseWriteLock(&avc->lock);
170 afs_lock_t afs_ftf; /* flush text lock */
174 /* This call is supposed to flush all caches that might be invalidated
175 * by either a local write operation or a write operation done on
176 * another client. This call may be called repeatedly on the same
177 * version of a file, even while a file is being written, so it
178 * shouldn't do anything that would discard newly written data before
179 * it is written to the file system. */
182 osi_FlushText_really(register struct vcache *vp)
184 afs_hyper_t fdv; /* version before which we'll flush */
186 AFS_STATCNT(osi_FlushText);
187 /* see if we've already flushed this data version */
188 if (hcmp(vp->m.DataVersion, vp->flushDV) <= 0)
193 void afs_gfs_FlushText();
194 afs_gfs_FlushText(vp);
199 MObtainWriteLock(&afs_ftf, 317);
200 hset(fdv, vp->m.DataVersion);
202 /* why this disgusting code below?
203 * xuntext, called by xrele, doesn't notice when it is called
204 * with a freed text object. Sun continually calls xrele or xuntext
205 * without any locking, as long as VTEXT is set on the
206 * corresponding vnode.
207 * But, if the text object is locked when you check the VTEXT
208 * flag, several processes can wait in xuntext, waiting for the
209 * text lock; when the second one finally enters xuntext's
210 * critical region, the text object is already free, but the check
211 * was already done by xuntext's caller.
212 * Even worse, it turns out that xalloc locks the text object
213 * before reading or stating a file via the vnode layer. Thus, we
214 * could end up in getdcache, being asked to bring in a new
215 * version of a file, but the corresponding text object could be
216 * locked. We can't flush the text object without causing
217 * deadlock, so now we just don't try to lock the text object
218 * unless it is guaranteed to work. And we try to flush the text
219 * when we need to a bit more often at the vnode layer. Sun
220 * really blew the vm-cache flushing interface.
223 #if defined (AFS_HPUX_ENV)
224 if (vp->v.v_flag & VTEXT) {
227 if (vp->v.v_flag & VTEXT) { /* still has a text object? */
228 MReleaseWriteLock(&afs_ftf);
234 /* next do the stuff that need not check for deadlock problems */
237 /* finally, record that we've done it */
238 hset(vp->flushDV, fdv);
239 MReleaseWriteLock(&afs_ftf);
241 #endif /* AFS_DEC_ENV */
245 /* I don't really like using xinval() here, because it kills processes
246 * a bit aggressively. Previous incarnations of this functionality
247 * used to use xrele() instead of xinval, and didn't invoke
248 * cacheinval(). But they would panic. So it might be worth looking
249 * into some middle ground...
252 afs_gfs_FlushText(register struct vcache *vp)
254 afs_hyper_t fdv; /* version before which we'll flush */
255 register struct text *xp;
258 MObtainWriteLock(&afs_ftf, 318);
259 hset(fdv, vp->m.DataVersion);
263 /* this happens frequently after cores are created. */
264 MReleaseWriteLock(&afs_ftf);
268 if (gp->g_flag & GTEXT) {
270 xp = (struct text *)gp->g_textp;
271 /* if text object is locked, give up */
272 if (xp && (xp->x_flag & XLOCK)) {
273 MReleaseWriteLock(&afs_ftf);
279 if (gp->g_flag & GTEXT) { /* still has a text object? */
284 /* next do the stuff that need not check for deadlock problems */
285 /* maybe xinval(gp); here instead of above */
288 /* finally, record that we've done it */
289 hset(vp->flushDV, fdv);
291 MReleaseWriteLock(&afs_ftf);
293 #endif /* AFS_DEC_ENV */
295 #endif /* AFS_TEXT_ENV */
297 /* mask signals in afsds */
299 afs_osi_MaskSignals(void)
301 #ifdef AFS_LINUX22_ENV
306 /* unmask signals in rxk listener */
308 afs_osi_UnmaskRxkSignals(void)
312 /* register rxk listener proc info */
314 afs_osi_RxkRegister(void)
316 #ifdef AFS_LINUX22_ENV
321 /* procedure for making our processes as invisible as we can */
323 afs_osi_Invisible(void)
325 #ifdef AFS_LINUX22_ENV
326 afs_osi_MaskSignals();
327 #elif defined(AFS_DEC_ENV)
328 u.u_procp->p_type |= SSYS;
329 #elif defined(AFS_SUN5_ENV)
330 curproc->p_flag |= SSYS;
331 #elif defined(AFS_HPUX101_ENV) && !defined(AFS_HPUX1123_ENV)
332 set_system_proc(u.u_procp);
333 #elif defined(AFS_DARWIN_ENV)
334 /* maybe call init_process instead? */
335 current_proc()->p_flag |= P_SYSTEM;
336 #elif defined(AFS_XBSD_ENV)
337 curproc->p_flag |= P_SYSTEM;
338 #elif defined(AFS_SGI_ENV)
342 AFS_STATCNT(osi_Invisible);
346 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
347 /* set the real time */
349 afs_osi_SetTime(osi_timeval_t * atv)
351 #if defined(AFS_AIX32_ENV)
352 struct timestruc_t t;
354 t.tv_sec = atv->tv_sec;
355 t.tv_nsec = atv->tv_usec * 1000;
356 ksettimer(&t); /* Was -> settimer(TIMEOFDAY, &t); */
357 #elif defined(AFS_SUN55_ENV)
359 #elif defined(AFS_SUN5_ENV)
361 * To get more than second resolution we can use adjtime. The problem
362 * is that the usecs from the server are wrong (by now) so it isn't
363 * worth complicating the following code.
369 sta.time = atv->tv_sec;
372 #elif defined(AFS_SGI_ENV)
378 sta.time = atv->tv_sec;
381 #elif defined(AFS_DARWIN_ENV)
386 /* stolen from kern_time.c */
388 boottime.tv_sec += atv->tv_sec - time.tv_sec;
392 #if !defined(AFS_HPUX1122_ENV)
393 /* drop the setting of the clock for now. spl7 is not
398 t.tv_sec = atv->tv_sec;
399 t.tv_usec = atv->tv_usec;
416 logtchg(atv->tv_sec);
418 #endif /* AFS_DARWIN_ENV */
419 AFS_STATCNT(osi_SetTime);
421 #endif /* AFS_LINUX20_ENV */
425 afs_osi_Alloc(size_t x)
427 register struct osimem *tm = NULL;
430 AFS_STATCNT(osi_Alloc);
431 /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
432 * things so that NULL returned iff an error occurred */
436 AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
437 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
438 #ifdef AFS_LINUX20_ENV
439 return osi_linux_alloc(x, 1);
440 #elif defined(AFS_FBSD_ENV)
441 return osi_fbsd_alloc(x, 1);
444 tm = (struct osimem *)AFS_KALLOC(size);
447 osi_Panic("osi_Alloc: Couldn't allocate %d bytes; out of memory!\n",
454 #if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV)
457 afs_osi_Alloc_NoSleep(size_t x)
459 register struct osimem *tm;
462 AFS_STATCNT(osi_Alloc);
463 /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
464 * things so that NULL returned iff an error occurred */
469 AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
470 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
471 tm = (struct osimem *)AFS_KALLOC_NOSLEEP(size);
475 #endif /* SUN || SGI */
478 afs_osi_Free(void *x, size_t asize)
480 AFS_STATCNT(osi_Free);
482 return; /* check for putting memZero back */
484 AFS_STATS(afs_stats_cmperf.OutStandingAllocs--);
485 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage -= asize);
486 #if defined(AFS_LINUX20_ENV)
488 #elif defined(AFS_FBSD_ENV)
491 AFS_KFREE((struct osimem *)x, asize);
496 afs_osi_FreeStr(char *x)
498 afs_osi_Free(x, strlen(x) + 1);
501 /* ? is it moderately likely that there are dirty VM pages associated with
504 * Prereqs: avc must be write-locked
506 * System Dependencies: - *must* support each type of system for which
507 * memory mapped files are supported, even if all
508 * it does is return TRUE;
510 * NB: this routine should err on the side of caution for ProcessFS to work
511 * correctly (or at least, not to introduce worse bugs than already exist)
515 osi_VMDirty_p(struct vcache *avc)
519 if (avc->execsOrWriters <= 0)
520 return 0; /* can't be many dirty pages here, I guess */
522 #if defined (AFS_AIX32_ENV)
524 /* because of the level of hardware involvment with VM and all the
525 * warnings about "This routine must be called at VMM interrupt
526 * level", I thought it would be safest to disable interrupts while
527 * looking at the software page fault table. */
529 /* convert vm handle into index into array: I think that stoinio is
530 * always zero... Look into this XXX */
531 #define VMHASH(handle) ( \
532 ( ((handle) & ~vmker.stoinio) \
533 ^ ((((handle) & ~vmker.stoinio) & vmker.stoimask) << vmker.stoihash) \
537 unsigned int pagef, pri, index, next;
539 index = VMHASH(avc->segid);
540 if (scb_valid(index)) { /* could almost be an ASSERT */
542 pri = disable_ints();
543 for (pagef = scb_sidlist(index); pagef >= 0; pagef = next) {
544 next = pft_sidfwd(pagef);
545 if (pft_modbit(pagef)) { /* has page frame been modified? */
555 #endif /* AFS_AIX32_ENV */
557 #if defined (AFS_SUN_ENV)
558 if (avc->states & CMAPPED) {
560 for (pg = avc->v.v_s.v_Pages; pg; pg = pg->p_vpnext) {
573 * Solaris osi_ReleaseVM should not drop and re-obtain the vcache entry lock.
574 * This leads to bad races when osi_ReleaseVM() is called from
575 * afs_InvalidateAllSegments().
577 * We can do this because Solaris osi_VM_Truncate() doesn't care whether the
578 * vcache entry lock is held or not.
580 * For other platforms, in some cases osi_VM_Truncate() doesn't care, but
581 * there may be cases where it does care. If so, it would be good to fix
582 * them so they don't care. Until then, we assume the worst.
584 * Locking: the vcache entry lock is held. It is dropped and re-obtained.
587 osi_ReleaseVM(struct vcache *avc, struct AFS_UCRED *acred)
591 osi_VM_Truncate(avc, 0, acred);
594 ReleaseWriteLock(&avc->lock);
596 osi_VM_Truncate(avc, 0, acred);
598 ObtainWriteLock(&avc->lock, 80);
606 AFS_STATCNT(shutdown_osi);
607 if (afs_cold_shutdown) {
608 LOCK_INIT(&afs_ftf, "afs_ftf");
614 afs_osi_suser(void *credp)
616 #if defined(AFS_SUN5_ENV)
617 return afs_suser(credp);
626 /* afs_osi_TraverseProcTable() - Walk through the systems process
627 * table, calling afs_GCPAGs_perproc_func() for each process.
630 #if defined(AFS_SUN5_ENV)
632 afs_osi_TraverseProcTable(void)
635 for (prp = practive; prp != NULL; prp = prp->p_next) {
636 afs_GCPAGs_perproc_func(prp);
641 #if defined(AFS_HPUX_ENV)
644 * NOTE: h/proc_private.h gives the process table locking rules
645 * It indicates that access to p_cred must be protected by
647 * mp_mtproc_unlock(p);
649 * The code in sys/pm_prot.c uses pcred_lock() to protect access to
650 * the process creds, and uses mp_mtproc_lock() only for audit-related
651 * changes. To be safe, we use both.
655 afs_osi_TraverseProcTable(void)
660 MP_SPINLOCK(activeproc_lock);
661 MP_SPINLOCK(sched_lock);
665 * Instead of iterating through all of proc[], traverse only
666 * the list of active processes. As an example of this,
667 * see foreach_process() in sys/vm_sched.c.
669 * We hold the locks for the entire scan in order to get a
670 * consistent view of the current set of creds.
673 for (p = proc; endchain == 0; p = &proc[p->p_fandx]) {
674 if (p->p_fandx == 0) {
682 afs_GCPAGs_perproc_func(p);
687 MP_SPINUNLOCK(sched_lock);
688 MP_SPINUNLOCK(activeproc_lock);
692 #if defined(AFS_SGI_ENV)
695 /* TODO: Fix this later. */
697 SGI_ProcScanFunc(void *p, void *arg, int mode)
701 #else /* AFS_SGI65_ENV */
703 SGI_ProcScanFunc(proc_t * p, void *arg, int mode)
705 afs_int32(*perproc_func) (struct proc *) = arg;
707 /* we pass in the function pointer for arg,
708 * mode ==0 for startup call, ==1 for each valid proc,
709 * and ==2 for terminate call.
712 code = perproc_func(p);
716 #endif /* AFS_SGI65_ENV */
719 afs_osi_TraverseProcTable(void)
721 procscan(SGI_ProcScanFunc, afs_GCPAGs_perproc_func);
723 #endif /* AFS_SGI_ENV */
725 #if defined(AFS_AIX_ENV)
727 #define max_proc v.ve_proc
730 afs_osi_TraverseProcTable(void)
736 * For binary compatibility, on AIX we need to be careful to use the
737 * proper size of a struct proc, even if it is different from what
738 * we were compiled with.
740 if (!afs_gcpags_procsize)
743 #ifndef AFS_AIX51_ENV
744 simple_lock(&proc_tbl_lock);
746 for (p = (struct proc *)v.vb_proc, i = 0; p < max_proc;
747 p = (struct proc *)((char *)p + afs_gcpags_procsize), i++) {
750 if (p->p_pvprocp->pv_stat == SNONE)
752 if (p->p_pvprocp->pv_stat == SIDL)
754 if (p->p_pvprocp->pv_stat == SEXIT)
757 if (p->p_stat == SNONE)
759 if (p->p_stat == SIDL)
761 if (p->p_stat == SEXIT)
767 if (PROCMASK(p->p_pid) != i) {
768 afs_gcpags = AFS_GCPAGS_EPIDCHECK;
774 if ((p->p_nice < P_NICE_MIN) || (P_NICE_MAX < p->p_nice)) {
775 afs_gcpags = AFS_GCPAGS_ENICECHECK;
779 afs_GCPAGs_perproc_func(p);
781 #ifndef AFS_AIX51_ENV
782 simple_unlock(&proc_tbl_lock);
787 #if defined(AFS_OSF_ENV)
789 afs_osi_TraverseProcTable(void)
791 struct pid_entry *pe;
793 #define pidNPID (pidtab + npid)
798 for (pe = pidtab; pe < pidNPID; ++pe) {
799 if (pe->pe_proc != PROC_NULL)
800 afs_GCPAGs_perproc_func(pe->pe_proc);
806 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
808 afs_osi_TraverseProcTable(void)
811 LIST_FOREACH(p, &allproc, p_list) {
812 if (p->p_stat == SIDL)
814 if (p->p_stat == SZOMB)
816 if (p->p_flag & P_SYSTEM)
818 afs_GCPAGs_perproc_func(p);
823 #if defined(AFS_LINUX22_ENV)
825 afs_osi_TraverseProcTable()
827 struct task_struct *p;
829 #ifdef EXPORTED_TASKLIST_LOCK
830 read_lock(&tasklist_lock);
832 #ifdef DEFINED_FOR_EACH_PROCESS
833 for_each_process(p) if (p->pid) {
834 if (p->state & TASK_ZOMBIE)
836 afs_GCPAGs_perproc_func(p);
839 for_each_task(p) if (p->pid) {
840 if (p->state & TASK_ZOMBIE)
842 afs_GCPAGs_perproc_func(p);
845 #ifdef EXPORTED_TASKLIST_LOCK
846 read_unlock(&tasklist_lock);
851 /* return a pointer (sometimes a static copy ) to the cred for a
853 * subsequent calls may overwrite the previously returned value.
856 #if defined(AFS_SGI65_ENV)
857 const struct AFS_UCRED *
858 afs_osi_proc2cred(AFS_PROC * p)
862 #elif defined(AFS_HPUX_ENV)
863 const struct AFS_UCRED *
864 afs_osi_proc2cred(AFS_PROC * p)
870 * Cannot use afs_warnuser() here, as the code path
871 * eventually wants to grab sched_lock, which is
877 #elif defined(AFS_AIX_ENV)
879 /* GLOBAL DECLARATIONS */
882 * LOCKS: the caller must do
883 * simple_lock(&proc_tbl_lock);
884 * simple_unlock(&proc_tbl_lock);
885 * around calls to this function.
888 const struct AFS_UCRED *
889 afs_osi_proc2cred(AFS_PROC * pproc)
891 struct AFS_UCRED *pcred = 0;
894 * pointer to process user structure valid in *our*
897 * The user structure for a process is stored in the user
898 * address space (as distinct from the kernel address
899 * space), and so to refer to the user structure of a
900 * different process we must employ special measures.
902 * I followed the example used in the AIX getproc() system
903 * call in bos/kernel/proc/getproc.c
905 struct user *xmem_userp;
907 struct xmem dp; /* ptr to xmem descriptor */
908 int xm; /* xmem result */
915 * The process private segment in which the user
916 * area is located may disappear. We need to increment
917 * its use count. Therefore we
918 * - get the proc_tbl_lock to hold the segment.
919 * - get the p_lock to lockout vm_cleardata.
920 * - vm_att to load the segment register (no check)
921 * - xmattach to bump its use count.
922 * - release the p_lock.
923 * - release the proc_tbl_lock.
924 * - do whatever we need.
925 * - xmdetach to decrement the use count.
926 * - vm_det to free the segment register (no check)
931 /* simple_lock(&proc_tbl_lock); */
933 if (pproc->p_adspace != vm_handle(NULLSEGID, (int32long64_t) 0)) {
935 if (pproc->p_adspace != NULLSEGVAL) {
939 simple_lock(&pproc->p_pvprocp->pv_lock);
941 simple_lock(&pproc->p_lock);
944 if (pproc->p_threadcount &&
946 pproc->p_pvprocp->pv_threadlist) {
948 pproc->p_threadlist) {
952 * arbitrarily pick the first thread in pproc
954 struct thread *pproc_thread =
956 pproc->p_pvprocp->pv_threadlist;
962 * location of 'struct user' in pproc's
965 struct user *pproc_userp = pproc_thread->t_userp;
968 * create a pointer valid in my own address space
971 xmem_userp = (struct user *)vm_att(pproc->p_adspace, pproc_userp);
973 dp.aspace_id = XMEM_INVAL;
974 xm = xmattach(xmem_userp, sizeof(*xmem_userp), &dp, SYS_ADSPACE);
978 simple_unlock(&pproc->p_pvprocp->pv_lock);
980 simple_unlock(&pproc->p_lock);
983 /* simple_unlock(&proc_tbl_lock); */
984 if (xm == XMEM_SUCC) {
986 static struct AFS_UCRED cred;
989 * What locking should we use to protect access to the user
990 * area? If needed also change the code in AIX/osi_groups.c.
993 /* copy cred to local address space */
994 cred = *xmem_userp->U_cred;
1000 vm_det((void *)xmem_userp);
1006 #elif defined(AFS_OSF_ENV)
1007 const struct AFS_UCRED *
1008 afs_osi_proc2cred(AFS_PROC * pr)
1010 struct AFS_UCRED *rv = NULL;
1016 if ((pr->p_stat == SSLEEP) || (pr->p_stat == SRUN)
1017 || (pr->p_stat == SSTOP))
1022 #elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
1023 const struct AFS_UCRED *
1024 afs_osi_proc2cred(AFS_PROC * pr)
1026 struct AFS_UCRED *rv = NULL;
1027 static struct AFS_UCRED cr;
1033 if ((pr->p_stat == SSLEEP) || (pr->p_stat == SRUN)
1034 || (pr->p_stat == SSTOP)) {
1037 cr.cr_uid = pr->p_cred->pc_ucred->cr_uid;
1038 cr.cr_ngroups = pr->p_cred->pc_ucred->cr_ngroups;
1039 memcpy(cr.cr_groups, pr->p_cred->pc_ucred->cr_groups,
1040 NGROUPS * sizeof(gid_t));
1047 #elif defined(AFS_LINUX22_ENV)
1048 const struct AFS_UCRED *
1049 afs_osi_proc2cred(AFS_PROC * pr)
1051 struct AFS_UCRED *rv = NULL;
1052 static struct AFS_UCRED cr;
1058 if ((pr->state == TASK_RUNNING) || (pr->state == TASK_INTERRUPTIBLE)
1059 || (pr->state == TASK_UNINTERRUPTIBLE)
1060 || (pr->state == TASK_STOPPED)) {
1062 cr.cr_uid = pr->uid;
1063 #if defined(AFS_LINUX26_ENV)
1064 get_group_info(pr->group_info);
1065 cr.cr_group_info = pr->group_info;
1067 cr.cr_ngroups = pr->ngroups;
1068 memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));
1076 const struct AFS_UCRED *
1077 afs_osi_proc2cred(AFS_PROC * pr)
1079 struct AFS_UCRED *rv = NULL;
1090 #endif /* AFS_GCPAGS */