On Sat, Jun 17, 2006 at 03:18:11PM +0200, Attilio Rao wrote: > 2006/6/17, YONETANI Tomokazu <[EMAIL PROTECTED]>: > >Hello. > >If the event handler in a kernel module returns an error upon registration, > >isn't the module supposed to be removed from the kldstat's list? > > > >I wrote a simple kernel module(attached) which always returns EOPNOTSUPP > >for MOD_LOAD event. It adds two sysctl nodes debug.test and > >debug.test_int. > >Reading from or writing to debug.test calls test_sysctl_proc() function. > >When loaded, although module_register_init prints an error message, the > >modules sits there, and I can even set different values to debug.test. > > > >Is this an expected behavior? Do I need to do something special to > >unregister my kernel module when something went wrong? > > kldload(8) is a simply binary wrapper to kldload(2), which is supposed > to invoke kernel linker in order to load (and locate in memory) kld > symbols. It doesn't provide a real error-prone infrastructure, so it > is expected you binary is loaded in memory but its consistency is not > assured.
No, I'm not just talking about when the module is loaded by kldload(8), but it can be loaded from the boot loader too. While I understand your point, I'm still believe that there's a room for improvement. OK, here's another question: when a kernel file(*.ko) contains one or more modules and none of them have positive reference count after the call to linker_file_sysinit(), should that kernel file still remain loaded? I also thought about making SYSINIT callback return a (recoverable) error code, but that breaks driver API and it's something I want to avoid.
