Support KLD. We register and unregister two modules. "coda" (the vfs)

via VFS_SET(), and "codadev" for the cdevsw entry.  From kldstat -v:
 3    1 0xf02c5000 115d8    coda.ko
        Contains modules:
                Id Name
                 2 codadev
                 3 coda
This commit is contained in:
Peter Wemm 1998-11-03 08:55:06 +00:00
parent cd8ab93c90
commit 7b91328a39
4 changed files with 130 additions and 88 deletions

View File

@ -27,7 +27,7 @@
* Mellon the rights to redistribute these changes without encumbrance.
*
* @(#) src/sys/coda/coda_fbsd.cr,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
* $Id: coda_fbsd.c,v 1.6 1998/09/28 20:52:57 rvb Exp $
* $Id: coda_fbsd.c,v 1.7 1998/09/29 20:19:45 rvb Exp $
*
*/
@ -84,59 +84,62 @@ static struct cdevsw codadevsw =
vc_nb_poll, nommap, NULL, "Coda", NULL, -1
};
void vcattach __P((void));
static dev_t codadev;
int vcdebug = 1;
#define VCDEBUG if (vcdebug) printf
void
vcattach(void)
{
/*
* In case we are an LKM, set up device switch.
*/
if (0 == (codadev = makedev(VC_DEV_NO, 0)))
VCDEBUG("makedev returned null\n");
else
VCDEBUG("makedev OK.\n");
cdevsw_add(&codadev, &codadevsw, NULL);
VCDEBUG("coda: codadevsw entry installed at %d.\n", major(codadev));
}
#if !defined(VFS_LKM) || defined(VFS_KLD)
static vc_devsw_installed = 0;
static void vc_drvinit __P((void *unused));
static void
vc_drvinit(void *unused)
static int
codadev_modevent(module_t mod, modeventtype_t type, void *data)
{
dev_t dev;
#ifdef DEVFS
int i;
#endif
static struct cdevsw *oldcdevsw;
if( ! vc_devsw_installed ) {
switch (type) {
case MOD_LOAD:
dev = makedev(VC_DEV_NO, 0);
cdevsw_add(&dev,&codadevsw, NULL);
vc_devsw_installed = 1;
}
cdevsw_add(&dev,&codadevsw, &oldcdevsw);
#ifdef DEVFS
/* tmp */
/* tmp */
#undef NVCODA
#define NVCODA 1
for (i = 0; i < NVCODA; i++) {
cfs_devfs_token[i] =
devfs_add_devswf(&codadevsw, i,
DV_CHR, UID_ROOT, GID_WHEEL, 0666,
"cfs%d", i);
coda_devfs_token[i] =
devfs_add_devswf(&codadevsw, i,
DV_CHR, UID_ROOT, GID_WHEEL, 0666,
"coda%d", i);
}
for (i = 0; i < NVCODA; i++) {
cfs_devfs_token[i] =
devfs_add_devswf(&codadevsw, i,
DV_CHR, UID_ROOT, GID_WHEEL, 0666,
"cfs%d", i);
coda_devfs_token[i] =
devfs_add_devswf(&codadevsw, i,
DV_CHR, UID_ROOT, GID_WHEEL, 0666,
"coda%d", i);
}
#endif
break;
case MOD_UNLOAD:
#ifdef DEVFS
for (i = 0; i < NVCODA; i++) {
devfs_remove_dev(cfs_devfs_token[i]);
devfs_remove_dev(coda_devfs_token[i]);
}
#endif
cdevsw_add(&dev, oldcdevsw, NULL);
break;
default:
break;
}
return 0;
}
static moduledata_t codadev_mod = {
"codadev",
codadev_modevent,
NULL
};
DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+VC_DEV_NO);
#endif
int
coda_fbsd_getpages(v)
@ -220,14 +223,26 @@ coda_fbsd_putpages(v)
ap->a_sync, ap->a_rtvals);
}
SYSINIT(codadev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+VC_DEV_NO,vc_drvinit,NULL)
#ifdef VFS_LKM
#if defined(VFS_LKM) && !defined(VFS_KLD)
#include <sys/mount.h>
#include <sys/lkm.h>
void vcattach __P((void));
static dev_t codadev;
void
vcattach(void)
{
if (0 == (codadev = makedev(VC_DEV_NO, 0)))
VCDEBUG("makedev returned null\n");
else
VCDEBUG("makedev OK.\n");
cdevsw_add(&codadev, &codadevsw, NULL);
VCDEBUG("coda: codadevsw entry installed at %d.\n", major(codadev));
}
extern struct vfsops coda_vfsops;
static struct vfsconf _fs_vfsconf = { &coda_vfsops, "coda", -1, 0, 0 };

View File

@ -27,7 +27,7 @@
* Mellon the rights to redistribute these changes without encumbrance.
*
* @(#) src/sys/cfs/coda_vfsops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
* $Id: coda_vfsops.c,v 1.6 1998/09/25 17:38:32 rvb Exp $
* $Id: coda_vfsops.c,v 1.7 1998/09/29 20:19:45 rvb Exp $
*
*/
@ -47,6 +47,11 @@
/*
* HISTORY
* $Log: coda_vfsops.c,v $
* Revision 1.7 1998/09/29 20:19:45 rvb
* Fixes for lkm:
* 1. use VFS_LKM vs ACTUALLY_LKM_NOT_KERNEL
* 2. don't pass -DCODA to lkm build
*
* Revision 1.6 1998/09/25 17:38:32 rvb
* Put "stray" printouts under DIAGNOSTIC. Make everything build
* with DEBUG on. Add support for lkm. (The macro's don't work
@ -739,10 +744,11 @@ struct vfsops coda_vfsops = {
coda_init,
};
#ifdef VFS_LKM
#if defined(VFS_LKM) && !defined(VFS_KLD)
/*
* This case is being handled in coda_fbsd.c
* What we want is too hairy for VFS_SET to get right!
* XXX but VFS_KLD does it in VFS_SET..
*/
#else
VFS_SET(coda_vfsops, coda, VFCF_NETWORK);

View File

@ -27,7 +27,7 @@
* Mellon the rights to redistribute these changes without encumbrance.
*
* @(#) src/sys/coda/coda_fbsd.cr,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
* $Id: coda_fbsd.c,v 1.6 1998/09/28 20:52:57 rvb Exp $
* $Id: coda_fbsd.c,v 1.7 1998/09/29 20:19:45 rvb Exp $
*
*/
@ -84,59 +84,62 @@ static struct cdevsw codadevsw =
vc_nb_poll, nommap, NULL, "Coda", NULL, -1
};
void vcattach __P((void));
static dev_t codadev;
int vcdebug = 1;
#define VCDEBUG if (vcdebug) printf
void
vcattach(void)
{
/*
* In case we are an LKM, set up device switch.
*/
if (0 == (codadev = makedev(VC_DEV_NO, 0)))
VCDEBUG("makedev returned null\n");
else
VCDEBUG("makedev OK.\n");
cdevsw_add(&codadev, &codadevsw, NULL);
VCDEBUG("coda: codadevsw entry installed at %d.\n", major(codadev));
}
#if !defined(VFS_LKM) || defined(VFS_KLD)
static vc_devsw_installed = 0;
static void vc_drvinit __P((void *unused));
static void
vc_drvinit(void *unused)
static int
codadev_modevent(module_t mod, modeventtype_t type, void *data)
{
dev_t dev;
#ifdef DEVFS
int i;
#endif
static struct cdevsw *oldcdevsw;
if( ! vc_devsw_installed ) {
switch (type) {
case MOD_LOAD:
dev = makedev(VC_DEV_NO, 0);
cdevsw_add(&dev,&codadevsw, NULL);
vc_devsw_installed = 1;
}
cdevsw_add(&dev,&codadevsw, &oldcdevsw);
#ifdef DEVFS
/* tmp */
/* tmp */
#undef NVCODA
#define NVCODA 1
for (i = 0; i < NVCODA; i++) {
cfs_devfs_token[i] =
devfs_add_devswf(&codadevsw, i,
DV_CHR, UID_ROOT, GID_WHEEL, 0666,
"cfs%d", i);
coda_devfs_token[i] =
devfs_add_devswf(&codadevsw, i,
DV_CHR, UID_ROOT, GID_WHEEL, 0666,
"coda%d", i);
}
for (i = 0; i < NVCODA; i++) {
cfs_devfs_token[i] =
devfs_add_devswf(&codadevsw, i,
DV_CHR, UID_ROOT, GID_WHEEL, 0666,
"cfs%d", i);
coda_devfs_token[i] =
devfs_add_devswf(&codadevsw, i,
DV_CHR, UID_ROOT, GID_WHEEL, 0666,
"coda%d", i);
}
#endif
break;
case MOD_UNLOAD:
#ifdef DEVFS
for (i = 0; i < NVCODA; i++) {
devfs_remove_dev(cfs_devfs_token[i]);
devfs_remove_dev(coda_devfs_token[i]);
}
#endif
cdevsw_add(&dev, oldcdevsw, NULL);
break;
default:
break;
}
return 0;
}
static moduledata_t codadev_mod = {
"codadev",
codadev_modevent,
NULL
};
DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+VC_DEV_NO);
#endif
int
coda_fbsd_getpages(v)
@ -220,14 +223,26 @@ coda_fbsd_putpages(v)
ap->a_sync, ap->a_rtvals);
}
SYSINIT(codadev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+VC_DEV_NO,vc_drvinit,NULL)
#ifdef VFS_LKM
#if defined(VFS_LKM) && !defined(VFS_KLD)
#include <sys/mount.h>
#include <sys/lkm.h>
void vcattach __P((void));
static dev_t codadev;
void
vcattach(void)
{
if (0 == (codadev = makedev(VC_DEV_NO, 0)))
VCDEBUG("makedev returned null\n");
else
VCDEBUG("makedev OK.\n");
cdevsw_add(&codadev, &codadevsw, NULL);
VCDEBUG("coda: codadevsw entry installed at %d.\n", major(codadev));
}
extern struct vfsops coda_vfsops;
static struct vfsconf _fs_vfsconf = { &coda_vfsops, "coda", -1, 0, 0 };

View File

@ -27,7 +27,7 @@
* Mellon the rights to redistribute these changes without encumbrance.
*
* @(#) src/sys/cfs/coda_vfsops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
* $Id: coda_vfsops.c,v 1.6 1998/09/25 17:38:32 rvb Exp $
* $Id: coda_vfsops.c,v 1.7 1998/09/29 20:19:45 rvb Exp $
*
*/
@ -47,6 +47,11 @@
/*
* HISTORY
* $Log: coda_vfsops.c,v $
* Revision 1.7 1998/09/29 20:19:45 rvb
* Fixes for lkm:
* 1. use VFS_LKM vs ACTUALLY_LKM_NOT_KERNEL
* 2. don't pass -DCODA to lkm build
*
* Revision 1.6 1998/09/25 17:38:32 rvb
* Put "stray" printouts under DIAGNOSTIC. Make everything build
* with DEBUG on. Add support for lkm. (The macro's don't work
@ -739,10 +744,11 @@ struct vfsops coda_vfsops = {
coda_init,
};
#ifdef VFS_LKM
#if defined(VFS_LKM) && !defined(VFS_KLD)
/*
* This case is being handled in coda_fbsd.c
* What we want is too hairy for VFS_SET to get right!
* XXX but VFS_KLD does it in VFS_SET..
*/
#else
VFS_SET(coda_vfsops, coda, VFCF_NETWORK);