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 #if !defined(AFS_DARWIN80_ENV)
64 lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0);
67 #elif defined(AFS_AIX41_ENV)
68 lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1);
69 simple_lock_init((void *)&afs_global_lock);
70 #elif !defined(AFS_LINUX22_ENV)
71 /* Linux initialization in osi directory. Should move the others. */
72 mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
74 /* afs_rxglobal_lock is initialized in rx_Init. */
75 #endif /* AFS_GLOBAL_SUNLOCK */
76 #endif /* AFS_HPUX_ENV */
78 if (!afs_osicred_initialized) {
79 #if defined(AFS_DARWIN80_ENV)
80 afs_osi_ctxtp_initialized = 0;
81 afs_osi_ctxtp = NULL; /* initialized in afs_Daemon since it has
82 a proc reference that cannot be changed */
84 #if defined(AFS_XBSD_ENV)
85 /* Can't just invent one, must use crget() because of mutex */
86 afs_osi_credp = crdup(osi_curcred());
88 memset(&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
89 #if defined(AFS_LINUX26_ENV)
90 afs_osi_cred.cr_group_info = groups_alloc(0);
92 #if defined(AFS_DARWIN80_ENV)
93 afs_osi_cred.cr_ref = 1; /* kauth_cred_get_ref needs 1 existing ref */
95 crhold(&afs_osi_cred); /* don't let it evaporate */
98 afs_osi_credp = &afs_osi_cred;
100 afs_osicred_initialized = 1;
103 osi_flid.fl_pid = osi_flid.fl_sysid = 0;
106 init_et_to_sys_error();
110 osi_Active(register struct vcache *avc)
112 AFS_STATCNT(osi_Active);
113 #if defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV) || (AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
114 if ((avc->opens > 0) || (avc->states & CMAPPED))
115 return 1; /* XXX: Warning, verify this XXX */
116 #elif defined(AFS_SGI_ENV)
117 if ((avc->opens > 0) || AFS_VN_MAPPED(AFSTOV(avc)))
120 if (avc->opens > 0 || (AFSTOV(avc)->v_flag & VTEXT))
126 /* this call, unlike osi_FlushText, is supposed to discard caches that may
127 contain invalid information if a file is written remotely, but that may
128 contain valid information that needs to be written back if the file is
129 being written locally. It doesn't subsume osi_FlushText, since the latter
130 function may be needed to flush caches that are invalidated by local writes.
132 avc->pvnLock is already held, avc->lock is guaranteed not to be held (by
136 osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp)
139 ObtainReadLock(&avc->lock);
140 /* If we've already purged this version, or if we're the ones
141 * writing this version, don't flush it (could lose the
142 * data we're writing). */
143 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0)
144 || ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
145 ReleaseReadLock(&avc->lock);
148 ReleaseReadLock(&avc->lock);
149 ObtainWriteLock(&avc->lock, 10);
151 if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0)
152 || ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
153 ReleaseWriteLock(&avc->lock);
156 if (hiszero(avc->mapDV)) {
157 hset(avc->mapDV, avc->m.DataVersion);
158 ReleaseWriteLock(&avc->lock);
162 AFS_STATCNT(osi_FlushPages);
163 hset(origDV, avc->m.DataVersion);
164 afs_Trace3(afs_iclSetp, CM_TRACE_FLUSHPAGES, ICL_TYPE_POINTER, avc,
165 ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->m.Length);
167 ReleaseWriteLock(&avc->lock);
169 osi_VM_FlushPages(avc, credp);
171 ObtainWriteLock(&avc->lock, 88);
173 /* do this last, and to original version, since stores may occur
174 * while executing above PUTPAGE call */
175 hset(avc->mapDV, origDV);
176 ReleaseWriteLock(&avc->lock);
179 afs_lock_t afs_ftf; /* flush text lock */
183 /* This call is supposed to flush all caches that might be invalidated
184 * by either a local write operation or a write operation done on
185 * another client. This call may be called repeatedly on the same
186 * version of a file, even while a file is being written, so it
187 * shouldn't do anything that would discard newly written data before
188 * it is written to the file system. */
191 osi_FlushText_really(register struct vcache *vp)
193 afs_hyper_t fdv; /* version before which we'll flush */
195 AFS_STATCNT(osi_FlushText);
196 /* see if we've already flushed this data version */
197 if (hcmp(vp->m.DataVersion, vp->flushDV) <= 0)
200 MObtainWriteLock(&afs_ftf, 317);
201 hset(fdv, vp->m.DataVersion);
203 /* why this disgusting code below?
204 * xuntext, called by xrele, doesn't notice when it is called
205 * with a freed text object. Sun continually calls xrele or xuntext
206 * without any locking, as long as VTEXT is set on the
207 * corresponding vnode.
208 * But, if the text object is locked when you check the VTEXT
209 * flag, several processes can wait in xuntext, waiting for the
210 * text lock; when the second one finally enters xuntext's
211 * critical region, the text object is already free, but the check
212 * was already done by xuntext's caller.
213 * Even worse, it turns out that xalloc locks the text object
214 * before reading or stating a file via the vnode layer. Thus, we
215 * could end up in getdcache, being asked to bring in a new
216 * version of a file, but the corresponding text object could be
217 * locked. We can't flush the text object without causing
218 * deadlock, so now we just don't try to lock the text object
219 * unless it is guaranteed to work. And we try to flush the text
220 * when we need to a bit more often at the vnode layer. Sun
221 * really blew the vm-cache flushing interface.
224 #if defined (AFS_HPUX_ENV)
225 if (vp->v.v_flag & VTEXT) {
228 if (vp->v.v_flag & VTEXT) { /* still has a text object? */
229 MReleaseWriteLock(&afs_ftf);
235 /* next do the stuff that need not check for deadlock problems */
238 /* finally, record that we've done it */
239 hset(vp->flushDV, fdv);
240 MReleaseWriteLock(&afs_ftf);
243 #endif /* AFS_TEXT_ENV */
245 /* mask signals in afsds */
247 afs_osi_MaskSignals(void)
249 #ifdef AFS_LINUX22_ENV
254 /* unmask signals in rxk listener */
256 afs_osi_UnmaskRxkSignals(void)
260 /* Two hacks to try and fix afsdb */
262 afs_osi_MaskUserLoop()
264 #ifdef AFS_DARWIN_ENV
266 afs_osi_fullSigMask();
268 afs_osi_MaskSignals();
273 afs_osi_UnmaskUserLoop()
275 #ifdef AFS_DARWIN_ENV
276 afs_osi_fullSigRestore();
280 /* register rxk listener proc info */
282 afs_osi_RxkRegister(void)
284 #ifdef AFS_LINUX22_ENV
289 /* procedure for making our processes as invisible as we can */
291 afs_osi_Invisible(void)
293 #ifdef AFS_LINUX22_ENV
294 afs_osi_MaskSignals();
295 #elif defined(AFS_SUN5_ENV)
296 curproc->p_flag |= SSYS;
297 #elif defined(AFS_HPUX101_ENV) && !defined(AFS_HPUX1123_ENV)
298 set_system_proc(u.u_procp);
299 #elif defined(AFS_DARWIN80_ENV)
300 #elif defined(AFS_DARWIN_ENV)
301 /* maybe call init_process instead? */
302 current_proc()->p_flag |= P_SYSTEM;
303 #elif defined(AFS_XBSD_ENV)
304 curproc->p_flag |= P_SYSTEM;
305 #elif defined(AFS_SGI_ENV)
309 AFS_STATCNT(osi_Invisible);
313 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
314 /* set the real time */
316 afs_osi_SetTime(osi_timeval_t * atv)
318 #if defined(AFS_AIX32_ENV)
319 struct timestruc_t t;
321 t.tv_sec = atv->tv_sec;
322 t.tv_nsec = atv->tv_usec * 1000;
323 ksettimer(&t); /* Was -> settimer(TIMEOFDAY, &t); */
324 #elif defined(AFS_SUN55_ENV)
326 #elif defined(AFS_SUN5_ENV)
328 * To get more than second resolution we can use adjtime. The problem
329 * is that the usecs from the server are wrong (by now) so it isn't
330 * worth complicating the following code.
336 sta.time = atv->tv_sec;
339 #elif defined(AFS_SGI_ENV)
345 sta.time = atv->tv_sec;
348 #elif defined(AFS_DARWIN_ENV)
349 #ifndef AFS_DARWIN80_ENV
355 /* stolen from kern_time.c */
357 boottime.tv_sec += atv->tv_sec - time.tv_sec;
361 #if !defined(AFS_HPUX1122_ENV)
362 /* drop the setting of the clock for now. spl7 is not
367 t.tv_sec = atv->tv_sec;
368 t.tv_usec = atv->tv_usec;
385 logtchg(atv->tv_sec);
387 #endif /* AFS_DARWIN_ENV */
388 AFS_STATCNT(osi_SetTime);
390 #endif /* AFS_LINUX20_ENV */
394 afs_osi_Alloc(size_t x)
396 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
397 register struct osimem *tm = NULL;
401 AFS_STATCNT(osi_Alloc);
402 /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
403 * things so that NULL returned iff an error occurred */
407 AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
408 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
409 #ifdef AFS_LINUX20_ENV
410 return osi_linux_alloc(x, 1);
411 #elif defined(AFS_FBSD_ENV)
412 return osi_fbsd_alloc(x, 1);
415 tm = (struct osimem *)AFS_KALLOC(size);
418 osi_Panic("osi_Alloc: Couldn't allocate %d bytes; out of memory!\n",
425 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
428 afs_osi_Alloc_NoSleep(size_t x)
430 register struct osimem *tm;
433 AFS_STATCNT(osi_Alloc);
434 /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
435 * things so that NULL returned iff an error occurred */
440 AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
441 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
442 tm = (struct osimem *)AFS_KALLOC_NOSLEEP(size);
446 #endif /* SUN || SGI */
449 afs_osi_Free(void *x, size_t asize)
451 AFS_STATCNT(osi_Free);
453 return; /* check for putting memZero back */
455 AFS_STATS(afs_stats_cmperf.OutStandingAllocs--);
456 AFS_STATS(afs_stats_cmperf.OutStandingMemUsage -= asize);
457 #if defined(AFS_LINUX20_ENV)
459 #elif defined(AFS_FBSD_ENV)
462 AFS_KFREE((struct osimem *)x, asize);
467 afs_osi_FreeStr(char *x)
469 afs_osi_Free(x, strlen(x) + 1);
472 /* ? is it moderately likely that there are dirty VM pages associated with
475 * Prereqs: avc must be write-locked
477 * System Dependencies: - *must* support each type of system for which
478 * memory mapped files are supported, even if all
479 * it does is return TRUE;
481 * NB: this routine should err on the side of caution for ProcessFS to work
482 * correctly (or at least, not to introduce worse bugs than already exist)
486 osi_VMDirty_p(struct vcache *avc)
490 if (avc->execsOrWriters <= 0)
491 return 0; /* can't be many dirty pages here, I guess */
493 #if defined (AFS_AIX32_ENV)
495 /* because of the level of hardware involvment with VM and all the
496 * warnings about "This routine must be called at VMM interrupt
497 * level", I thought it would be safest to disable interrupts while
498 * looking at the software page fault table. */
500 /* convert vm handle into index into array: I think that stoinio is
501 * always zero... Look into this XXX */
502 #define VMHASH(handle) ( \
503 ( ((handle) & ~vmker.stoinio) \
504 ^ ((((handle) & ~vmker.stoinio) & vmker.stoimask) << vmker.stoihash) \
508 unsigned int pagef, pri, index, next;
510 index = VMHASH(avc->segid);
511 if (scb_valid(index)) { /* could almost be an ASSERT */
513 pri = disable_ints();
514 for (pagef = scb_sidlist(index); pagef >= 0; pagef = next) {
515 next = pft_sidfwd(pagef);
516 if (pft_modbit(pagef)) { /* has page frame been modified? */
526 #endif /* AFS_AIX32_ENV */
528 #if defined (AFS_SUN5_ENV)
529 if (avc->states & CMAPPED) {
531 for (pg = avc->v.v_s.v_Pages; pg; pg = pg->p_vpnext) {
544 * Solaris osi_ReleaseVM should not drop and re-obtain the vcache entry lock.
545 * This leads to bad races when osi_ReleaseVM() is called from
546 * afs_InvalidateAllSegments().
548 * We can do this because Solaris osi_VM_Truncate() doesn't care whether the
549 * vcache entry lock is held or not.
551 * For other platforms, in some cases osi_VM_Truncate() doesn't care, but
552 * there may be cases where it does care. If so, it would be good to fix
553 * them so they don't care. Until then, we assume the worst.
555 * Locking: the vcache entry lock is held. It is dropped and re-obtained.
558 osi_ReleaseVM(struct vcache *avc, struct AFS_UCRED *acred)
562 osi_VM_Truncate(avc, 0, acred);
565 ReleaseWriteLock(&avc->lock);
567 osi_VM_Truncate(avc, 0, acred);
569 ObtainWriteLock(&avc->lock, 80);
577 AFS_STATCNT(shutdown_osi);
578 #ifdef AFS_DARWIN80_ENV
579 if (afs_osi_ctxtp_initialized && afs_osi_ctxtp) {
580 vfs_context_rele(afs_osi_ctxtp);
581 afs_osi_ctxtp = NULL;
582 afs_osi_ctxtp_initialized = 0;
585 if (afs_cold_shutdown) {
586 LOCK_INIT(&afs_ftf, "afs_ftf");
592 afs_osi_suser(void *credp)
594 #if defined(AFS_SUN5_ENV)
595 return afs_suser(credp);
597 return afs_suser(NULL);
604 /* afs_osi_TraverseProcTable() - Walk through the systems process
605 * table, calling afs_GCPAGs_perproc_func() for each process.
608 #if defined(AFS_SUN5_ENV)
610 afs_osi_TraverseProcTable(void)
613 for (prp = practive; prp != NULL; prp = prp->p_next) {
614 afs_GCPAGs_perproc_func(prp);
619 #if defined(AFS_HPUX_ENV)
622 * NOTE: h/proc_private.h gives the process table locking rules
623 * It indicates that access to p_cred must be protected by
625 * mp_mtproc_unlock(p);
627 * The code in sys/pm_prot.c uses pcred_lock() to protect access to
628 * the process creds, and uses mp_mtproc_lock() only for audit-related
629 * changes. To be safe, we use both.
633 afs_osi_TraverseProcTable(void)
638 MP_SPINLOCK(activeproc_lock);
639 MP_SPINLOCK(sched_lock);
643 * Instead of iterating through all of proc[], traverse only
644 * the list of active processes. As an example of this,
645 * see foreach_process() in sys/vm_sched.c.
647 * We hold the locks for the entire scan in order to get a
648 * consistent view of the current set of creds.
651 for (p = proc; endchain == 0; p = &proc[p->p_fandx]) {
652 if (p->p_fandx == 0) {
660 afs_GCPAGs_perproc_func(p);
665 MP_SPINUNLOCK(sched_lock);
666 MP_SPINUNLOCK(activeproc_lock);
670 #if defined(AFS_SGI_ENV)
673 /* TODO: Fix this later. */
675 SGI_ProcScanFunc(void *p, void *arg, int mode)
679 #else /* AFS_SGI65_ENV */
681 SGI_ProcScanFunc(proc_t * p, void *arg, int mode)
683 afs_int32(*perproc_func) (struct proc *) = arg;
685 /* we pass in the function pointer for arg,
686 * mode ==0 for startup call, ==1 for each valid proc,
687 * and ==2 for terminate call.
690 code = perproc_func(p);
694 #endif /* AFS_SGI65_ENV */
697 afs_osi_TraverseProcTable(void)
699 procscan(SGI_ProcScanFunc, afs_GCPAGs_perproc_func);
701 #endif /* AFS_SGI_ENV */
703 #if defined(AFS_AIX_ENV)
705 #define max_proc v.ve_proc
708 afs_osi_TraverseProcTable(void)
714 * For binary compatibility, on AIX we need to be careful to use the
715 * proper size of a struct proc, even if it is different from what
716 * we were compiled with.
718 if (!afs_gcpags_procsize)
721 #ifndef AFS_AIX51_ENV
722 simple_lock(&proc_tbl_lock);
724 for (p = (struct proc *)v.vb_proc, i = 0; p < max_proc;
725 p = (struct proc *)((char *)p + afs_gcpags_procsize), i++) {
728 if (p->p_pvprocp->pv_stat == SNONE)
730 if (p->p_pvprocp->pv_stat == SIDL)
732 if (p->p_pvprocp->pv_stat == SEXIT)
735 if (p->p_stat == SNONE)
737 if (p->p_stat == SIDL)
739 if (p->p_stat == SEXIT)
745 if (PROCMASK(p->p_pid) != i) {
746 afs_gcpags = AFS_GCPAGS_EPIDCHECK;
752 if ((p->p_nice < P_NICE_MIN) || (P_NICE_MAX < p->p_nice)) {
753 afs_gcpags = AFS_GCPAGS_ENICECHECK;
757 afs_GCPAGs_perproc_func(p);
759 #ifndef AFS_AIX51_ENV
760 simple_unlock(&proc_tbl_lock);
765 #if defined(AFS_OSF_ENV)
768 extern struct pid_entry *pidtab;
773 afs_osi_TraverseProcTable(void)
775 struct pid_entry *pe;
777 #define pidNPID (pidtab + npid)
782 for (pe = pidtab; pe < pidNPID; ++pe) {
783 if (pe->pe_proc != PROC_NULL)
784 afs_GCPAGs_perproc_func(pe->pe_proc);
790 #if (defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN80_ENV)) || defined(AFS_FBSD_ENV)
792 afs_osi_TraverseProcTable(void)
795 LIST_FOREACH(p, &allproc, p_list) {
796 if (p->p_stat == SIDL)
798 if (p->p_stat == SZOMB)
800 if (p->p_flag & P_SYSTEM)
802 afs_GCPAGs_perproc_func(p);
807 #if defined(AFS_LINUX22_ENV)
808 extern rwlock_t tasklist_lock __attribute__((weak));
810 afs_osi_TraverseProcTable()
812 struct task_struct *p;
814 read_lock(&tasklist_lock);
815 #ifdef DEFINED_FOR_EACH_PROCESS
816 for_each_process(p) if (p->pid) {
817 #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
821 if (p->state & TASK_ZOMBIE)
824 afs_GCPAGs_perproc_func(p);
827 for_each_task(p) if (p->pid) {
828 #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
832 if (p->state & TASK_ZOMBIE)
835 afs_GCPAGs_perproc_func(p);
839 read_unlock(&tasklist_lock);
843 /* return a pointer (sometimes a static copy ) to the cred for a
845 * subsequent calls may overwrite the previously returned value.
848 #if defined(AFS_SGI65_ENV)
849 const struct AFS_UCRED *
850 afs_osi_proc2cred(AFS_PROC * p)
854 #elif defined(AFS_HPUX_ENV)
855 const struct AFS_UCRED *
856 afs_osi_proc2cred(AFS_PROC * p)
862 * Cannot use afs_warnuser() here, as the code path
863 * eventually wants to grab sched_lock, which is
869 #elif defined(AFS_AIX_ENV)
871 /* GLOBAL DECLARATIONS */
874 * LOCKS: the caller must do
875 * simple_lock(&proc_tbl_lock);
876 * simple_unlock(&proc_tbl_lock);
877 * around calls to this function.
880 const struct AFS_UCRED *
881 afs_osi_proc2cred(AFS_PROC * pproc)
883 struct AFS_UCRED *pcred = 0;
886 * pointer to process user structure valid in *our*
889 * The user structure for a process is stored in the user
890 * address space (as distinct from the kernel address
891 * space), and so to refer to the user structure of a
892 * different process we must employ special measures.
894 * I followed the example used in the AIX getproc() system
895 * call in bos/kernel/proc/getproc.c
897 struct user *xmem_userp;
899 struct xmem dp; /* ptr to xmem descriptor */
900 int xm; /* xmem result */
907 * The process private segment in which the user
908 * area is located may disappear. We need to increment
909 * its use count. Therefore we
910 * - get the proc_tbl_lock to hold the segment.
911 * - get the p_lock to lockout vm_cleardata.
912 * - vm_att to load the segment register (no check)
913 * - xmattach to bump its use count.
914 * - release the p_lock.
915 * - release the proc_tbl_lock.
916 * - do whatever we need.
917 * - xmdetach to decrement the use count.
918 * - vm_det to free the segment register (no check)
923 /* simple_lock(&proc_tbl_lock); */
925 if (pproc->p_adspace != vm_handle(NULLSEGID, (int32long64_t) 0)) {
927 if (pproc->p_adspace != NULLSEGVAL) {
931 simple_lock(&pproc->p_pvprocp->pv_lock);
933 simple_lock(&pproc->p_lock);
936 if (pproc->p_threadcount &&
938 pproc->p_pvprocp->pv_threadlist) {
940 pproc->p_threadlist) {
944 * arbitrarily pick the first thread in pproc
946 struct thread *pproc_thread =
948 pproc->p_pvprocp->pv_threadlist;
954 * location of 'struct user' in pproc's
957 struct user *pproc_userp = pproc_thread->t_userp;
960 * create a pointer valid in my own address space
963 xmem_userp = (struct user *)vm_att(pproc->p_adspace, pproc_userp);
965 dp.aspace_id = XMEM_INVAL;
966 xm = xmattach(xmem_userp, sizeof(*xmem_userp), &dp, SYS_ADSPACE);
970 simple_unlock(&pproc->p_pvprocp->pv_lock);
972 simple_unlock(&pproc->p_lock);
975 /* simple_unlock(&proc_tbl_lock); */
976 if (xm == XMEM_SUCC) {
978 static struct AFS_UCRED cred;
981 * What locking should we use to protect access to the user
982 * area? If needed also change the code in AIX/osi_groups.c.
985 /* copy cred to local address space */
986 cred = *xmem_userp->U_cred;
992 vm_det((void *)xmem_userp);
998 #elif defined(AFS_OSF_ENV)
999 const struct AFS_UCRED *
1000 afs_osi_proc2cred(AFS_PROC * pr)
1002 struct AFS_UCRED *rv = NULL;
1008 if ((pr->p_stat == SSLEEP) || (pr->p_stat == SRUN)
1009 || (pr->p_stat == SSTOP))
1014 #elif defined(AFS_DARWIN80_ENV)
1015 const struct AFS_UCRED *
1016 afs_osi_proc2cred(AFS_PROC * pr)
1018 struct AFS_UCRED *rv = NULL;
1019 static struct AFS_UCRED cr;
1020 struct ucred *pcred;
1025 pcred = proc_ucred(pr);
1027 cr.cr_uid = pcred->cr_uid;
1028 cr.cr_ngroups = pcred->cr_ngroups;
1029 memcpy(cr.cr_groups, pcred->cr_groups,
1030 NGROUPS * sizeof(gid_t));
1033 #elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
1034 const struct AFS_UCRED *
1035 afs_osi_proc2cred(AFS_PROC * pr)
1037 struct AFS_UCRED *rv = NULL;
1038 static struct AFS_UCRED cr;
1044 if ((pr->p_stat == SSLEEP) || (pr->p_stat == SRUN)
1045 || (pr->p_stat == SSTOP)) {
1048 cr.cr_uid = pr->p_cred->pc_ucred->cr_uid;
1049 cr.cr_ngroups = pr->p_cred->pc_ucred->cr_ngroups;
1050 memcpy(cr.cr_groups, pr->p_cred->pc_ucred->cr_groups,
1051 NGROUPS * sizeof(gid_t));
1058 #elif defined(AFS_LINUX22_ENV)
1059 const struct AFS_UCRED *
1060 afs_osi_proc2cred(AFS_PROC * pr)
1062 struct AFS_UCRED *rv = NULL;
1063 static struct AFS_UCRED cr;
1069 if ((pr->state == TASK_RUNNING) || (pr->state == TASK_INTERRUPTIBLE)
1070 || (pr->state == TASK_UNINTERRUPTIBLE)
1071 || (pr->state == TASK_STOPPED)) {
1073 cr.cr_uid = pr->uid;
1074 #if defined(AFS_LINUX26_ENV)
1075 get_group_info(pr->group_info);
1076 cr.cr_group_info = pr->group_info;
1078 cr.cr_ngroups = pr->ngroups;
1079 memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));
1087 const struct AFS_UCRED *
1088 afs_osi_proc2cred(AFS_PROC * pr)
1090 struct AFS_UCRED *rv = NULL;
1101 #endif /* AFS_GCPAGS */