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 | #include <afsconfig.h> | |
12 | #include <afs/param.h> | |
13 | ||
14 | ||
15 | #include <afs/sysincludes.h> | |
16 | #include <afsincludes.h> | |
17 | #include <sys/module.h> | |
18 | #include <sys/sysproto.h> | |
19 | #include <sys/syscall.h> | |
20 | ||
21 | extern struct vfsops afs_vfsops; | |
22 | extern struct vnodeopv_desc afs_vnodeop_opv_desc; | |
23 | extern struct mount *afs_globalVFS; | |
24 | ||
25 | MALLOC_DEFINE(M_AFS, "afsmisc", "memory used by the AFS filesystem"); | |
26 | ||
27 | #ifdef AFS_FBSD60_ENV | |
28 | VFS_SET(afs_vfsops, afs, VFCF_NETWORK); | |
29 | #else | |
30 | int afs_module_handler(module_t mod, int what, void *arg); | |
31 | ||
32 | static struct vfsconf afs_vfsconf; | |
33 | static moduledata_t afs_mod = { | |
34 | "afs", | |
35 | afs_module_handler, | |
36 | &afs_mod | |
37 | }; | |
38 | ||
39 | DECLARE_MODULE(afs, afs_mod, SI_SUB_VFS, SI_ORDER_MIDDLE); | |
40 | #endif | |
41 | ||
42 | #ifndef AFS_FBSD60_ENV | |
43 | int | |
44 | afs_module_handler(module_t mod, int what, void *arg) | |
45 | { | |
46 | static int inited = 0; | |
47 | int error = 0; | |
48 | ||
49 | switch (what) { | |
50 | case MOD_LOAD: | |
51 | if (inited) { | |
52 | printf("afs cannot be MOD_LOAD'd more than once\n"); | |
53 | error = EBUSY; | |
54 | break; | |
55 | } | |
56 | memset(&afs_vfsconf, 0, sizeof(struct vfsconf)); | |
57 | #ifdef AFS_FBSD53_ENV | |
58 | afs_vfsconf.vfc_version = VFS_VERSION; | |
59 | #endif | |
60 | strcpy(afs_vfsconf.vfc_name, "AFS"); | |
61 | afs_vfsconf.vfc_vfsops = &afs_vfsops; | |
62 | afs_vfsconf.vfc_typenum = -1; /* set by vfs_register */ | |
63 | afs_vfsconf.vfc_flags = VFCF_NETWORK; | |
64 | if ((error = vfs_register(&afs_vfsconf)) != 0) | |
65 | break; | |
66 | vfs_add_vnodeops(&afs_vnodeop_opv_desc); | |
67 | inited = 1; | |
68 | break; | |
69 | case MOD_UNLOAD: | |
70 | #ifndef RXK_LISTENER_ENV | |
71 | /* shutdown is incomplete unless RXK_LISTENER_ENV */ | |
72 | printf("afs: I can't be unloaded yet\n"); | |
73 | return -1; | |
74 | #endif | |
75 | if (!inited) { | |
76 | error = 0; | |
77 | break; | |
78 | } | |
79 | if ((error = vfs_unregister(&afs_vfsconf)) != 0) { | |
80 | break; | |
81 | } | |
82 | vfs_rm_vnodeops(&afs_vnodeop_opv_desc); | |
83 | break; | |
84 | } | |
85 | ||
86 | return (error); | |
87 | } | |
88 | #endif |