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(char *aname, enum uio_seg seg, int followlink,
27 char tname[PATHBUFLEN];
31 if (seg == AFS_UIOUSER) { /* XXX 64bit */
32 AFS_COPYINSTR(aname, tname, sizeof(tname), &len, code);
39 flags |= VNODE_LOOKUP_NOFOLLOW;
40 ctx=vfs_context_create(NULL);
41 code = vnode_lookup(aname, flags, vpp, ctx);
42 if (!code) { /* get a usecount */
46 vfs_context_rele(ctx);
51 osi_lookupname(char *aname, enum uio_seg seg, int followlink,
62 NDINIT(&n, LOOKUP, flags, seg, aname, current_proc());
63 if (error = namei(&n))
66 /* should we do this? */
67 VOP_UNLOCK(n.ni_vp, 0, current_proc());
73 * afs_suser() returns true if the caller is superuser, false otherwise.
75 * Note that it must NOT set errno.
78 afs_suser(void *credp)
81 struct proc *p = current_proc();
83 #ifdef AFS_DARWIN80_ENV
84 if ((error = proc_suser(p)) == 0) {
89 if ((error = suser(p->p_ucred, &p->p_acflag)) == 0) {
96 #ifdef AFS_DARWIN80_ENV
97 uio_t afsio_darwin_partialcopy(uio_t auio, int size) {
103 if (proc_is64bit(current_proc())) {
104 res = uio_create(uio_iovcnt(auio), uio_offset(auio),
105 uio_isuserspace(auio) ? UIO_USERSPACE64 : UIO_SYSSPACE32,
108 res = uio_create(uio_iovcnt(auio), uio_offset(auio),
109 uio_isuserspace(auio) ? UIO_USERSPACE32 : UIO_SYSSPACE32,
113 for (i = 0;i < uio_iovcnt(auio) && size > 0;i++) {
114 if (uio_getiov(auio, i, &iovaddr, &iovsize))
118 if (uio_addiov(res, iovaddr, iovsize))
125 vfs_context_t afs_osi_ctxtp;
126 int afs_osi_ctxtp_initialized;
127 static thread_t vfs_context_owner;
128 static proc_t vfs_context_curproc;
130 void get_vfs_context(void) {
131 int isglock = ISAFS_GLOCK();
135 if (afs_osi_ctxtp_initialized) {
140 osi_Assert(vfs_context_owner != current_thread());
141 if (afs_osi_ctxtp && current_proc() == vfs_context_curproc) {
143 vfs_context_owner = current_thread();
148 while (afs_osi_ctxtp && vfs_context_ref) {
149 afs_osi_Sleep(&afs_osi_ctxtp);
150 if (afs_osi_ctxtp_initialized) {
156 vfs_context_rele(afs_osi_ctxtp);
158 afs_osi_ctxtp = vfs_context_create(NULL);
159 vfs_context_owner = current_thread();
160 vfs_context_curproc = current_proc();
165 void put_vfs_context(void) {
166 int isglock = ISAFS_GLOCK();
170 if (afs_osi_ctxtp_initialized) {
175 if (vfs_context_owner == current_thread())
176 vfs_context_owner = (thread_t)0;
178 afs_osi_Wakeup(&afs_osi_ctxtp);
183 extern int afs3_syscall();
185 int afs_cdev_nop_openclose(dev_t dev, int flags, int devtype,struct proc *p) {
188 extern int afs3_syscall(struct proc *p, void *data, unsigned long *retval);
191 afs_cdev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) {
192 unsigned long retval=0;
194 struct afssysargs *a = (struct afssysargs *)data;
198 if (cmd != VIOC_SYSCALL) {
202 code=afs3_syscall(p, data, &retval);
205 if (retval && a->syscall != AFSCALL_CALL && a->param1 != AFSOP_CACHEINODE) { printf("SSCall(%d,%d) is returning non-error value %d\n", a->syscall, a->param1, retval); }