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"
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"
25 #if defined(AFS_LINUX26_ENV)
27 #include "h/kthread.h"
30 int afs_osicred_initialized = 0;
31 struct AFS_UCRED afs_osi_cred;
34 afs_osi_SetTime(osi_timeval_t * tvp)
36 #if defined(AFS_LINUX24_ENV)
38 #if defined(AFS_LINUX26_ENV)
40 tv.tv_sec = tvp->tv_sec;
41 tv.tv_nsec = tvp->tv_usec * NSEC_PER_USEC;
44 tv.tv_sec = tvp->tv_sec;
45 tv.tv_usec = tvp->tv_usec;
48 AFS_STATCNT(osi_SetTime);
52 extern int (*sys_settimeofdayp) (struct timeval * tv,
53 struct timezone * tz);
57 AFS_STATCNT(osi_SetTime);
60 if (sys_settimeofdayp)
61 (void)(*sys_settimeofdayp) (tvp, NULL);
70 sigfillset(¤t->blocked);
71 RECALC_SIGPENDING(current);
75 #if defined(AFS_LINUX24_ENV)
76 /* LOOKUP_POSITIVE is becoming the default */
77 #ifndef LOOKUP_POSITIVE
78 #define LOOKUP_POSITIVE 0
80 /* Lookup name and return vnode for same. */
82 osi_lookupname_internal(char *aname, int followlink, struct vfsmount **mnt,
87 int flags = LOOKUP_POSITIVE;
91 flags |= LOOKUP_FOLLOW;
92 #if defined(AFS_LINUX26_ENV)
93 code = path_lookup(aname, flags, &nd);
95 if (path_init(aname, flags, &nd))
96 code = path_walk(aname, &nd);
100 #if defined(STRUCT_NAMEIDATA_HAS_PATH)
101 *dpp = dget(nd.path.dentry);
103 *mnt = mntget(nd.path.mnt);
106 *dpp = dget(nd.dentry);
108 *mnt = mntget(nd.mnt);
115 osi_lookupname(char *aname, uio_seg_t seg, int followlink,
121 if (seg == AFS_UIOUSER) {
122 tname = getname(aname);
124 return PTR_ERR(tname);
128 code = osi_lookupname_internal(tname, followlink, NULL, dpp);
129 if (seg == AFS_UIOUSER) {
136 osi_lookupname(char *aname, uio_seg_t seg, int followlink, struct dentry **dpp)
138 struct dentry *dp = NULL;
142 if (seg == AFS_UIOUSER) {
143 dp = followlink ? namei(aname) : lnamei(aname);
145 dp = lookup_dentry(aname, NULL, followlink ? 1 : 0);
148 if (dp && !IS_ERR(dp)) {
161 #ifdef AFS_LINUX26_ENV
162 /* This is right even for Linux 2.4, but on that version d_path is inline
163 * and implemented in terms of __d_path, which is not exported.
165 int osi_abspath(char *aname, char *buf, int buflen,
166 int followlink, char **pathp)
168 struct dentry *dp = NULL;
169 struct vfsmount *mnt = NULL;
174 tname = getname(aname);
176 return -PTR_ERR(tname);
177 code = osi_lookupname_internal(tname, followlink, &mnt, &dp);
179 #if defined(D_PATH_TAKES_STRUCT_PATH)
180 struct path p = { mnt, dp };
181 path = d_path(&p, buf, buflen);
183 path = d_path(dp, mnt, buf, buflen);
187 code = -PTR_ERR(path);
201 /* This could use some work, and support on more platforms. */
202 int afs_thread_wrapper(void *rock)
204 void (*proc)(void) = rock;
205 __module_get(THIS_MODULE);
209 module_put(THIS_MODULE);
213 void afs_start_thread(void (*proc)(void), char *name)
215 kthread_run(afs_thread_wrapper, proc, "%s", name);