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 <linux/dcache.h>
20 #include <linux/namei.h>
21 #include <linux/kthread.h>
22 #include "afs/sysincludes.h"
23 #include "afsincludes.h"
24 #include "afs/afs_stats.h"
26 #include "osi_compat.h"
28 int afs_osicred_initialized = 0;
29 afs_ucred_t afs_osi_cred;
35 sigfillset(¤t->blocked);
36 RECALC_SIGPENDING(current);
41 osi_linux_unmaskrxk(void)
43 extern struct task_struct *rxk_ListenerTask;
44 /* Note this unblocks signals on the rxk_Listener
45 * thread from a thread that is stopping rxk */
46 SIG_LOCK(rxk_ListenerTask);
47 sigdelset(&rxk_ListenerTask->blocked, SIGKILL);
48 SIG_UNLOCK(rxk_ListenerTask);
51 /* LOOKUP_POSITIVE is becoming the default */
52 #ifndef LOOKUP_POSITIVE
53 #define LOOKUP_POSITIVE 0
55 /* Lookup name and return vnode for same. */
57 osi_lookupname_internal(char *aname, int followlink, struct vfsmount **mnt,
61 #if defined(HAVE_LINUX_PATH_LOOKUP)
62 struct nameidata path_data;
64 afs_linux_path_t path_data;
66 int flags = LOOKUP_POSITIVE;
69 flags |= LOOKUP_FOLLOW;
70 code = afs_kern_path(aname, flags, &path_data);
73 afs_get_dentry_ref(&path_data, mnt, dpp);
79 afs_getname(char *aname)
82 char *name = kmem_cache_alloc(names_cachep, GFP_KERNEL);
85 return ERR_PTR(-ENOMEM);
87 len = strncpy_from_user(name, aname, PATH_MAX);
90 if (len >= PATH_MAX) {
97 kmem_cache_free(names_cachep, name);
102 afs_putname(char *name)
104 kmem_cache_free(names_cachep, name);
108 osi_lookupname(char *aname, uio_seg_t seg, int followlink,
114 if (seg == AFS_UIOUSER) {
115 name = afs_getname(aname);
117 return -PTR_ERR(name);
121 code = osi_lookupname_internal(name, followlink, NULL, dpp);
122 if (seg == AFS_UIOUSER) {
128 int osi_abspath(char *aname, char *buf, int buflen,
129 int followlink, char **pathp)
131 struct dentry *dp = NULL;
132 struct vfsmount *mnt = NULL;
136 name = afs_getname(aname);
138 return -PTR_ERR(name);
139 code = osi_lookupname_internal(name, followlink, &mnt, &dp);
141 #if defined(D_PATH_TAKES_STRUCT_PATH)
142 afs_linux_path_t p = { .mnt = mnt, .dentry = dp };
143 path = d_path(&p, buf, buflen);
145 path = d_path(dp, mnt, buf, buflen);
149 code = -PTR_ERR(path);
163 /* This could use some work, and support on more platforms. */
164 int afs_thread_wrapper(void *rock)
166 void (*proc)(void) = rock;
167 __module_get(THIS_MODULE);
171 module_put(THIS_MODULE);
175 void afs_start_thread(void (*proc)(void), char *name)
177 kthread_run(afs_thread_wrapper, proc, "%s", name);