8e5a8ab6646729197d9f21d2fdc08e342db99cad
[openafs.git] / src / afs / FBSD / 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 /* 
11  * osi_misc.c
12  *
13  * Implements:
14  * afs_suser
15  */
16
17 #include <afsconfig.h>
18 #include "../afs/param.h"
19
20 RCSID("$Header$");
21
22 #include "../afs/sysincludes.h" /* Standard vendor system headers */
23 #include "../afs/afsincludes.h" /* Afs-based standard headers */
24 #include <sys/namei.h>
25 /*
26  * afs_suser() returns true if the caller is superuser, false otherwise.
27  *
28  * Note that it must NOT set errno.
29  */
30
31 afs_suser() {
32     int error;
33
34     if (suser(curproc) == 0) {
35         return(1);
36     }
37     return(0);
38 }
39
40 int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
41                           struct vnode **dirvpp, struct vnode **vpp)
42 {
43    struct nameidata n;
44    int flags,error;
45    flags=0;
46    flags=LOCKLEAF;
47    if (followlink)
48      flags|=FOLLOW;
49    else 
50      flags|=NOFOLLOW;
51 /*   if (dirvpp) flags|=WANTPARENT;*/ /* XXX LOCKPARENT? */
52    NDINIT(&n, LOOKUP, flags, seg, aname, curproc);
53    if (error=namei(&n))
54       return error;
55    *vpp=n.ni_vp;
56 /*
57    if (dirvpp)
58       *dirvpp = n.ni_dvp;
59 */
60    /* should we do this? */
61    VOP_UNLOCK(n.ni_vp, 0, curproc);
62    NDFREE(&n, NDF_ONLY_PNBUF);
63    return 0;
64 }