* Linux module support routines.
*
*/
-#include "../afs/param.h"
-#include "../afs/sysincludes.h"
-#include "../afs/afsincludes.h"
-#include "../h/unistd.h" /* For syscall numbers. */
-#include "../h/mm.h"
+#include <afsconfig.h>
+#include "afs/param.h"
-#include <linux/module.h>
+#include <linux/module.h> /* early to avoid printf->printk mapping */
+#include "afs/sysincludes.h"
+#include "afsincludes.h"
+#include <linux/unistd.h> /* For syscall numbers. */
+#include <linux/mm.h>
+#ifdef AFS_AMD64_LINUX20_ENV
+#include <asm/ia32_unistd.h>
+#endif
-asmlinkage int (*sys_settimeofdayp)(struct timeval *tv, struct timezone *tz);
-asmlinkage int (*sys_socketcallp)(int call, long *args);
-asmlinkage int (*sys_killp)(int pid, int signal);
-asmlinkage int (*sys_setgroupsp)(int gidsetsize, gid_t *grouplist);
+#include <linux/proc_fs.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
-extern void *sys_call_table[];
-extern struct file_system_type afs_file_system;
+#include "osi_pagecopy.h"
-static long get_page_offset(void);
+extern struct file_system_type afs_fs_type;
-struct semaphore afs_global_lock = MUTEX;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+DEFINE_MUTEX(afs_global_lock);
+#else
+DECLARE_MUTEX(afs_global_lock);
+#endif
int afs_global_owner = 0;
-unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */
-/* Since sys_ni_syscall is not exported, I need to cache it in order to restore
- * it.
- */
-static void *afs_ni_syscall = NULL;
+#ifdef HAVE_LINUX_KUID_T
+struct user_namespace *afs_ns;
+#endif
-int init_module(void)
+int __init
+afs_init(void)
{
- extern int afs_syscall();
- extern int afs_xsetgroups();
+ int err;
+ AFS_RWLOCK_INIT(&afs_xosi, "afs_xosi");
- /* obtain PAGE_OFFSET value */
- afs_linux_page_offset = get_page_offset();
+#ifdef HAVE_LINUX_KUID_T
+ afs_ns = afs_current_user_ns();
+#endif
- if (afs_linux_page_offset == 0) {
- /* couldn't obtain page offset so can't continue */
- printf("afs: Unable to obtain PAGE_OFFSET. Exiting..");
- return -EIO;
+ osi_Init();
+#if !defined(AFS_NONFSTRANS)
+ osi_linux_nfssrv_init();
+#endif
+
+#ifndef LINUX_KEYRING_SUPPORT
+ err = osi_syscall_init();
+ if (err)
+ return err;
+#endif
+ err = afs_init_inodecache();
+ if (err) {
+#ifndef LINUX_KEYRING_SUPPORT
+ osi_syscall_clean();
+#endif
+ return err;
}
-
- /* Initialize pointers to kernel syscalls. */
- sys_settimeofdayp = sys_call_table[__NR_settimeofday];
- sys_socketcallp = sys_call_table[__NR_socketcall];
- sys_killp = sys_call_table[__NR_kill];
-
- /* setup AFS entry point. */
- if (sys_call_table[__NR_afs_syscall] == afs_syscall) {
- printf("AFS syscall entry point already in use!\n");
- return -EBUSY;
+ err = register_filesystem(&afs_fs_type);
+ if (err) {
+ afs_destroy_inodecache();
+#ifndef LINUX_KEYRING_SUPPORT
+ osi_syscall_clean();
+#endif
+ return err;
}
-
- afs_ni_syscall = sys_call_table[__NR_afs_syscall];
- sys_call_table[__NR_afs_syscall] = afs_syscall;
-
- osi_Init();
- register_filesystem(&afs_file_system);
-
- /* Intercept setgroups calls */
- sys_setgroupsp = sys_call_table[__NR_setgroups];
- sys_call_table[__NR_setgroups] = afs_xsetgroups;
+ osi_sysctl_init();
+#ifdef LINUX_KEYRING_SUPPORT
+ osi_keyring_init();
+#endif
+ osi_proc_init();
+ osi_ioctl_init();
+ afs_init_pagecopy();
return 0;
}
-void cleanup_module(void)
+void __exit
+afs_cleanup(void)
{
- struct task_struct *t;
-
- sys_call_table[__NR_setgroups] = sys_setgroupsp;
- sys_call_table[__NR_afs_syscall] = afs_ni_syscall;
-
- unregister_filesystem(&afs_file_system);
-
- osi_linux_free_inode_pages(); /* Invalidate all pages using AFS inodes. */
+ afs_shutdown_pagecopy();
+
+#ifdef LINUX_KEYRING_SUPPORT
+ osi_keyring_shutdown();
+#endif
+ osi_sysctl_clean();
+#ifndef LINUX_KEYRING_SUPPORT
+ osi_syscall_clean();
+#endif
+ unregister_filesystem(&afs_fs_type);
+
+ afs_destroy_inodecache();
+#if !defined(AFS_NONFSTRANS)
+ osi_linux_nfssrv_shutdown();
+#endif
+ shutdown_osisleep();
osi_linux_free_afs_memory();
+ osi_ioctl_clean();
+ osi_proc_clean();
+
return;
}
-static long get_page_offset(void)
-{
- struct task_struct *p;
-
- /* search backward thru the circular list */
- for(p = current; p; p = p->prev_task)
- if (p->pid == 1)
- return p->addr_limit.seg;
+MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
+module_init(afs_init);
+module_exit(afs_cleanup);
- return 0;
-}