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