[openbeos] Re: driver/module shutdown notification for R1

  • From: "Waldemar Kornewald" <Waldemar.Kornewald@xxxxxx>
  • To: <openbeos@xxxxxxxxxxxxx>
  • Date: Sat, 14 Jun 2003 15:16:53 +0200

> >Actually, this should be no problem.
> >We add the ioctl and std_ops action B_UNLOAD_ON_SHUTDOWN.
> >When the system is shut down the kernel calls
> >
> >if(ioctl(fd,B_UNLOAD_ON_SHUTDOWN...) == B_OK)
> >    unload_driver(fd);
> >
> >and
> >
> >if(module->std_ops(B_UNLOAD_ON_SHUTDOWN) == B_OK)
> >    unload_module(module);
> >
> >for each module and driver that is loaded.
> >
> >Drivers/modules that do not support this automatically return B_ERROR or
> >something like that.
> >The same goes for drivers/modules that do not need this behaviour. They
just
> >do not implement it and the switch-case part in the driver will fall
through
> >and return B_ERROR.
> >
> >Why should we need an additional call for driver/modules if we can use
the
> >current API without any problems?
> >The advantage is that old drivers will still work and can be adapted
without
> >much work (just add a new "case" statement).
> >
> >Waldemar
> >
> >
> >
> Isn't the 'uninit_driver()' function meant for this purpose? The BeBook
> says it's called when unloading the driver ...

Good point. :))

Still, how do modules know that the system is shutting down?
This was actually the source of my problem. PPP is a module in BONE (and
will be a module in OBOS, too). The PPP module must disconnect before the
system is shut down.
I could write some application for that task and execute it in the shutdown
script, but when we go embedded (OBIA ;) it will be better to have this in
the kernel itself. And it is better not to rely upon scripts for jobs that
could be done automatically. This would be the next step to a terrible
Linux-I-script-everything-please-edit-me-with-a-text-editor-super-duper-comp
licated-world! ;)

Waldemar


Other related posts: