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 "../afs/param.h"
15 #include "../afs/sysincludes.h"
16 #include "../afs/afsincludes.h"
17 #include "../h/unistd.h" /* For syscall numbers. */
20 #include <linux/module.h>
24 asmlinkage int (*sys_settimeofdayp)(struct timeval *tv, struct timezone *tz);
25 asmlinkage int (*sys_socketcallp)(int call, long *args);
26 asmlinkage int (*sys_killp)(int pid, int signal);
27 asmlinkage int (*sys_setgroupsp)(int gidsetsize, gid_t *grouplist);
29 extern void *sys_call_table[];
30 extern struct file_system_type afs_file_system;
32 static long get_page_offset(void);
34 #if defined(AFS_LINUX24_ENV)
35 DECLARE_MUTEX(afs_global_lock);
37 struct semaphore afs_global_lock = MUTEX;
39 int afs_global_owner = 0;
40 unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */
42 /* Since sys_ni_syscall is not exported, I need to cache it in order to restore
45 static void *afs_ni_syscall = NULL;
49 extern int afs_syscall();
50 extern int afs_xsetgroups();
52 /* obtain PAGE_OFFSET value */
53 afs_linux_page_offset = get_page_offset();
55 if (afs_linux_page_offset == 0) {
56 /* couldn't obtain page offset so can't continue */
57 printf("afs: Unable to obtain PAGE_OFFSET. Exiting..");
61 /* Initialize pointers to kernel syscalls. */
62 sys_settimeofdayp = sys_call_table[__NR_settimeofday];
63 sys_socketcallp = sys_call_table[__NR_socketcall];
64 sys_killp = sys_call_table[__NR_kill];
66 /* setup AFS entry point. */
67 if (sys_call_table[__NR_afs_syscall] == afs_syscall) {
68 printf("AFS syscall entry point already in use!\n");
73 afs_ni_syscall = sys_call_table[__NR_afs_syscall];
74 sys_call_table[__NR_afs_syscall] = afs_syscall;
77 register_filesystem(&afs_file_system);
79 /* Intercept setgroups calls */
80 sys_setgroupsp = sys_call_table[__NR_setgroups];
81 sys_call_table[__NR_setgroups] = afs_xsetgroups;
86 void cleanup_module(void)
88 struct task_struct *t;
90 sys_call_table[__NR_setgroups] = sys_setgroupsp;
91 sys_call_table[__NR_afs_syscall] = afs_ni_syscall;
93 unregister_filesystem(&afs_file_system);
95 osi_linux_free_inode_pages(); /* Invalidate all pages using AFS inodes. */
96 osi_linux_free_afs_memory();
101 static long get_page_offset(void)
103 #if defined(AFS_PPC_LINUX22_ENV)
106 struct task_struct *p;
108 /* search backward thru the circular list */
109 for(p = current; p; p = p->prev_task)
111 return p->addr_limit.seg;