Commit | Line | Data |
---|---|---|
805e021f CE |
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 | */ | |
9 | ||
10 | /* | |
11 | * Linux module support routines. | |
12 | * | |
13 | */ | |
14 | #include <afsconfig.h> | |
15 | #include "afs/param.h" | |
16 | ||
17 | #include <linux/module.h> /* early to avoid printf->printk mapping */ | |
18 | #include "afs/sysincludes.h" | |
19 | #include "afsincludes.h" | |
20 | #include <linux/unistd.h> /* For syscall numbers. */ | |
21 | #include <linux/mm.h> | |
22 | ||
23 | #ifdef AFS_AMD64_LINUX20_ENV | |
24 | #include <asm/ia32_unistd.h> | |
25 | #endif | |
26 | ||
27 | #include <linux/proc_fs.h> | |
28 | #include <linux/slab.h> | |
29 | #include <linux/init.h> | |
30 | #include <linux/sched.h> | |
31 | #include <linux/kernel.h> | |
32 | ||
33 | static unsigned long nfs_server_addr = 0; | |
34 | #if defined(module_param) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) | |
35 | module_param(nfs_server_addr, long, 0); | |
36 | #else | |
37 | MODULE_PARM(nfs_server_addr, "l"); | |
38 | #endif | |
39 | MODULE_PARM_DESC(nfs_server_addr, "IP Address of NFS Server"); | |
40 | ||
41 | static char *this_cell = 0; | |
42 | #if defined(module_param_array) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) | |
43 | module_param(this_cell, charp, 0); | |
44 | #else | |
45 | MODULE_PARM(this_cell, "s"); | |
46 | #endif | |
47 | MODULE_PARM_DESC(this_cell, "Local cell name"); | |
48 | ||
49 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) | |
50 | DEFINE_MUTEX(afs_global_lock); | |
51 | #else | |
52 | DECLARE_MUTEX(afs_global_lock); | |
53 | #endif | |
54 | struct proc_dir_entry *openafs_procfs; | |
55 | int afs_global_owner = 0; | |
56 | ||
57 | #ifdef HAVE_LINUX_KUID_T | |
58 | struct user_namespace *afs_ns; | |
59 | #endif | |
60 | ||
61 | int __init | |
62 | afspag_init(void) | |
63 | { | |
64 | #if !defined(EXPORTED_PROC_ROOT_FS) | |
65 | char path[64]; | |
66 | #endif | |
67 | int err; | |
68 | ||
69 | #ifdef HAVE_LINUX_KUID_T | |
70 | afs_ns = afs_current_user_ns(); | |
71 | #endif | |
72 | ||
73 | osi_Init(); | |
74 | ||
75 | err = osi_syscall_init(); | |
76 | if (err) | |
77 | return err; | |
78 | #if defined(EXPORTED_PROC_ROOT_FS) | |
79 | openafs_procfs = proc_mkdir(PROC_FSDIRNAME, proc_root_fs); | |
80 | #else | |
81 | sprintf(path, "fs/%s", PROC_FSDIRNAME); | |
82 | openafs_procfs = proc_mkdir(path, NULL); | |
83 | #endif | |
84 | osi_ioctl_init(); | |
85 | ||
86 | afspag_Init(htonl(nfs_server_addr)); | |
87 | if (this_cell) | |
88 | afspag_SetPrimaryCell(this_cell); | |
89 | ||
90 | return 0; | |
91 | } | |
92 | ||
93 | void __exit | |
94 | afspag_cleanup(void) | |
95 | { | |
96 | #if !defined(EXPORTED_PROC_ROOT_FS) | |
97 | char path[64]; | |
98 | #endif | |
99 | osi_syscall_clean(); | |
100 | ||
101 | osi_linux_free_afs_memory(); | |
102 | ||
103 | osi_ioctl_clean(); | |
104 | #if defined(EXPORTED_PROC_ROOT_FS) | |
105 | remove_proc_entry(PROC_FSDIRNAME, proc_root_fs); | |
106 | #else | |
107 | sprintf(path, "fs/%s", PROC_FSDIRNAME); | |
108 | remove_proc_entry(path, NULL); | |
109 | #endif | |
110 | return; | |
111 | } | |
112 | ||
113 | MODULE_LICENSE("http://www.openafs.org/dl/license10.html"); | |
114 | module_init(afspag_init); | |
115 | module_exit(afspag_cleanup); | |
116 | ||
117 | /* Hack alert! | |
118 | * These will never be called in the standalone PAG manager, because | |
119 | * they are only referenced in afs_InitReq, and nothing calls that. | |
120 | * However, we need to define them in order to resolve the reference, | |
121 | * unless we want to move afs_InitReq out of afs_osi_pag.c. | |
122 | */ | |
123 | int osi_linux_nfs_initreq(struct vrequest *av, afs_ucred_t *cr, int *code) | |
124 | { | |
125 | *code = EACCES; | |
126 | return 1; | |
127 | } | |
128 | ||
129 | int | |
130 | afs_nfsclient_reqhandler(struct afs_exporter *exporter, | |
131 | afs_ucred_t **cred, | |
132 | afs_uint32 host, afs_int32 *pagparam, | |
133 | struct afs_exporter **outexporter) | |
134 | { | |
135 | return EINVAL; | |
136 | } |