5583207424efcf3dda84d1407554b0e12895d6cb
[openafs.git] / src / afs / LINUX / osi_pag_module.c
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_LINUX_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 module_param(nfs_server_addr, long, 0);
35 MODULE_PARM_DESC(nfs_server_addr,  "IP Address of NFS Server");
36
37 static char *this_cell = 0;
38 module_param(this_cell, charp, 0);
39 MODULE_PARM_DESC(this_cell, "Local cell name");
40
41 DEFINE_MUTEX(afs_global_lock);
42
43 struct proc_dir_entry *openafs_procfs;
44 int afs_global_owner = 0;
45
46 #ifdef HAVE_LINUX_KUID_T
47 struct user_namespace *afs_ns;
48 #endif
49
50 int __init
51 afspag_init(void)
52 {
53 #if !defined(EXPORTED_PROC_ROOT_FS)
54     char path[64];
55 #endif
56     int err;
57
58 #ifdef HAVE_LINUX_KUID_T
59     afs_ns = afs_current_user_ns();
60 #endif
61
62     osi_Init();
63
64     err = osi_syscall_init();
65     if (err)
66         return err;
67 #if defined(EXPORTED_PROC_ROOT_FS)
68     openafs_procfs = proc_mkdir(PROC_FSDIRNAME, proc_root_fs);
69 #else
70     sprintf(path, "fs/%s", PROC_FSDIRNAME);
71     openafs_procfs = proc_mkdir(path, NULL);
72 #endif
73     osi_ioctl_init();
74
75     afspag_Init(htonl(nfs_server_addr));
76     if (this_cell)
77         afspag_SetPrimaryCell(this_cell);
78
79     return 0;
80 }
81
82 void __exit
83 afspag_cleanup(void)
84 {
85 #if !defined(EXPORTED_PROC_ROOT_FS)
86     char path[64];
87 #endif
88     osi_syscall_clean();
89
90     osi_linux_free_afs_memory();
91
92     osi_ioctl_clean();
93 #if defined(EXPORTED_PROC_ROOT_FS)
94     remove_proc_entry(PROC_FSDIRNAME, proc_root_fs);
95 #else
96     sprintf(path, "fs/%s", PROC_FSDIRNAME);
97     remove_proc_entry(path, NULL);
98 #endif
99     return;
100 }
101
102 MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
103 module_init(afspag_init);
104 module_exit(afspag_cleanup);
105
106 /* Hack alert!
107  * These will never be called in the standalone PAG manager, because
108  * they are only referenced in afs_InitReq, and nothing calls that.
109  * However, we need to define them in order to resolve the reference,
110  * unless we want to move afs_InitReq out of afs_osi_pag.c.
111  */
112 int osi_linux_nfs_initreq(struct vrequest *av, afs_ucred_t *cr, int *code)
113 {
114     *code = EACCES;
115     return 1;
116 }
117
118 int
119 afs_nfsclient_reqhandler(struct afs_exporter *exporter,
120                          afs_ucred_t **cred,
121                          afs_uint32 host, afs_int32 *pagparam,
122                          struct afs_exporter **outexporter)
123 {
124     return EINVAL;
125 }