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 <afsconfig.h>
37 #include "afs/param.h"
42 #include "sys/limits.h"
43 #include "sys/types.h"
45 #include "sys/vnode.h"
47 #include "sys/errno.h"
48 #include "sys/device.h"
50 #include "sys/vmount.h"
54 #include "sys/priv.h" /* XXX */
55 #include "sys/lockl.h"
56 #include "sys/malloc.h"
57 #include <sys/syspest.h> /* to define the assert and ASSERT macros */
58 #include <sys/timer.h> /* For the timer related defines */
59 #include <sys/intr.h> /* for the serialization defines */
60 #include <sys/malloc.h> /* for the parameters to xmalloc() */
61 #include "afs/afs_osi.h" /* pick up osi_timeval_t for afs_stats.h */
62 #include "afs/afs_stats.h"
63 #include "../export.h"
66 #define KOFF_PRESENT 1
68 #define KOFF_PRESENT 0
79 extern struct gfs afs_gfs;
80 extern struct vnodeops locked_afs_gn_vnodeops;
88 #define AFS_CALLOUT_TBL_SIZE 256
90 #include <sys/lock_alloc.h>
91 extern Simple_lock afs_callout_lock;
94 * afs_config - handle AFS configuration requests
97 * cmd - add/delete command
98 * uiop - uio vector describing any config params
100 afs_config(cmd, uiop)
104 extern struct vnodeops *afs_ops;
106 AFS_STATCNT(afs_config);
110 if (cmd == CFG_INIT) { /* add AFS gfs */
112 * init any vrmix mandated kluges
114 if (err = kluge_init())
117 * make sure that we pin everything
119 if (err = pincode(afs_config))
121 err = gfsadd(AFS_MOUNT_AFS, &afs_gfs);
123 * ok, if already installed
128 pin(&afs_callout_lock, sizeof(afs_callout_lock));
129 lock_alloc(&afs_callout_lock, LOCK_ALLOC_PIN, 0, 5);
130 simple_lock_init(&afs_callout_lock);
131 afs_ops = &locked_afs_gn_vnodeops;
132 timeoutcf(AFS_CALLOUT_TBL_SIZE);
134 unpincode(afs_config);
138 extern void *db_syms[];
141 koff_addsyms(db_syms, db_nsyms);
143 } else if (cmd == CFG_TERM) { /* delete AFS gfs */
144 err = gfsdel(AFS_MOUNT_AFS);
146 * ok, if already deleted
150 #ifndef AFS_AIX51_ENV
155 if (err = unpin(&afs_callout_lock))
158 if (err = unpincode(afs_config))
161 timeoutcf(-AFS_CALLOUT_TBL_SIZE);
163 } else /* unknown command */
168 if (!err && (cmd == CFG_INIT))
175 * The following stuff is (hopefully) temporary.
180 * mem_getbytes - memory allocator
182 * Seems we can't make up our mind what to call these
192 * mem_freebytes - memory deallocator
194 mem_freebytes(p, size)
216 register struct vnode *vp;
223 register struct vnode *vp;
230 * The following stuff is to account for the fact that stuff we need exported
231 * from the kernel isn't, so we must be devious.
234 int (*kluge_ufdalloc) ();
235 int (*kluge_fpalloc) ();
236 void *(*kluge_ufdfree) ();
237 void *(*kluge_ffree) ();
238 int (*kluge_iptovp) ();
239 int (*kluge_dev_ialloc) ();
240 int (*kluge_iget) ();
241 int (*kluge_iput) ();
242 int (*kluge_commit) ();
243 void *(*kluge_ksettimer) ();
244 void *(*kluge_fsSimpleLock) ();
245 void *(*kluge_fsSimpleUnlock) ();
246 void *(*kluge_fsReadLock) ();
247 void *(*kluge_fsWriteLock) ();
248 void *(*kluge_fsCxUnlock) ();
251 * kernel function import list
254 struct k_func kfuncs[] = {
255 {(void *(**)())&kluge_ufdalloc, ".ufdalloc"},
256 {(void *(**)())&kluge_fpalloc, ".fpalloc"},
257 {&kluge_ufdfree, ".ufdfree"},
258 {&kluge_ffree, ".ffree"},
259 {(void *(**)())&kluge_iptovp, ".iptovp"},
260 {(void *(**)())&kluge_dev_ialloc, ".dev_ialloc"},
261 {(void *(**)())&kluge_iget, ".iget"},
262 {(void *(**)())&kluge_iput, ".iput"},
263 {(void *(**)())&kluge_commit, ".commit"},
264 {&kluge_ksettimer, ".ksettimer"},
266 {&kluge_fsSimpleLock, ".fs_simple_lock"},
267 {&kluge_fsSimpleUnlock, ".fs_simple_unlock"},
268 {&kluge_fsReadLock, ".fs_read_lock"},
269 {&kluge_fsWriteLock, ".fs_write_lock"},
270 {&kluge_fsCxUnlock, ".fs_complex_unlock"},
275 void *vnodefops; /* dummy vnodeops */
277 Simple_lock jfs_icache_lock;
278 Simple_lock proc_tbl_lock;
281 * kernel variable import list
283 struct k_var kvars[] = {
284 {(void *)&vnodefops, "vnodefops"},
285 {(void *)&ifnet, "ifnet"},
286 {(void *)&jfs_icache_lock, "jfs_icache_lock"},
287 #ifndef AFS_AIX51_ENV
288 {(void *)&proc_tbl_lock, "proc_tbl_lock"},
294 * kluge_init - initialise the kernel imports kluge
298 register struct k_func *kf;
299 register struct k_var *kv;
301 register afs_uint64 toc;
303 register afs_uint32 toc;
308 for (kf = kfuncs; !err && kf->name; ++kf) {
309 err = import_kfunc(kf);
311 for (kv = kvars; !err && kv->name; ++kv) {
312 err = import_kvar(kv, toc);
322 return (*kluge_ufdalloc) (i, fdp);
325 fpalloc(vp, flag, type, ops, fpp)
331 return (*kluge_fpalloc) (vp, flag, type, ops, fpp);
338 (void)(*kluge_ufdfree) (fd);
346 (void)(*kluge_ffree) (fp);
349 iptovp(vfsp, ip, vpp)
351 struct inode *ip, **vpp;
354 return (*kluge_iptovp) (vfsp, ip, vpp);
357 dev_ialloc(pip, ino, mode, vfsp, ipp)
365 return (*kluge_dev_ialloc) (pip, ino, mode, vfsp, ipp);
369 iget(dev, ino, ipp, doscan, vfsp)
382 return (*kluge_iget) (dev, ino, ipp, (afs_size_t) doscan, vfsp, &dummy);
384 return (*kluge_iget) (dev, ino, ipp, doscan, vfsp);
392 return (*kluge_iput) (ip, vfsp);
395 commit(n, i0, i1, i2)
396 struct inode *i0, *i1, *i2;
399 return (*kluge_commit) (n, i0, i1, i2);
404 fs_simple_lock(void *lp, int type)
406 return (*kluge_fsSimpleLock) (lp, type);
409 fs_simple_unlock(void *lp, int type)
411 return (*kluge_fsSimpleUnlock) (lp, type);
414 fs_read_lock(complex_lock_t lp, int type)
416 return (*kluge_fsReadLock) (lp, type);
419 fs_write_lock(complex_lock_t lp, int type)
421 return (*kluge_fsWriteLock) (lp, type);
424 fs_complex_unlock(complex_lock_t lp, int type)
426 return (*kluge_fsCxUnlock) (lp, type);