2 * Copyright 2000, International Business Machines Corporation and others.
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
36 #include "../afs/param.h"
37 #include <afsconfig.h>
41 #include "sys/limits.h"
42 #include "sys/types.h"
44 #include "sys/vnode.h"
46 #include "sys/errno.h"
47 #include "sys/device.h"
49 #include "sys/vmount.h"
53 #include "sys/priv.h" /* XXX */
54 #include "sys/lockl.h"
55 #include "sys/malloc.h"
56 #include <sys/syspest.h>/* to define the assert and ASSERT macros */
57 #include <sys/timer.h> /* For the timer related defines */
58 #include <sys/intr.h> /* for the serialization defines */
59 #include <sys/malloc.h> /* for the parameters to xmalloc() */
60 #include "afs/afs_osi.h" /* pick up osi_timeval_t for afs_stats.h */
61 #include "afs/afs_stats.h"
65 #define KOFF_PRESENT 1
67 #define KOFF_PRESENT 0
75 extern struct gfs afs_gfs;
76 extern struct vnodeops locked_afs_gn_vnodeops;
78 #define AFS_CALLOUT_TBL_SIZE 256
80 #include <sys/lock_alloc.h>
81 extern Simple_lock afs_callout_lock;
84 * afs_config - handle AFS configuration requests
87 * cmd - add/delete command
88 * uiop - uio vector describing any config params
93 extern struct vnodeops *afs_ops;
95 AFS_STATCNT(afs_config);
99 if (cmd == CFG_INIT) { /* add AFS gfs */
101 * init any vrmix mandated kluges
103 if (err = kluge_init())
106 * make sure that we pin everything
108 if (err = pincode(afs_config))
110 err = gfsadd(AFS_MOUNT_AFS, &afs_gfs);
112 * ok, if already installed
117 pin(&afs_callout_lock, sizeof(afs_callout_lock));
118 lock_alloc(&afs_callout_lock, LOCK_ALLOC_PIN, 0, 5);
119 simple_lock_init(&afs_callout_lock);
120 afs_ops = &locked_afs_gn_vnodeops;
121 timeoutcf(AFS_CALLOUT_TBL_SIZE);
123 unpincode(afs_config);
127 extern void *db_syms[];
130 koff_addsyms(db_syms, db_nsyms);
132 } else if (cmd == CFG_TERM) { /* delete AFS gfs */
133 err = gfsdel(AFS_MOUNT_AFS);
135 * ok, if already deleted
140 if (err = unpincode(afs_config))
143 timeoutcf(-AFS_CALLOUT_TBL_SIZE);
145 } else /* unknown command */
150 if ( !err && (cmd == CFG_INIT) )
157 * The following stuff is (hopefully) temporary.
162 * mem_getbytes - memory allocator
164 * Seems we can't make up our mind what to call these
173 * mem_freebytes - memory deallocator
175 mem_freebytes(p, size)
194 register struct vnode *vp; {
200 register struct vnode *vp; {
206 * The following stuff is to account for the fact that stuff we need exported
207 * from the kernel isn't, so we must be devious.
210 int (*kluge_ufdalloc)();
211 int (*kluge_fpalloc)();
212 void *(*kluge_ufdfree)();
213 void *(*kluge_ffree)();
214 int (*kluge_iptovp)();
215 int (*kluge_dev_ialloc)();
218 int (*kluge_commit)();
219 void *(*kluge_ksettimer)();
220 void *(*kluge_fsSimpleLock)();
221 void *(*kluge_fsSimpleUnlock)();
222 void *(*kluge_fsReadLock)();
223 void *(*kluge_fsWriteLock)();
224 void *(*kluge_fsCxUnlock)();
227 * kernel function import list
230 struct k_func kfuncs[] = {
231 { (void *(**)()) &kluge_ufdalloc, ".ufdalloc" },
232 { (void *(**)()) &kluge_fpalloc, ".fpalloc" },
233 { &kluge_ufdfree, ".ufdfree" },
234 { &kluge_ffree, ".ffree" },
235 { (void *(**)()) &kluge_iptovp, ".iptovp" },
236 { (void *(**)()) &kluge_dev_ialloc, ".dev_ialloc" },
237 { (void *(**)()) &kluge_iget, ".iget" },
238 { (void *(**)()) &kluge_iput, ".iput" },
239 { (void *(**)()) &kluge_commit, ".commit" },
240 { &kluge_ksettimer, ".ksettimer" },
242 { &kluge_fsSimpleLock, ".fs_simple_lock" },
243 { &kluge_fsSimpleUnlock, ".fs_simple_unlock" },
244 { &kluge_fsReadLock, ".fs_read_lock" },
245 { &kluge_fsWriteLock, ".fs_write_lock" },
246 { &kluge_fsCxUnlock, ".fs_complex_unlock" },
251 void *vnodefops; /* dummy vnodeops */
253 Simple_lock jfs_icache_lock;
254 Simple_lock proc_tbl_lock;
257 * kernel variable import list
259 struct k_var kvars[] = {
260 { (void *) &vnodefops, "vnodefops" },
261 { (void *) &ifnet, "ifnet" },
262 { (void *) &jfs_icache_lock, "jfs_icache_lock" },
263 { (void *) &proc_tbl_lock, "proc_tbl_lock" },
268 * kluge_init - initialise the kernel imports kluge
271 register struct k_func *kf;
272 register struct k_var *kv;
273 register afs_uint32 toc;
277 for (kf = kfuncs; !err && kf->name; ++kf) {
278 err = import_kfunc(kf);
280 for (kv = kvars; !err && kv->name; ++kv) {
281 err = import_kvar(kv, toc);
290 return (*kluge_ufdalloc)(i, fdp);
293 fpalloc(vp, flag, type, ops, fpp)
298 return (*kluge_fpalloc)(vp, flag, type, ops, fpp);
304 (void) (*kluge_ufdfree)(fd);
311 (void) (*kluge_ffree)(fp);
314 iptovp(vfsp, ip, vpp)
316 struct inode *ip, **vpp; {
318 return (*kluge_iptovp)(vfsp, ip, vpp);
321 dev_ialloc(pip, ino, mode, vfsp, ipp)
326 struct inode **ipp; {
328 return (*kluge_dev_ialloc)(pip, ino, mode, vfsp, ipp);
332 iget(dev, ino, ipp, doscan, vfsp)
336 struct inode **ipp; {
338 return (*kluge_iget)(dev, ino, ipp, doscan, vfsp);
344 return (*kluge_iput)(ip, vfsp);
347 commit(n, i0, i1, i2)
348 struct inode *i0, *i1, *i2; {
350 return (*kluge_commit)(n, i0, i1, i2);
355 fs_simple_lock(void *lp, int type) {
356 return (*kluge_fsSimpleLock)(lp, type);
359 fs_simple_unlock(void *lp, int type) {
360 return (*kluge_fsSimpleUnlock)(lp, type);
363 fs_read_lock(complex_lock_t lp, int type) {
364 return (*kluge_fsReadLock)(lp, type);
367 fs_write_lock(complex_lock_t lp, int type) {
368 return (*kluge_fsWriteLock)(lp, type);
371 fs_complex_unlock(complex_lock_t lp, int type) {
372 return (*kluge_fsCxUnlock)(lp, type);