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 struct semaphore afs_global_lock = MUTEX;
35 int afs_global_owner = 0;
36 unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */
38 /* Since sys_ni_syscall is not exported, I need to cache it in order to restore
41 static void *afs_ni_syscall = NULL;
45 extern int afs_syscall();
46 extern int afs_xsetgroups();
48 /* obtain PAGE_OFFSET value */
49 afs_linux_page_offset = get_page_offset();
51 if (afs_linux_page_offset == 0) {
52 /* couldn't obtain page offset so can't continue */
53 printf("afs: Unable to obtain PAGE_OFFSET. Exiting..");
57 /* Initialize pointers to kernel syscalls. */
58 sys_settimeofdayp = sys_call_table[__NR_settimeofday];
59 sys_socketcallp = sys_call_table[__NR_socketcall];
60 sys_killp = sys_call_table[__NR_kill];
62 /* setup AFS entry point. */
63 if (sys_call_table[__NR_afs_syscall] == afs_syscall) {
64 printf("AFS syscall entry point already in use!\n");
69 afs_ni_syscall = sys_call_table[__NR_afs_syscall];
70 sys_call_table[__NR_afs_syscall] = afs_syscall;
73 register_filesystem(&afs_file_system);
75 /* Intercept setgroups calls */
76 sys_setgroupsp = sys_call_table[__NR_setgroups];
77 sys_call_table[__NR_setgroups] = afs_xsetgroups;
82 void cleanup_module(void)
84 struct task_struct *t;
86 sys_call_table[__NR_setgroups] = sys_setgroupsp;
87 sys_call_table[__NR_afs_syscall] = afs_ni_syscall;
89 unregister_filesystem(&afs_file_system);
91 osi_linux_free_inode_pages(); /* Invalidate all pages using AFS inodes. */
92 osi_linux_free_afs_memory();
97 static long get_page_offset(void)
99 struct task_struct *p;
101 /* search backward thru the circular list */
102 for(p = current; p; p = p->prev_task)
104 return p->addr_limit.seg;