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 module 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 "h/unistd.h" /* For syscall numbers. */
26 #ifdef AFS_AMD64_LINUX20_ENV
27 #include <asm/ia32_unistd.h>
29 #ifdef AFS_SPARC64_LINUX20_ENV
30 #include <linux/ioctl32.h>
33 #include <linux/proc_fs.h>
34 #include <linux/slab.h>
35 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
36 #include <linux/init.h>
37 #include <linux/sched.h>
38 #include <linux/kernel.h>
41 extern struct file_system_type afs_fs_type;
43 #if !defined(AFS_LINUX24_ENV)
44 static long get_page_offset(void);
47 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
48 DEFINE_MUTEX(afs_global_lock);
49 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
50 DECLARE_MUTEX(afs_global_lock);
52 struct semaphore afs_global_lock = MUTEX;
54 int afs_global_owner = 0;
55 #if !defined(AFS_LINUX24_ENV)
56 unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */
60 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
69 RWLOCK_INIT(&afs_xosi, "afs_xosi");
71 #if !defined(AFS_LINUX24_ENV)
72 /* obtain PAGE_OFFSET value */
73 afs_linux_page_offset = get_page_offset();
75 #ifndef AFS_S390_LINUX22_ENV
76 if (afs_linux_page_offset == 0) {
77 /* couldn't obtain page offset so can't continue */
78 printf("afs: Unable to obtain PAGE_OFFSET. Exiting..");
81 #endif /* AFS_S390_LINUX22_ENV */
82 #endif /* !defined(AFS_LINUX24_ENV) */
85 #ifdef AFS_LINUX26_ENV
86 #if !defined(AFS_NONFSTRANS)
87 osi_linux_nfssrv_init();
91 #ifndef LINUX_KEYRING_SUPPORT
92 err = osi_syscall_init();
96 err = afs_init_inodecache();
98 #ifndef LINUX_KEYRING_SUPPORT
103 err = register_filesystem(&afs_fs_type);
105 afs_destroy_inodecache();
106 #ifndef LINUX_KEYRING_SUPPORT
113 #ifdef LINUX_KEYRING_SUPPORT
116 #ifdef AFS_LINUX24_ENV
124 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
132 #ifdef LINUX_KEYRING_SUPPORT
133 osi_keyring_shutdown();
136 #ifndef LINUX_KEYRING_SUPPORT
139 unregister_filesystem(&afs_fs_type);
141 afs_destroy_inodecache();
142 #ifdef AFS_LINUX26_ENV
143 #if !defined(AFS_NONFSTRANS)
144 osi_linux_nfssrv_shutdown();
147 osi_linux_free_afs_memory();
149 #ifdef AFS_LINUX24_ENV
156 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
157 MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
158 module_init(afs_init);
159 module_exit(afs_cleanup);
163 #if !defined(AFS_LINUX24_ENV)
165 get_page_offset(void)
167 #if defined(AFS_PPC_LINUX22_ENV) || defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV) || defined(AFS_ALPHA_LINUX20_ENV) || defined(AFS_S390_LINUX22_ENV) || defined(AFS_IA64_LINUX20_ENV) || defined(AFS_PARISC_LINUX24_ENV) || defined(AFS_AMD64_LINUX20_ENV) || defined(AFS_PPC64_LINUX20_ENV)
170 struct task_struct *p, *q;
172 /* search backward thru the circular list */
173 #if defined(EXPORTED_TASKLIST_LOCK)
174 read_lock(&tasklist_lock);
176 /* search backward thru the circular list */
177 #ifdef DEFINED_PREV_TASK
178 for (q = current; p = q; q = prev_task(p)) {
180 for (p = current; p; p = p->prev_task) {
183 #if defined(EXPORTED_TASKLIST_LOCK)
184 read_unlock(&tasklist_lock);
186 return p->addr_limit.seg;
190 #if defined(EXPORTED_TASKLIST_LOCK)
191 read_unlock(&tasklist_lock);
196 #endif /* !AFS_LINUX24_ENV */