2 * Copyright 2000, International Business Machines Corporation and others.
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
11 * Linux support routines.
14 #include <afsconfig.h>
15 #include "afs/param.h"
20 #include <linux/module.h> /* early to avoid printf->printk mapping */
21 #include "afs/sysincludes.h"
22 #include "afsincludes.h"
23 #include "afs/afs_stats.h"
24 #if defined(AFS_LINUX24_ENV)
25 #include "h/smp_lock.h"
27 #if defined(AFS_LINUX26_ENV)
29 #include "h/kthread.h"
32 int afs_osicred_initialized = 0;
33 struct AFS_UCRED afs_osi_cred;
36 afs_osi_SetTime(osi_timeval_t * tvp)
38 #if defined(AFS_LINUX24_ENV)
40 #if defined(AFS_LINUX26_ENV)
42 tv.tv_sec = tvp->tv_sec;
43 tv.tv_nsec = tvp->tv_usec * NSEC_PER_USEC;
46 tv.tv_sec = tvp->tv_sec;
47 tv.tv_usec = tvp->tv_usec;
50 AFS_STATCNT(osi_SetTime);
54 extern int (*sys_settimeofdayp) (struct timeval * tv,
55 struct timezone * tz);
59 AFS_STATCNT(osi_SetTime);
62 if (sys_settimeofdayp)
63 (void)(*sys_settimeofdayp) (tvp, NULL);
68 struct task_struct *rxk_ListenerTask;
74 sigfillset(¤t->blocked);
75 RECALC_SIGPENDING(current);
80 osi_linux_rxkreg(void)
82 rxk_ListenerTask = current;
86 #if defined(AFS_LINUX24_ENV)
87 /* LOOKUP_POSITIVE is becoming the default */
88 #ifndef LOOKUP_POSITIVE
89 #define LOOKUP_POSITIVE 0
91 /* Lookup name and return vnode for same. */
93 osi_lookupname_internal(char *aname, int followlink, struct vfsmount **mnt,
98 int flags = LOOKUP_POSITIVE;
102 flags |= LOOKUP_FOLLOW;
103 #if defined(AFS_LINUX26_ENV)
104 code = path_lookup(aname, flags, &nd);
106 if (path_init(aname, flags, &nd))
107 code = path_walk(aname, &nd);
111 *dpp = dget(nd.dentry);
113 *mnt = mntget(nd.mnt);
119 osi_lookupname(char *aname, uio_seg_t seg, int followlink,
125 if (seg == AFS_UIOUSER) {
126 tname = getname(aname);
128 return PTR_ERR(tname);
132 code = osi_lookupname_internal(tname, followlink, NULL, dpp);
133 if (seg == AFS_UIOUSER) {
140 osi_lookupname(char *aname, uio_seg_t seg, int followlink, struct dentry **dpp)
142 struct dentry *dp = NULL;
146 if (seg == AFS_UIOUSER) {
147 dp = followlink ? namei(aname) : lnamei(aname);
149 dp = lookup_dentry(aname, NULL, followlink ? 1 : 0);
152 if (dp && !IS_ERR(dp)) {
165 #ifdef AFS_LINUX26_ENV
166 /* This is right even for Linux 2.4, but on that version d_path is inline
167 * and implemented in terms of __d_path, which is not exported.
169 int osi_abspath(char *aname, char *buf, int buflen,
170 int followlink, char **pathp)
172 struct dentry *dp = NULL;
173 struct vfsmnt *mnt = NULL;
178 tname = getname(aname);
180 return -PTR_ERR(tname);
181 code = osi_lookupname_internal(tname, followlink, &mnt, &dp);
183 path = d_path(dp, mnt, buf, buflen);
186 code = -PTR_ERR(path);
200 /* This could use some work, and support on more platforms. */
201 int afs_thread_wrapper(void *rock)
203 void (*proc)(void) = rock;
204 __module_get(THIS_MODULE);
208 module_put(THIS_MODULE);
212 void afs_start_thread(void (*proc)(void), char *name)
214 kthread_run(afs_thread_wrapper, proc, "%s", name);