Use a once control to initialize the LKM subsystem on first open. Remove
the lkm_init() call from main().
This commit is contained in:
parent
64a43eb2f4
commit
6685f0f408
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: init_main.c,v 1.256 2005/11/25 20:01:38 thorpej Exp $ */
|
/* $NetBSD: init_main.c,v 1.257 2005/11/25 20:13:54 thorpej Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
|
* Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.256 2005/11/25 20:01:38 thorpej Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.257 2005/11/25 20:13:54 thorpej Exp $");
|
||||||
|
|
||||||
#include "opt_ipsec.h"
|
#include "opt_ipsec.h"
|
||||||
#include "opt_sysv.h"
|
#include "opt_sysv.h"
|
||||||
|
@ -264,11 +264,6 @@ main(void)
|
||||||
/* Initialize process and pgrp structures. */
|
/* Initialize process and pgrp structures. */
|
||||||
procinit();
|
procinit();
|
||||||
|
|
||||||
#ifdef LKM
|
|
||||||
/* Initialize the LKM system. */
|
|
||||||
lkm_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize signal-related data structures. */
|
/* Initialize signal-related data structures. */
|
||||||
signal_init();
|
signal_init();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_lkm.c,v 1.86 2005/04/12 14:13:16 hannken Exp $ */
|
/* $NetBSD: kern_lkm.c,v 1.87 2005/11/25 20:13:54 thorpej Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 Christopher G. Demetriou
|
* Copyright (c) 1994 Christopher G. Demetriou
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.86 2005/04/12 14:13:16 hannken Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.87 2005/11/25 20:13:54 thorpej Exp $");
|
||||||
|
|
||||||
#include "opt_ddb.h"
|
#include "opt_ddb.h"
|
||||||
#include "opt_malloclog.h"
|
#include "opt_malloclog.h"
|
||||||
|
@ -63,6 +63,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.86 2005/04/12 14:13:16 hannken Exp $"
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
#include <sys/ksyms.h>
|
#include <sys/ksyms.h>
|
||||||
#include <sys/device.h>
|
#include <sys/device.h>
|
||||||
|
#include <sys/once.h>
|
||||||
|
|
||||||
#include <sys/lkm.h>
|
#include <sys/lkm.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
@ -100,7 +101,8 @@ int lkmdebug = 0;
|
||||||
static int lkm_v = 0;
|
static int lkm_v = 0;
|
||||||
static int lkm_state = LKMS_IDLE;
|
static int lkm_state = LKMS_IDLE;
|
||||||
|
|
||||||
static TAILQ_HEAD(lkms_head, lkm_table) lkmods; /* table of loaded modules */
|
static TAILQ_HEAD(lkms_head, lkm_table) lkmods = /* table of loaded modules */
|
||||||
|
TAILQ_HEAD_INITIALIZER(lkmods);
|
||||||
static struct lkm_table *curp; /* global for in-progress ops */
|
static struct lkm_table *curp; /* global for in-progress ops */
|
||||||
|
|
||||||
static struct lkm_table *lkmlookup(int, char *, int, int *);
|
static struct lkm_table *lkmlookup(int, char *, int, int *);
|
||||||
|
@ -128,7 +130,9 @@ const struct cdevsw lkm_cdevsw = {
|
||||||
nostop, notty, nopoll, nommap, nokqfilter,
|
nostop, notty, nopoll, nommap, nokqfilter,
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static ONCE_DECL(lkm_init_once);
|
||||||
|
|
||||||
|
static void
|
||||||
lkm_init(void)
|
lkm_init(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -137,8 +141,6 @@ lkm_init(void)
|
||||||
*/
|
*/
|
||||||
if (lkm_map == NULL)
|
if (lkm_map == NULL)
|
||||||
lkm_map = kernel_map;
|
lkm_map = kernel_map;
|
||||||
|
|
||||||
TAILQ_INIT(&lkmods);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
|
@ -147,6 +149,8 @@ lkmopen(dev_t dev, int flag, int devtype, struct proc *p)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
RUN_ONCE(&lkm_init_once, lkm_init);
|
||||||
|
|
||||||
if (minor(dev) != 0)
|
if (minor(dev) != 0)
|
||||||
return (ENXIO); /* bad minor # */
|
return (ENXIO); /* bad minor # */
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: lkm.h,v 1.37 2005/02/03 19:20:01 perry Exp $ */
|
/* $NetBSD: lkm.h,v 1.38 2005/11/25 20:13:54 thorpej Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Header file used by loadable kernel modules and loadable kernel module
|
* Header file used by loadable kernel modules and loadable kernel module
|
||||||
|
@ -338,7 +338,6 @@ int lkmdispatch(struct lkm_table *, int);
|
||||||
LKM_DISPATCH(lkmtp, cmd, NULL, att, det, stat)
|
LKM_DISPATCH(lkmtp, cmd, NULL, att, det, stat)
|
||||||
|
|
||||||
extern struct vm_map *lkm_map;
|
extern struct vm_map *lkm_map;
|
||||||
void lkm_init(void);
|
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue