Subject: Re: LKM support for many filesystems as well as compat_freebsd
To: Jason Thorpe <>
From: Michael Graff <>
List: tech-kern
Date: 08/12/1996 22:48:09
Jason Thorpe <> writes:

> Anyhow, I thought one of the points of LKM'ing was to eliminate the #ifdefs?

As I said, this was a first try.  Consider it a proof of concept, not a
finished product.

> hmm... Perhaps the emul structure pointers should just always exist in 
> kern/exec_conf.c, always declared NULL.  In kern/exec_subr.c, a new 
> function, emul_init() could be implemented.  This function would fill in 
> the emulation struct pointers if the emulations were compiled in 
> statically.  It could be implemented something like:

That was my intent, btw.  Let me know when you wanna help  ;)

>  > One thing I don't know for certain is what happens if you try to unload
>  > freebsd when something is being run in freebsd emulation mode.  I suspect
>  > Bad Things.
> "Try it."  At the very least, the executable in question will probably 
> drop core.  :-)

Well, if suddenly the process's emulation points to random non-kernel space,
will it die 

> Cool ... err, what happens when you run out of room in the file system 
> switch table?  Also, when you load a file system, I assume that it places 
> itself into the appropriate place in the switch table?

Yes.  It looks through the vfssw table comparing names.  If it finds one,
it assumes it is already loaded and fails.  If it cannot find an entry,
it punts.  See kern/kern_lkm.c for more details.

> You'd have to just do the additional procedure to LKM'ing a syscall.  I 
> guess this entails just installing the appropriate function pointer into 
> the appropriate slot in the syscall switch table.

That's just the thing...  I know HOW to do it, and I know I CAN do it.
The thing is, the lkm interface needs to be redone to allow it without
calling the internal lkm routines directly.  _I_ have no problem doing
that, but it is a hack.

Also, I intend to add routines which will be called "before load" "after load"
"before unload" and "after unload".  The before cases are already
in the lkm "spec" but it is sometimes useful to have after cases as well.

Thanks for your comments.  Assistance is always appreciated, btw.  :)