Merge 1.8.0~pre4 packaging into master
[pkg-k5-afs_openafs.git] / src / afs / LINUX / osi_module.c
blobd6172c1ad68ad6b5cec4f7387dbaae627fe83eae
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
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
8 */
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 <linux/unistd.h> /* For syscall numbers. */
22 #include <linux/mm.h>
24 #ifdef AFS_AMD64_LINUX20_ENV
25 #include <asm/ia32_unistd.h>
26 #endif
28 #include <linux/proc_fs.h>
29 #include <linux/slab.h>
30 #include <linux/init.h>
31 #include <linux/sched.h>
32 #include <linux/kernel.h>
34 #include "osi_pagecopy.h"
36 extern struct file_system_type afs_fs_type;
38 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
39 DEFINE_MUTEX(afs_global_lock);
40 #else
41 DECLARE_MUTEX(afs_global_lock);
42 #endif
43 int afs_global_owner = 0;
45 #ifdef HAVE_LINUX_KUID_T
46 struct user_namespace *afs_ns;
47 #endif
49 int __init
50 afs_init(void)
52 int err;
53 AFS_RWLOCK_INIT(&afs_xosi, "afs_xosi");
55 #ifdef HAVE_LINUX_KUID_T
56 afs_ns = afs_current_user_ns();
57 #endif
59 osi_Init();
60 #if !defined(AFS_NONFSTRANS)
61 osi_linux_nfssrv_init();
62 #endif
64 err = osi_syscall_init();
65 if (err)
66 return err;
67 err = afs_init_inodecache();
68 if (err) {
69 osi_syscall_clean();
70 return err;
72 err = register_filesystem(&afs_fs_type);
73 if (err) {
74 afs_destroy_inodecache();
75 osi_syscall_clean();
76 return err;
79 osi_sysctl_init();
80 #ifdef LINUX_KEYRING_SUPPORT
81 osi_keyring_init();
82 #endif
83 osi_proc_init();
84 osi_ioctl_init();
85 afs_init_pagecopy();
87 return 0;
90 void __exit
91 afs_cleanup(void)
93 afs_shutdown_pagecopy();
95 #ifdef LINUX_KEYRING_SUPPORT
96 osi_keyring_shutdown();
97 #endif
98 osi_sysctl_clean();
99 osi_syscall_clean();
100 unregister_filesystem(&afs_fs_type);
102 afs_destroy_inodecache();
103 #if !defined(AFS_NONFSTRANS)
104 osi_linux_nfssrv_shutdown();
105 #endif
106 shutdown_osisleep();
107 osi_linux_free_afs_memory();
109 osi_ioctl_clean();
110 osi_proc_clean();
112 return;
115 MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
116 module_init(afs_init);
117 module_exit(afs_cleanup);