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"
40 #include "sys/limits.h"
41 #include "sys/types.h"
43 #include "sys/vnode.h"
45 #include "sys/errno.h"
46 #include "sys/device.h"
48 #include "sys/vmount.h"
52 #include "sys/priv.h" /* XXX */
53 #include "sys/lockl.h"
54 #include "sys/malloc.h"
55 #include <sys/syspest.h> /* to define the assert and ASSERT macros */
56 #include <sys/timer.h> /* For the timer related defines */
57 #include <sys/intr.h> /* for the serialization defines */
58 #include <sys/malloc.h> /* for the parameters to xmalloc() */
59 #include "afs/afs_osi.h" /* pick up osi_timeval_t for afs_stats.h */
60 #include "afs/afs_stats.h"
61 #include "../export.h"
64 #define KOFF_PRESENT 1
66 #define KOFF_PRESENT 0
77 extern struct gfs afs_gfs
;
78 extern struct vnodeops locked_afs_gn_vnodeops
;
86 #define AFS_CALLOUT_TBL_SIZE 256
88 #include <sys/lock_alloc.h>
89 extern Simple_lock afs_callout_lock
;
92 * afs_config - handle AFS configuration requests
95 * cmd - add/delete command
96 * uiop - uio vector describing any config params
102 extern struct vnodeops
*afs_ops
;
104 AFS_STATCNT(afs_config
);
108 if (cmd
== CFG_INIT
) { /* add AFS gfs */
110 * init any vrmix mandated kluges
112 if (err
= kluge_init())
115 * make sure that we pin everything
117 if (err
= pincode(afs_config
))
119 err
= gfsadd(AFS_MOUNT_AFS
, &afs_gfs
);
121 * ok, if already installed
126 pin(&afs_callout_lock
, sizeof(afs_callout_lock
));
127 lock_alloc(&afs_callout_lock
, LOCK_ALLOC_PIN
, 0, 5);
128 simple_lock_init(&afs_callout_lock
);
129 afs_ops
= &locked_afs_gn_vnodeops
;
130 timeoutcf(AFS_CALLOUT_TBL_SIZE
);
132 unpincode(afs_config
);
136 extern void *db_syms
[];
139 koff_addsyms(db_syms
, db_nsyms
);
141 } else if (cmd
== CFG_TERM
) { /* delete AFS gfs */
142 err
= gfsdel(AFS_MOUNT_AFS
);
144 * ok, if already deleted
148 #ifndef AFS_AIX51_ENV
153 if (err
= unpin(&afs_callout_lock
))
156 if (err
= unpincode(afs_config
))
159 timeoutcf(-AFS_CALLOUT_TBL_SIZE
);
161 } else /* unknown command */
166 if (!err
&& (cmd
== CFG_INIT
))
173 * The following stuff is (hopefully) temporary.
178 * mem_getbytes - memory allocator
180 * Seems we can't make up our mind what to call these
190 * mem_freebytes - memory deallocator
192 mem_freebytes(p
, size
)
228 * The following stuff is to account for the fact that stuff we need exported
229 * from the kernel isn't, so we must be devious.
232 int (*kluge_ufdalloc
) ();
233 int (*kluge_fpalloc
) ();
234 void *(*kluge_ufdfree
) ();
235 void *(*kluge_ffree
) ();
236 int (*kluge_iptovp
) ();
237 int (*kluge_dev_ialloc
) ();
238 int (*kluge_iget
) ();
239 int (*kluge_iput
) ();
240 int (*kluge_commit
) ();
241 void *(*kluge_ksettimer
) ();
242 void *(*kluge_fsSimpleLock
) ();
243 void *(*kluge_fsSimpleUnlock
) ();
244 void *(*kluge_fsReadLock
) ();
245 void *(*kluge_fsWriteLock
) ();
246 void *(*kluge_fsCxUnlock
) ();
249 * kernel function import list
252 struct k_func kfuncs
[] = {
253 {(void *(**)())&kluge_ufdalloc
, ".ufdalloc"},
254 {(void *(**)())&kluge_fpalloc
, ".fpalloc"},
255 {&kluge_ufdfree
, ".ufdfree"},
256 {&kluge_ffree
, ".ffree"},
257 {(void *(**)())&kluge_iptovp
, ".iptovp"},
258 {(void *(**)())&kluge_dev_ialloc
, ".dev_ialloc"},
259 {(void *(**)())&kluge_iget
, ".iget"},
260 {(void *(**)())&kluge_iput
, ".iput"},
261 {(void *(**)())&kluge_commit
, ".commit"},
262 {&kluge_ksettimer
, ".ksettimer"},
264 {&kluge_fsSimpleLock
, ".fs_simple_lock"},
265 {&kluge_fsSimpleUnlock
, ".fs_simple_unlock"},
266 {&kluge_fsReadLock
, ".fs_read_lock"},
267 {&kluge_fsWriteLock
, ".fs_write_lock"},
268 {&kluge_fsCxUnlock
, ".fs_complex_unlock"},
273 void *vnodefops
; /* dummy vnodeops */
275 Simple_lock jfs_icache_lock
;
276 Simple_lock proc_tbl_lock
;
279 * kernel variable import list
281 struct k_var kvars
[] = {
282 {(void *)&vnodefops
, "vnodefops"},
283 {(void *)&ifnet
, "ifnet"},
284 {(void *)&jfs_icache_lock
, "jfs_icache_lock"},
285 #ifndef AFS_AIX51_ENV
286 {(void *)&proc_tbl_lock
, "proc_tbl_lock"},
292 * kluge_init - initialise the kernel imports kluge
306 for (kf
= kfuncs
; !err
&& kf
->name
; ++kf
) {
307 err
= import_kfunc(kf
);
309 for (kv
= kvars
; !err
&& kv
->name
; ++kv
) {
310 err
= import_kvar(kv
, toc
);
320 return (*kluge_ufdalloc
) (i
, fdp
);
323 fpalloc(vp
, flag
, type
, ops
, fpp
)
329 return (*kluge_fpalloc
) (vp
, flag
, type
, ops
, fpp
);
336 (void)(*kluge_ufdfree
) (fd
);
344 (void)(*kluge_ffree
) (fp
);
347 iptovp(vfsp
, ip
, vpp
)
349 struct inode
*ip
, **vpp
;
352 return (*kluge_iptovp
) (vfsp
, ip
, vpp
);
355 dev_ialloc(pip
, ino
, mode
, vfsp
, ipp
)
363 return (*kluge_dev_ialloc
) (pip
, ino
, mode
, vfsp
, ipp
);
367 iget(dev
, ino
, ipp
, doscan
, vfsp
)
380 return (*kluge_iget
) (dev
, ino
, ipp
, (afs_size_t
) doscan
, vfsp
, &dummy
);
382 return (*kluge_iget
) (dev
, ino
, ipp
, doscan
, vfsp
);
390 return (*kluge_iput
) (ip
, vfsp
);
393 commit(n
, i0
, i1
, i2
)
394 struct inode
*i0
, *i1
, *i2
;
397 return (*kluge_commit
) (n
, i0
, i1
, i2
);
402 fs_simple_lock(void *lp
, int type
)
404 return (*kluge_fsSimpleLock
) (lp
, type
);
407 fs_simple_unlock(void *lp
, int type
)
409 return (*kluge_fsSimpleUnlock
) (lp
, type
);
412 fs_read_lock(complex_lock_t lp
, int type
)
414 return (*kluge_fsReadLock
) (lp
, type
);
417 fs_write_lock(complex_lock_t lp
, int type
)
419 return (*kluge_fsWriteLock
) (lp
, type
);
422 fs_complex_unlock(complex_lock_t lp
, int type
)
424 return (*kluge_fsCxUnlock
) (lp
, type
);