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"
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;
84 #define AFS_CALLOUT_TBL_SIZE 256
86 #include <sys/lock_alloc.h>
87 extern Simple_lock afs_callout_lock;
90 * afs_config - handle AFS configuration requests
93 * cmd - add/delete command
94 * uiop - uio vector describing any config params
99 extern struct vnodeops *afs_ops;
101 AFS_STATCNT(afs_config);
105 if (cmd == CFG_INIT) { /* add AFS gfs */
107 * init any vrmix mandated kluges
109 if (err = kluge_init())
112 * make sure that we pin everything
114 if (err = pincode(afs_config))
116 err = gfsadd(AFS_MOUNT_AFS, &afs_gfs);
118 * ok, if already installed
123 pin(&afs_callout_lock, sizeof(afs_callout_lock));
124 lock_alloc(&afs_callout_lock, LOCK_ALLOC_PIN, 0, 5);
125 simple_lock_init(&afs_callout_lock);
126 afs_ops = &locked_afs_gn_vnodeops;
127 timeoutcf(AFS_CALLOUT_TBL_SIZE);
129 unpincode(afs_config);
133 extern void *db_syms[];
136 koff_addsyms(db_syms, db_nsyms);
138 } else if (cmd == CFG_TERM) { /* delete AFS gfs */
139 err = gfsdel(AFS_MOUNT_AFS);
141 * ok, if already deleted
146 if (err = unpincode(afs_config))
149 timeoutcf(-AFS_CALLOUT_TBL_SIZE);
151 } else /* unknown command */
156 if ( !err && (cmd == CFG_INIT) )
163 * The following stuff is (hopefully) temporary.
168 * mem_getbytes - memory allocator
170 * Seems we can't make up our mind what to call these
179 * mem_freebytes - memory deallocator
181 mem_freebytes(p, size)
200 register struct vnode *vp; {
206 register struct vnode *vp; {
212 * The following stuff is to account for the fact that stuff we need exported
213 * from the kernel isn't, so we must be devious.
216 int (*kluge_ufdalloc)();
217 int (*kluge_fpalloc)();
218 void *(*kluge_ufdfree)();
219 void *(*kluge_ffree)();
220 int (*kluge_iptovp)();
221 int (*kluge_dev_ialloc)();
224 int (*kluge_commit)();
225 void *(*kluge_ksettimer)();
226 void *(*kluge_fsSimpleLock)();
227 void *(*kluge_fsSimpleUnlock)();
228 void *(*kluge_fsReadLock)();
229 void *(*kluge_fsWriteLock)();
230 void *(*kluge_fsCxUnlock)();
233 * kernel function import list
236 struct k_func kfuncs[] = {
237 { (void *(**)()) &kluge_ufdalloc, ".ufdalloc" },
238 { (void *(**)()) &kluge_fpalloc, ".fpalloc" },
239 { &kluge_ufdfree, ".ufdfree" },
240 { &kluge_ffree, ".ffree" },
241 { (void *(**)()) &kluge_iptovp, ".iptovp" },
242 { (void *(**)()) &kluge_dev_ialloc, ".dev_ialloc" },
243 { (void *(**)()) &kluge_iget, ".iget" },
244 { (void *(**)()) &kluge_iput, ".iput" },
245 { (void *(**)()) &kluge_commit, ".commit" },
246 { &kluge_ksettimer, ".ksettimer" },
248 { &kluge_fsSimpleLock, ".fs_simple_lock" },
249 { &kluge_fsSimpleUnlock, ".fs_simple_unlock" },
250 { &kluge_fsReadLock, ".fs_read_lock" },
251 { &kluge_fsWriteLock, ".fs_write_lock" },
252 { &kluge_fsCxUnlock, ".fs_complex_unlock" },
257 void *vnodefops; /* dummy vnodeops */
259 Simple_lock jfs_icache_lock;
260 Simple_lock proc_tbl_lock;
263 * kernel variable import list
265 struct k_var kvars[] = {
266 { (void *) &vnodefops, "vnodefops" },
267 { (void *) &ifnet, "ifnet" },
268 { (void *) &jfs_icache_lock, "jfs_icache_lock" },
269 #ifndef AFS_AIX51_ENV
270 { (void *) &proc_tbl_lock, "proc_tbl_lock" },
276 * kluge_init - initialise the kernel imports kluge
279 register struct k_func *kf;
280 register struct k_var *kv;
282 register afs_uint64 toc;
284 register afs_uint32 toc;
289 for (kf = kfuncs; !err && kf->name; ++kf) {
290 err = import_kfunc(kf);
292 for (kv = kvars; !err && kv->name; ++kv) {
293 err = import_kvar(kv, toc);
302 return (*kluge_ufdalloc)(i, fdp);
305 fpalloc(vp, flag, type, ops, fpp)
310 return (*kluge_fpalloc)(vp, flag, type, ops, fpp);
316 (void) (*kluge_ufdfree)(fd);
323 (void) (*kluge_ffree)(fp);
326 iptovp(vfsp, ip, vpp)
328 struct inode *ip, **vpp; {
330 return (*kluge_iptovp)(vfsp, ip, vpp);
333 dev_ialloc(pip, ino, mode, vfsp, ipp)
338 struct inode **ipp; {
340 return (*kluge_dev_ialloc)(pip, ino, mode, vfsp, ipp);
344 iget(dev, ino, ipp, doscan, vfsp)
351 struct inode **ipp; {
356 return (*kluge_iget)(dev, ino, ipp, (afs_size_t) doscan, vfsp, &dummy);
358 return (*kluge_iget)(dev, ino, ipp, doscan, vfsp);
365 return (*kluge_iput)(ip, vfsp);
368 commit(n, i0, i1, i2)
369 struct inode *i0, *i1, *i2; {
371 return (*kluge_commit)(n, i0, i1, i2);
376 fs_simple_lock(void *lp, int type) {
377 return (*kluge_fsSimpleLock)(lp, type);
380 fs_simple_unlock(void *lp, int type) {
381 return (*kluge_fsSimpleUnlock)(lp, type);
384 fs_read_lock(complex_lock_t lp, int type) {
385 return (*kluge_fsReadLock)(lp, type);
388 fs_write_lock(complex_lock_t lp, int type) {
389 return (*kluge_fsWriteLock)(lp, type);
392 fs_complex_unlock(complex_lock_t lp, int type) {
393 return (*kluge_fsCxUnlock)(lp, type);