65daf7a73267a767fed8525ff576a79f7f26e0c4
[openafs.git] / src / afs / DARWIN / osi_misc.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 #include "../afs/param.h"
11 #include "../afs/sysincludes.h"
12 #include "../afs/afsincludes.h"
13 #include <sys/namei.h>
14
15 int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
16                           struct vnode **dirvpp, struct vnode **vpp)
17 {
18    struct nameidata n;
19    int flags,error;
20    flags=0;
21    flags=LOCKLEAF;
22    if (followlink)
23      flags|=FOLLOW;
24    else 
25      flags|=NOFOLLOW;
26 /*   if (dirvpp) flags|=WANTPARENT;*/ /* XXX LOCKPARENT? */
27    NDINIT(&n, LOOKUP, flags, seg, aname, current_proc());
28    if (error=namei(&n))
29       return error;
30    *vpp=n.ni_vp;
31 /*
32    if (dirvpp)
33       *dirvpp = n.ni_dvp;
34 #/
35    /* should we do this? */
36    VOP_UNLOCK(n.ni_vp, 0, current_proc());
37    return 0;
38 }
39
40 /*
41  * afs_suser() returns true if the caller is superuser, false otherwise.
42  *
43  * Note that it must NOT set errno.
44  */
45
46 afs_suser() {
47     int error;
48     struct proc *p=current_proc();
49
50     if ((error = suser(p->p_ucred, &p->p_acflag)) == 0) {
51         return(1);
52     }
53     return(0);
54 }