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"
18 #include <linux/module.h> /* early to avoid printf->printk mapping */
19 #include "afs/sysincludes.h"
20 #include "afsincludes.h"
21 #include "h/unistd.h" /* For syscall numbers. */
24 #ifdef AFS_AMD64_LINUX20_ENV
25 #include <asm/ia32_unistd.h>
27 #ifdef AFS_SPARC64_LINUX20_ENV
28 #include <linux/ioctl32.h>
31 #include <linux/proc_fs.h>
32 #include <linux/slab.h>
33 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
34 #include <linux/init.h>
35 #include <linux/sched.h>
36 #include <linux/kernel.h>
39 extern struct file_system_type afs_fs_type;
41 #if !defined(AFS_LINUX24_ENV)
42 static long get_page_offset(void);
45 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
46 DEFINE_MUTEX(afs_global_lock);
47 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
48 DECLARE_MUTEX(afs_global_lock);
50 struct semaphore afs_global_lock = MUTEX;
52 int afs_global_owner = 0;
53 #if !defined(AFS_LINUX24_ENV)
54 unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */
58 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
67 AFS_RWLOCK_INIT(&afs_xosi, "afs_xosi");
69 #if !defined(AFS_LINUX24_ENV)
70 /* obtain PAGE_OFFSET value */
71 afs_linux_page_offset = get_page_offset();
73 #ifndef AFS_S390_LINUX22_ENV
74 if (afs_linux_page_offset == 0) {
75 /* couldn't obtain page offset so can't continue */
76 printf("afs: Unable to obtain PAGE_OFFSET. Exiting..");
79 #endif /* AFS_S390_LINUX22_ENV */
80 #endif /* !defined(AFS_LINUX24_ENV) */
84 #ifndef LINUX_KEYRING_SUPPORT
85 err = osi_syscall_init();
89 err = afs_init_inodecache();
91 #ifndef LINUX_KEYRING_SUPPORT
96 err = register_filesystem(&afs_fs_type);
98 afs_destroy_inodecache();
99 #ifndef LINUX_KEYRING_SUPPORT
106 #ifdef LINUX_KEYRING_SUPPORT
109 #ifdef AFS_LINUX24_ENV
117 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
125 #ifdef LINUX_KEYRING_SUPPORT
126 osi_keyring_shutdown();
129 #ifndef LINUX_KEYRING_SUPPORT
132 unregister_filesystem(&afs_fs_type);
134 afs_destroy_inodecache();
135 osi_linux_free_afs_memory();
137 #ifdef AFS_LINUX24_ENV
145 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
146 MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
147 module_init(afs_init);
148 module_exit(afs_cleanup);
152 #if !defined(AFS_LINUX24_ENV)
154 get_page_offset(void)
156 #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)
159 struct task_struct *p, *q;
161 /* search backward thru the circular list */
162 #if defined(EXPORTED_TASKLIST_LOCK)
163 read_lock(&tasklist_lock);
165 /* search backward thru the circular list */
166 #if defined(prev_task)
167 for (q = current; p = q; q = prev_task(p)) {
169 for (p = current; p; p = p->prev_task) {
172 #if defined(EXPORTED_TASKLIST_LOCK)
173 read_unlock(&tasklist_lock);
175 return p->addr_limit.seg;
179 #if defined(EXPORTED_TASKLIST_LOCK)
180 read_unlock(&tasklist_lock);
185 #endif /* !AFS_LINUX24_ENV */