unroll-macos-104-20050523
[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 **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     NDINIT(&n, LOOKUP, flags, seg, aname, current_proc());
33     if (error = namei(&n))
34         return error;
35     *vpp = n.ni_vp;
36    /* should we do this? */
37     VOP_UNLOCK(n.ni_vp, 0, current_proc());
38     return 0;
39 }
40
41 /*
42  * afs_suser() returns true if the caller is superuser, false otherwise.
43  *
44  * Note that it must NOT set errno.
45  */
46
47 afs_suser(void *credp)
48 {
49     int error;
50     struct proc *p = current_proc();
51
52     if ((error = suser(p->p_ucred, &p->p_acflag)) == 0) {
53         return (1);
54     }
55     return (0);
56 }