no-copy-libafs-builds-20021015
[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 <afsconfig.h>
11 #include "afs/param.h"
12
13 RCSID("$Header$");
14
15 #include "afs/sysincludes.h"
16 #include "afsincludes.h"
17 #include <sys/namei.h>
18
19 int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
20                           struct vnode **dirvpp, struct vnode **vpp)
21 {
22    struct nameidata n;
23    int flags,error;
24    flags=0;
25    flags=LOCKLEAF;
26    if (followlink)
27      flags|=FOLLOW;
28    else 
29      flags|=NOFOLLOW;
30 /*   if (dirvpp) flags|=WANTPARENT;*/ /* XXX LOCKPARENT? */
31    NDINIT(&n, LOOKUP, flags, seg, aname, current_proc());
32    if (error=namei(&n))
33       return error;
34    *vpp=n.ni_vp;
35 /*
36    if (dirvpp)
37       *dirvpp = n.ni_dvp;
38 #/
39    /* should we do this? */
40    VOP_UNLOCK(n.ni_vp, 0, current_proc());
41    return 0;
42 }
43
44 /*
45  * afs_suser() returns true if the caller is superuser, false otherwise.
46  *
47  * Note that it must NOT set errno.
48  */
49
50 afs_suser() {
51     int error;
52     struct proc *p=current_proc();
53
54     if ((error = suser(p->p_ucred, &p->p_acflag)) == 0) {
55         return(1);
56     }
57     return(0);
58 }