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"
14 #include "afs/sysincludes.h"
15 #include "afsincludes.h"
16 #include <sys/namei.h>
19 #define PATHBUFLEN 256
22 #ifdef AFS_DARWIN80_ENV
24 osi_lookupname_user(user_addr_t aname, enum uio_seg seg, int followlink,
26 char tname[PATHBUFLEN];
30 if (seg == AFS_UIOUSER) { /* XXX 64bit */
31 AFS_COPYINSTR(aname, tname, sizeof(tname), &len, code);
34 return osi_lookupname(tname, seg, followlink, vpp);
36 return osi_lookupname(CAST_DOWN(char *, aname), seg, followlink, vpp);
41 osi_lookupname(char *aname, enum uio_seg seg, int followlink,
48 flags |= VNODE_LOOKUP_NOFOLLOW;
49 ctx=vfs_context_create(NULL);
50 code = vnode_lookup(aname, flags, vpp, ctx);
51 if (!code) { /* get a usecount */
55 vfs_context_rele(ctx);
60 osi_lookupname(char *aname, enum uio_seg seg, int followlink,
71 NDINIT(&n, LOOKUP, flags, seg, aname, current_proc());
72 if (error = namei(&n))
75 /* should we do this? */
76 VOP_UNLOCK(n.ni_vp, 0, current_proc());
82 * afs_suser() returns true if the caller is superuser, false otherwise.
84 * Note that it must NOT set errno.
87 afs_suser(void *credp)
90 struct proc *p = current_proc();
92 #ifdef AFS_DARWIN80_ENV
93 if ((error = proc_suser(p)) == 0) {
98 if ((error = suser(p->p_ucred, &p->p_acflag)) == 0) {
105 #ifdef AFS_DARWIN80_ENV
107 afsio_darwin_partialcopy(uio_t auio, int size)
114 if (proc_is64bit(current_proc())) {
115 res = uio_create(uio_iovcnt(auio), uio_offset(auio),
116 uio_isuserspace(auio) ? UIO_USERSPACE64 : UIO_SYSSPACE32,
119 res = uio_create(uio_iovcnt(auio), uio_offset(auio),
120 uio_isuserspace(auio) ? UIO_USERSPACE32 : UIO_SYSSPACE32,
124 for (i = 0;i < uio_iovcnt(auio) && size > 0;i++) {
125 if (uio_getiov(auio, i, &iovaddr, &iovsize))
129 if (uio_addiov(res, iovaddr, iovsize))
136 vfs_context_t afs_osi_ctxtp;
137 int afs_osi_ctxtp_initialized;
138 static thread_t vfs_context_owner;
139 static proc_t vfs_context_curproc;
143 get_vfs_context(void)
145 int isglock = ISAFS_GLOCK();
149 if (afs_osi_ctxtp_initialized) {
154 osi_Assert(vfs_context_owner != current_thread());
155 if (afs_osi_ctxtp && current_proc() == vfs_context_curproc) {
157 vfs_context_owner = current_thread();
162 while (afs_osi_ctxtp && vfs_context_ref) {
163 afs_osi_Sleep(&afs_osi_ctxtp);
164 if (afs_osi_ctxtp_initialized) {
170 vfs_context_rele(afs_osi_ctxtp);
172 afs_osi_ctxtp = vfs_context_create(NULL);
173 vfs_context_owner = current_thread();
174 vfs_context_curproc = current_proc();
180 put_vfs_context(void)
182 int isglock = ISAFS_GLOCK();
186 if (afs_osi_ctxtp_initialized) {
191 if (vfs_context_owner == current_thread())
192 vfs_context_owner = (thread_t)0;
194 afs_osi_Wakeup(&afs_osi_ctxtp);
200 afs_cdev_nop_openclose(dev_t dev, int flags, int devtype,struct proc *p)
205 extern int afs3_syscall(struct proc *p, void *data, unsigned int *retval);
208 afs_cdev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) {
209 unsigned int retval=0;
210 int code, is64 = proc_is64bit(p);
211 struct afssysargs *a = (struct afssysargs *)data;
212 struct afssysargs64 *a64 = (struct afssysargs64 *)data;
214 if (((unsigned int)cmd != VIOC_SYSCALL) &&
215 ((unsigned int)cmd != VIOC_SYSCALL64))
218 if (((unsigned int)cmd == VIOC_SYSCALL64) && (is64 == 0))
221 if (((unsigned int)cmd == VIOC_SYSCALL) && (is64 != 0))
224 code=afs3_syscall(p, data, &retval);
228 if ((!is64) && retval && a->syscall != AFSCALL_CALL
229 && a->param1 != AFSOP_CACHEINODE)
231 printf("SSCall(%d,%d) is returning non-error value %d\n", a->syscall, a->param1, retval);
233 if ((is64) && retval && a64->syscall != AFSCALL_CALL
234 && a64->param1 != AFSOP_CACHEINODE)
236 printf("SSCall(%d,%llx) is returning non-error value %d\n", a64->syscall, a64->param1, retval);
242 a64->retval = retval;