Specifications
Loadable Modules
13-9
Screen 13-4 shows a sample wrapper for a file system module. Notice that this file system
module doesn't need to do any clean-up when it is unloaded, so its wrapper defines a NULL
_unload routine.
Screen 13-4. File System Module Wrapper Coding Example
Screen 13-5 shows a sample wrapper for a miscellaneous module. Notice that, once
loaded, this module wants to remain loaded, so its _unload routine always returns
EBUSY.
Screen 13-5. Miscellaneous Module Wrapper Coding Example
#include<sys/moddefs.h>
STATIC int s5_load(void);
MOD_FS_WRAPPER(s5, s5_load, NULL, “Loadable s5 FS Type”);
.
.
.
STATIC int
s5_load(void)
{
inoinit();
bzero((caddr_t)&s5fshead, sizeof(s5fshead));
s5fshead.f_freelist = &s5ifreelist;
s5fshead.f_inode_cleanup = s5_cleanup;
s5fshead.f_maxpages = 1;
s5fshead.f_isize = sizeof (struct inode);
s5fshead.f_max = ninode;
fs_ipoolinit(&s5fshead);
return 0;
}
#include<sys/moddefs.h>
STATICintclis_load(), clis_unload();
MOD_MISC_WRAPPER(clis, clis_load, clis_unload, “clist - character io”);
.
.
.
STATIC int
clis_load()
{
.
.
.
cinit();
return(0);
}
STATIC int
clis_unload()
{
/*
* This module can not be unloaded.
*/
return(EBUSY);
}