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) {
78 /* Can't just invent one, must use crget() because of mutex */
79 afs_osi_credp = crdup(osi_curcred());
81 memset(&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
82 crhold(&afs_osi_cred); /* don't let it evaporate */
83 afs_osi_credp = &afs_osi_cred;
85 afs_osicred_initialized = 1;
88 osi_flid.fl_pid = osi_flid.fl_sysid = 0;
91 init_et_to_sys_error();
95 osi_Active(register struct vcache *avc)
97 AFS_STATCNT(osi_Active);
98 #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)
99 if ((avc->opens > 0) || (avc->states & CMAPPED))
100 return 1; /* XXX: Warning, verify this XXX */
101 #elif defined(AFS_MACH_ENV)
103 || ((avc->v.v_flag & VTEXT) && !inode_uncache_try(avc)))
105 #elif defined(AFS_SGI_ENV)
106 if ((avc->opens > 0) || AFS_VN_MAPPED(AFSTOV(avc)))
109 if (avc->opens > 0 || (AFSTOV(avc)->v_flag & VTEXT))
115 /* this call, unlike osi_FlushText, is supposed to discard caches that may
116 contain invalid information if a file is written remotely, but that may
117 contain valid information that needs to be written back if the file is
118 being written locally. It doesn't subsume osi_FlushText, since the latter
119 function may be needed to flush caches that are invalidated by local writes.
121 avc->pvnLock is already held, avc->lock is guaranteed not to be held (by
125 osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp)
128 ObtainReadLock(&avc->lock);
129 /* If we've already purged this version, or if we're the ones
130 * writing this version, don't flush it (could lose the
131 * data we're writing). */
132 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0)
133 || ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
134 ReleaseReadLock(&avc->lock);
137 ReleaseReadLock(&avc->lock);
138 ObtainWriteLock(&avc->lock, 10);
140 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0)
141 || ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
142 ReleaseWriteLock(&avc->lock);
145 if (hiszero(avc->mapDV)) {
146 hset(avc->mapDV, avc->m.DataVersion);
147 ReleaseWriteLock(&avc->lock);
151 AFS_STATCNT(osi_FlushPages);
152 hset(origDV, avc->m.DataVersion);
153 afs_Trace3(afs_iclSetp, CM_TRACE_FLUSHPAGES, ICL_TYPE_POINTER, avc,
154 ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->m.Length);
156 ReleaseWriteLock(&avc->lock);
158 osi_VM_FlushPages(avc, credp);
160 ObtainWriteLock(&avc->lock, 88);
162 /* do this last, and to original version, since stores may occur
163 * while executing above PUTPAGE call */
164 hset(avc->mapDV, origDV);
165 ReleaseWriteLock(&avc->lock);
168 afs_lock_t afs_ftf; /* flush text lock */
172 /* This call is supposed to flush all caches that might be invalidated
173 * by either a local write operation or a write operation done on
174 * another client. This call may be called repeatedly on the same
175 * version of a file, even while a file is being written, so it
176 * shouldn't do anything that would discard newly written data before
177 * it is written to the file system. */
180 osi_FlushText_really(register struct vcache *vp)
182 afs_hyper_t fdv; /* version before which we'll flush */
184 AFS_STATCNT(osi_FlushText);
185 /* see if we've already flushed this data version */
186 if (hcmp(vp->m.DataVersion, vp->flushDV) <= 0)
191 void afs_gfs_FlushText();
192 afs_gfs_FlushText(vp);
197 MObtainWriteLock(&afs_ftf, 317);
198 hset(fdv, vp->m.DataVersion);
200 /* why this disgusting code below?
201 * xuntext, called by xrele, doesn't notice when it is called
202 * with a freed text object. Sun continually calls xrele or xuntext
203 * without any locking, as long as VTEXT is set on the
204 * corresponding vnode.
205 * But, if the text object is locked when you check the VTEXT
206 * flag, several processes can wait in xuntext, waiting for the
207 * text lock; when the second one finally enters xuntext's
208 * critical region, the text object is already free, but the check
209 * was already done by xuntext's caller.
210 * Even worse, it turns out that xalloc locks the text object
211 * before reading or stating a file via the vnode layer. Thus, we
212 * could end up in getdcache, being asked to bring in a new
213 * version of a file, but the corresponding text object could be
214 * locked. We can't flush the text object without causing
215 * deadlock, so now we just don't try to lock the text object
216 * unless it is guaranteed to work. And we try to flush the text
217 * when we need to a bit more often at the vnode layer. Sun
218 * really blew the vm-cache flushing interface.
221 #if defined (AFS_HPUX_ENV)
222 if (vp->v.v_flag & VTEXT) {
225 if (vp->v.v_flag & VTEXT) { /* still has a text object? */
226 MReleaseWriteLock(&afs_ftf);
232 /* next do the stuff that need not check for deadlock problems */
235 /* finally, record that we've done it */
236 hset(vp->flushDV, fdv);
237 MReleaseWriteLock(&afs_ftf);
239 #endif /* AFS_DEC_ENV */
243 /* I don't really like using xinval() here, because it kills processes
244 * a bit aggressively. Previous incarnations of this functionality
245 * used to use xrele() instead of xinval, and didn't invoke
246 * cacheinval(). But they would panic. So it might be worth looking
247 * into some middle ground...
250 afs_gfs_FlushText(register struct vcache *vp)
252 afs_hyper_t fdv; /* version before which we'll flush */
253 register struct text *xp;
256 MObtainWriteLock(&afs_ftf, 318);
257 hset(fdv, vp->m.DataVersion);
261 /* this happens frequently after cores are created. */
262 MReleaseWriteLock(&afs_ftf);
266 if (gp->g_flag & GTEXT) {
268 xp = (struct text *)gp->g_textp;
269 /* if text object is locked, give up */
270 if (xp && (xp->x_flag & XLOCK)) {
271 MReleaseWriteLock(&afs_ftf);
277 if (gp->g_flag & GTEXT) { /* still has a text object? */
282 /* next do the stuff that need not check for deadlock problems */
283 /* maybe xinval(gp); here instead of above */
286 /* finally, record that we've done it */
287 hset(vp->flushDV, fdv);
289 MReleaseWriteLock(&afs_ftf);
291 #endif /* AFS_DEC_ENV */
293 #endif /* AFS_TEXT_ENV */
295 /* mask signals in afsds */
297 afs_osi_MaskSignals(void)
299 #ifdef AFS_LINUX22_ENV
304 /* unmask signals in rxk listener */
306 afs_osi_UnmaskRxkSignals(void)
310 /* register rxk listener proc info */
312 afs_osi_RxkRegister(void)
314 #ifdef AFS_LINUX22_ENV
319 /* procedure for making our processes as invisible as we can */
321 afs_osi_Invisible(void)
323 #ifdef AFS_LINUX22_ENV
324 afs_osi_MaskSignals();
325 #elif defined(AFS_DEC_ENV)
326 u.u_procp->p_type |= SSYS;
327 #elif defined(AFS_SUN5_ENV)
328 curproc->p_flag |= SSYS;
329 #elif defined(AFS_HPUX101_ENV) && !defined(AFS_HPUX1123_ENV)
330 set_system_proc(u.u_procp);
331 #elif defined(AFS_DARWIN_ENV)
332 /* maybe call init_process instead? */
333 current_proc()->p_flag |= P_SYSTEM;
334 #elif defined(AFS_XBSD_ENV)
335 curproc->p_flag |= P_SYSTEM;
336 #elif defined(AFS_SGI_ENV)
340 AFS_STATCNT(osi_Invisible);
344 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
345 /* set the real time */
347 afs_osi_SetTime(osi_timeval_t * atv)
349 #if defined(AFS_AIX32_ENV)
350 struct timestruc_t t;
352 t.tv_sec = atv->tv_sec;
353 t.tv_nsec = atv->tv_usec * 1000;
354 ksettimer(&t); /* Was -> settimer(TIMEOFDAY, &t); */
355 #elif defined(AFS_SUN55_ENV)
357 #elif defined(AFS_SUN5_ENV)
359 * To get more than second resolution we can use adjtime. The problem
360 * is that the usecs from the server are wrong (by now) so it isn't
361 * worth complicating the following code.
367 sta.time = atv->tv_sec;
370 #elif defined(AFS_SGI_ENV)
376 sta.time = atv->tv_sec;
379 #elif defined(AFS_DARWIN_ENV)
384 /* stolen from kern_time.c */
386 boottime.tv_sec += atv->tv_sec - time.tv_sec;
390 #if !defined(AFS_HPUX1122_ENV)
391 /* drop the setting of the clock for now. spl7 is not
396 t.tv_sec = atv->tv_sec;
397 t.tv_usec = atv->tv_usec;
414 logtchg(atv->tv_sec);
416 #endif /* AFS_DARWIN_ENV */
417 AFS_STATCNT(osi_SetTime);
419 #endif /* AFS_LINUX20_ENV */
423 afs_osi_Alloc(size_t x)
425 register struct osimem *tm = NULL;
428 AFS_STATCNT(osi_Alloc);
429 /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
430 * things so that NULL returned iff an error occurred */
434 AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
435 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
436 #ifdef AFS_LINUX20_ENV
437 return osi_linux_alloc(x, 1);
438 #elif defined(AFS_FBSD_ENV)
439 return osi_fbsd_alloc(x, 1);
442 tm = (struct osimem *)AFS_KALLOC(size);
445 osi_Panic("osi_Alloc: Couldn't allocate %d bytes; out of memory!\n",
452 #if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV)
455 afs_osi_Alloc_NoSleep(size_t x)
457 register struct osimem *tm;
460 AFS_STATCNT(osi_Alloc);
461 /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
462 * things so that NULL returned iff an error occurred */
467 AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
468 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
469 tm = (struct osimem *)AFS_KALLOC_NOSLEEP(size);
473 #endif /* SUN || SGI */
476 afs_osi_Free(void *x, size_t asize)
478 AFS_STATCNT(osi_Free);
480 return; /* check for putting memZero back */
482 AFS_STATS(afs_stats_cmperf.OutStandingAllocs--);
483 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage -= asize);
484 #if defined(AFS_LINUX20_ENV)
486 #elif defined(AFS_FBSD_ENV)
489 AFS_KFREE((struct osimem *)x, asize);
494 afs_osi_FreeStr(char *x)
496 afs_osi_Free(x, strlen(x) + 1);
499 /* ? is it moderately likely that there are dirty VM pages associated with
502 * Prereqs: avc must be write-locked
504 * System Dependencies: - *must* support each type of system for which
505 * memory mapped files are supported, even if all
506 * it does is return TRUE;
508 * NB: this routine should err on the side of caution for ProcessFS to work
509 * correctly (or at least, not to introduce worse bugs than already exist)
513 osi_VMDirty_p(struct vcache *avc)
517 if (avc->execsOrWriters <= 0)
518 return 0; /* can't be many dirty pages here, I guess */
520 #if defined (AFS_AIX32_ENV)
522 /* because of the level of hardware involvment with VM and all the
523 * warnings about "This routine must be called at VMM interrupt
524 * level", I thought it would be safest to disable interrupts while
525 * looking at the software page fault table. */
527 /* convert vm handle into index into array: I think that stoinio is
528 * always zero... Look into this XXX */
529 #define VMHASH(handle) ( \
530 ( ((handle) & ~vmker.stoinio) \
531 ^ ((((handle) & ~vmker.stoinio) & vmker.stoimask) << vmker.stoihash) \
535 unsigned int pagef, pri, index, next;
537 index = VMHASH(avc->segid);
538 if (scb_valid(index)) { /* could almost be an ASSERT */
540 pri = disable_ints();
541 for (pagef = scb_sidlist(index); pagef >= 0; pagef = next) {
542 next = pft_sidfwd(pagef);
543 if (pft_modbit(pagef)) { /* has page frame been modified? */
553 #endif /* AFS_AIX32_ENV */
555 #if defined (AFS_SUN_ENV)
556 if (avc->states & CMAPPED) {
558 for (pg = avc->v.v_s.v_Pages; pg; pg = pg->p_vpnext) {
571 * Solaris osi_ReleaseVM should not drop and re-obtain the vcache entry lock.
572 * This leads to bad races when osi_ReleaseVM() is called from
573 * afs_InvalidateAllSegments().
575 * We can do this because Solaris osi_VM_Truncate() doesn't care whether the
576 * vcache entry lock is held or not.
578 * For other platforms, in some cases osi_VM_Truncate() doesn't care, but
579 * there may be cases where it does care. If so, it would be good to fix
580 * them so they don't care. Until then, we assume the worst.
582 * Locking: the vcache entry lock is held. It is dropped and re-obtained.
585 osi_ReleaseVM(struct vcache *avc, struct AFS_UCRED *acred)
589 osi_VM_Truncate(avc, 0, acred);
592 ReleaseWriteLock(&avc->lock);
594 osi_VM_Truncate(avc, 0, acred);
596 ObtainWriteLock(&avc->lock, 80);
604 AFS_STATCNT(shutdown_osi);
605 if (afs_cold_shutdown) {
606 LOCK_INIT(&afs_ftf, "afs_ftf");
612 afs_osi_suser(void *credp)
614 #if defined(AFS_SUN5_ENV)
615 return afs_suser(credp);
624 /* afs_osi_TraverseProcTable() - Walk through the systems process
625 * table, calling afs_GCPAGs_perproc_func() for each process.
628 #if defined(AFS_SUN5_ENV)
630 afs_osi_TraverseProcTable(void)
633 for (prp = practive; prp != NULL; prp = prp->p_next) {
634 afs_GCPAGs_perproc_func(prp);
639 #if defined(AFS_HPUX_ENV)
642 * NOTE: h/proc_private.h gives the process table locking rules
643 * It indicates that access to p_cred must be protected by
645 * mp_mtproc_unlock(p);
647 * The code in sys/pm_prot.c uses pcred_lock() to protect access to
648 * the process creds, and uses mp_mtproc_lock() only for audit-related
649 * changes. To be safe, we use both.
653 afs_osi_TraverseProcTable(void)
658 MP_SPINLOCK(activeproc_lock);
659 MP_SPINLOCK(sched_lock);
663 * Instead of iterating through all of proc[], traverse only
664 * the list of active processes. As an example of this,
665 * see foreach_process() in sys/vm_sched.c.
667 * We hold the locks for the entire scan in order to get a
668 * consistent view of the current set of creds.
671 for (p = proc; endchain == 0; p = &proc[p->p_fandx]) {
672 if (p->p_fandx == 0) {
680 afs_GCPAGs_perproc_func(p);
685 MP_SPINUNLOCK(sched_lock);
686 MP_SPINUNLOCK(activeproc_lock);
690 #if defined(AFS_SGI_ENV)
693 /* TODO: Fix this later. */
695 SGI_ProcScanFunc(void *p, void *arg, int mode)
699 #else /* AFS_SGI65_ENV */
701 SGI_ProcScanFunc(proc_t * p, void *arg, int mode)
703 afs_int32(*perproc_func) (struct proc *) = arg;
705 /* we pass in the function pointer for arg,
706 * mode ==0 for startup call, ==1 for each valid proc,
707 * and ==2 for terminate call.
710 code = perproc_func(p);
714 #endif /* AFS_SGI65_ENV */
717 afs_osi_TraverseProcTable(void)
719 procscan(SGI_ProcScanFunc, afs_GCPAGs_perproc_func);
721 #endif /* AFS_SGI_ENV */
723 #if defined(AFS_AIX_ENV)
725 #define max_proc v.ve_proc
728 afs_osi_TraverseProcTable(void)
734 * For binary compatibility, on AIX we need to be careful to use the
735 * proper size of a struct proc, even if it is different from what
736 * we were compiled with.
738 if (!afs_gcpags_procsize)
741 #ifndef AFS_AIX51_ENV
742 simple_lock(&proc_tbl_lock);
744 for (p = (struct proc *)v.vb_proc, i = 0; p < max_proc;
745 p = (struct proc *)((char *)p + afs_gcpags_procsize), i++) {
748 if (p->p_pvprocp->pv_stat == SNONE)
750 if (p->p_pvprocp->pv_stat == SIDL)
752 if (p->p_pvprocp->pv_stat == SEXIT)
755 if (p->p_stat == SNONE)
757 if (p->p_stat == SIDL)
759 if (p->p_stat == SEXIT)
765 if (PROCMASK(p->p_pid) != i) {
766 afs_gcpags = AFS_GCPAGS_EPIDCHECK;
772 if ((p->p_nice < P_NICE_MIN) || (P_NICE_MAX < p->p_nice)) {
773 afs_gcpags = AFS_GCPAGS_ENICECHECK;
777 afs_GCPAGs_perproc_func(p);
779 #ifndef AFS_AIX51_ENV
780 simple_unlock(&proc_tbl_lock);
785 #if defined(AFS_OSF_ENV)
787 afs_osi_TraverseProcTable(void)
789 struct pid_entry *pe;
791 #define pidNPID (pidtab + npid)
796 for (pe = pidtab; pe < pidNPID; ++pe) {
797 if (pe->pe_proc != PROC_NULL)
798 afs_GCPAGs_perproc_func(pe->pe_proc);
804 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
806 afs_osi_TraverseProcTable(void)
809 LIST_FOREACH(p, &allproc, p_list) {
810 if (p->p_stat == SIDL)
812 if (p->p_stat == SZOMB)
814 if (p->p_flag & P_SYSTEM)
816 afs_GCPAGs_perproc_func(p);
821 #if defined(AFS_LINUX22_ENV)
823 afs_osi_TraverseProcTable()
825 struct task_struct *p;
827 #ifdef EXPORTED_TASKLIST_LOCK
828 read_lock(&tasklist_lock);
830 #ifdef DEFINED_FOR_EACH_PROCESS
831 for_each_process(p) if (p->pid) {
832 if (p->state & TASK_ZOMBIE)
834 afs_GCPAGs_perproc_func(p);
837 for_each_task(p) if (p->pid) {
838 if (p->state & TASK_ZOMBIE)
840 afs_GCPAGs_perproc_func(p);
843 #ifdef EXPORTED_TASKLIST_LOCK
844 read_unlock(&tasklist_lock);
849 /* return a pointer (sometimes a static copy ) to the cred for a
851 * subsequent calls may overwrite the previously returned value.
854 #if defined(AFS_SGI65_ENV)
855 const struct AFS_UCRED *
856 afs_osi_proc2cred(AFS_PROC * p)
860 #elif defined(AFS_HPUX_ENV)
861 const struct AFS_UCRED *
862 afs_osi_proc2cred(AFS_PROC * p)
868 * Cannot use afs_warnuser() here, as the code path
869 * eventually wants to grab sched_lock, which is
875 #elif defined(AFS_AIX_ENV)
877 /* GLOBAL DECLARATIONS */
880 * LOCKS: the caller must do
881 * simple_lock(&proc_tbl_lock);
882 * simple_unlock(&proc_tbl_lock);
883 * around calls to this function.
886 const struct AFS_UCRED *
887 afs_osi_proc2cred(AFS_PROC * pproc)
889 struct AFS_UCRED *pcred = 0;
892 * pointer to process user structure valid in *our*
895 * The user structure for a process is stored in the user
896 * address space (as distinct from the kernel address
897 * space), and so to refer to the user structure of a
898 * different process we must employ special measures.
900 * I followed the example used in the AIX getproc() system
901 * call in bos/kernel/proc/getproc.c
903 struct user *xmem_userp;
905 struct xmem dp; /* ptr to xmem descriptor */
906 int xm; /* xmem result */
913 * The process private segment in which the user
914 * area is located may disappear. We need to increment
915 * its use count. Therefore we
916 * - get the proc_tbl_lock to hold the segment.
917 * - get the p_lock to lockout vm_cleardata.
918 * - vm_att to load the segment register (no check)
919 * - xmattach to bump its use count.
920 * - release the p_lock.
921 * - release the proc_tbl_lock.
922 * - do whatever we need.
923 * - xmdetach to decrement the use count.
924 * - vm_det to free the segment register (no check)
929 /* simple_lock(&proc_tbl_lock); */
931 if (pproc->p_adspace != vm_handle(NULLSEGID, (int32long64_t) 0)) {
933 if (pproc->p_adspace != NULLSEGVAL) {
937 simple_lock(&pproc->p_pvprocp->pv_lock);
939 simple_lock(&pproc->p_lock);
942 if (pproc->p_threadcount &&
944 pproc->p_pvprocp->pv_threadlist) {
946 pproc->p_threadlist) {
950 * arbitrarily pick the first thread in pproc
952 struct thread *pproc_thread =
954 pproc->p_pvprocp->pv_threadlist;
960 * location of 'struct user' in pproc's
963 struct user *pproc_userp = pproc_thread->t_userp;
966 * create a pointer valid in my own address space
969 xmem_userp = (struct user *)vm_att(pproc->p_adspace, pproc_userp);
971 dp.aspace_id = XMEM_INVAL;
972 xm = xmattach(xmem_userp, sizeof(*xmem_userp), &dp, SYS_ADSPACE);
976 simple_unlock(&pproc->p_pvprocp->pv_lock);
978 simple_unlock(&pproc->p_lock);
981 /* simple_unlock(&proc_tbl_lock); */
982 if (xm == XMEM_SUCC) {
984 static struct AFS_UCRED cred;
987 * What locking should we use to protect access to the user
988 * area? If needed also change the code in AIX/osi_groups.c.
991 /* copy cred to local address space */
992 cred = *xmem_userp->U_cred;
998 vm_det((void *)xmem_userp);
1004 #elif defined(AFS_OSF_ENV)
1005 const struct AFS_UCRED *
1006 afs_osi_proc2cred(AFS_PROC * pr)
1008 struct AFS_UCRED *rv = NULL;
1014 if ((pr->p_stat == SSLEEP) || (pr->p_stat == SRUN)
1015 || (pr->p_stat == SSTOP))
1020 #elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
1021 const struct AFS_UCRED *
1022 afs_osi_proc2cred(AFS_PROC * pr)
1024 struct AFS_UCRED *rv = NULL;
1025 static struct AFS_UCRED cr;
1031 if ((pr->p_stat == SSLEEP) || (pr->p_stat == SRUN)
1032 || (pr->p_stat == SSTOP)) {
1035 cr.cr_uid = pr->p_cred->pc_ucred->cr_uid;
1036 cr.cr_ngroups = pr->p_cred->pc_ucred->cr_ngroups;
1037 memcpy(cr.cr_groups, pr->p_cred->pc_ucred->cr_groups,
1038 NGROUPS * sizeof(gid_t));
1045 #elif defined(AFS_LINUX22_ENV)
1046 const struct AFS_UCRED *
1047 afs_osi_proc2cred(AFS_PROC * pr)
1049 struct AFS_UCRED *rv = NULL;
1050 static struct AFS_UCRED cr;
1056 if ((pr->state == TASK_RUNNING) || (pr->state == TASK_INTERRUPTIBLE)
1057 || (pr->state == TASK_UNINTERRUPTIBLE)
1058 || (pr->state == TASK_STOPPED)) {
1060 cr.cr_uid = pr->uid;
1061 #if defined(AFS_LINUX26_ENV)
1065 memset(cr.cr_groups, 0, NGROUPS * sizeof(gid_t));
1067 cr.cr_ngroups = pr->group_info->ngroups;
1068 for(i = 0; i < pr->group_info->ngroups; ++i)
1069 cr.cr_groups[i] = GROUP_AT(pr->group_info, i);
1072 cr.cr_ngroups = pr->ngroups;
1073 memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));
1081 const struct AFS_UCRED *
1082 afs_osi_proc2cred(AFS_PROC * pr)
1084 struct AFS_UCRED *rv = NULL;
1095 #endif /* AFS_GCPAGS */