Linux: remove unused cr->next member in struct afs_cred
[openafs.git] / src / afs / LINUX24 / 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  * Linux support routines.
12  *
13  */
14 #include <afsconfig.h>
15 #include "afs/param.h"
16
17
18 #include <linux/module.h> /* early to avoid printf->printk mapping */
19 #include "afs/sysincludes.h"
20 #include "afsincludes.h"
21 #include "afs/afs_stats.h"
22 #if defined(AFS_LINUX24_ENV)
23 #include "h/smp_lock.h"
24 #endif
25
26 int afs_osicred_initialized = 0;
27 afs_ucred_t afs_osi_cred;
28
29 void
30 afs_osi_SetTime(osi_timeval_t * tvp)
31 {
32 #if defined(AFS_LINUX24_ENV)
33     struct timeval tv;
34     tv.tv_sec = tvp->tv_sec;
35     tv.tv_usec = tvp->tv_usec;
36
37     AFS_STATCNT(osi_SetTime);
38
39     do_settimeofday(&tv);
40 #else
41     extern int (*sys_settimeofdayp) (struct timeval * tv,
42                                      struct timezone * tz);
43
44     KERNEL_SPACE_DECL;
45
46     AFS_STATCNT(osi_SetTime);
47
48     TO_USER_SPACE();
49     if (sys_settimeofdayp)
50         (void)(*sys_settimeofdayp) (tvp, NULL);
51     TO_KERNEL_SPACE();
52 #endif
53 }
54
55 void
56 osi_linux_mask(void)
57 {
58     SIG_LOCK(current);
59     sigfillset(&current->blocked);
60     RECALC_SIGPENDING(current);
61     SIG_UNLOCK(current);
62 }
63
64 #if defined(AFS_LINUX24_ENV)
65 /* LOOKUP_POSITIVE is becoming the default */
66 #ifndef LOOKUP_POSITIVE
67 #define LOOKUP_POSITIVE 0
68 #endif
69 /* Lookup name and return vnode for same. */
70 int
71 osi_lookupname_internal(char *aname, int followlink, struct vfsmount **mnt,
72                         struct dentry **dpp)
73 {
74     int code;
75     struct nameidata nd;
76     int flags = LOOKUP_POSITIVE;
77     code = ENOENT;
78
79     if (followlink)
80        flags |= LOOKUP_FOLLOW;
81     if (path_init(aname, flags, &nd))
82         code = path_walk(aname, &nd);
83
84     if (!code) {
85 #if defined(STRUCT_NAMEIDATA_HAS_PATH)
86         *dpp = dget(nd.path.dentry);
87         if (mnt)
88             *mnt = mntget(nd.path.mnt);
89         path_put(&nd.path);
90 #else
91         *dpp = dget(nd.dentry);
92         if (mnt)
93            *mnt = mntget(nd.mnt);
94         path_release(&nd);
95 #endif
96     }
97     return code;
98 }
99
100 int
101 osi_lookupname(char *aname, uio_seg_t seg, int followlink, 
102                struct dentry **dpp)
103 {
104     int code;
105     char *tname;
106     code = ENOENT;
107     if (seg == AFS_UIOUSER) {
108         tname = getname(aname);
109         if (IS_ERR(tname)) 
110             return PTR_ERR(tname);
111     } else {
112         tname = aname;
113     }
114     code = osi_lookupname_internal(tname, followlink, NULL, dpp);   
115     if (seg == AFS_UIOUSER) {
116         putname(tname);
117     }
118     return code;
119 }
120 #else
121 int
122 osi_lookupname(char *aname, uio_seg_t seg, int followlink, struct dentry **dpp)
123 {
124     struct dentry *dp = NULL;
125     int code;
126
127     code = ENOENT;
128     if (seg == AFS_UIOUSER) {
129         dp = followlink ? namei(aname) : lnamei(aname);
130     } else {
131         dp = lookup_dentry(aname, NULL, followlink ? 1 : 0);
132     }
133
134     if (dp && !IS_ERR(dp)) {
135         if (dp->d_inode) {
136             *dpp = dp;
137             code = 0;
138         } else
139             dput(dp);
140     }
141
142     return code;
143 }
144 #endif