tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Dynamic modules




> Sent: Monday, May 04, 2015 at 11:39 AM
> From: "Paul Goyette" <paul%vps1.whooppee.com@localhost>
> To: "Kamil Rytarowski" <n54%gmx.com@localhost>
> Cc: tech-kern%netbsd.org@localhost
> Subject: Re: Dynamic modules
>
> On Mon, 4 May 2015, Kamil Rytarowski wrote:
> 
> 
> > 3. Is it possible to automatically create a device file in /dev from a
> >    module?
> 
> Not really, at least not from a loaded kernel module.
> 
I see.

> On the other hand, modules are also applicable to "rump" environments, 
> and you _can_ dynamically create the /dev entry (in a rump'd file 
> system, of course).  For an example, please have a look at
> 
>  	src/sys/rump/dev/lib/libsysmon/sysmon_component.c

Interesting note!

> 
> > 4. What is the best way to extract the major from devsw_attach call in
> >    case we let it to automatically generate the major? For now I'm
> >    using printf(9) and I'm checking dmesg(8). This gives me an output
> >    for mknod(8) with an appropriate value.
> 
> You could always create a sysctl and make the return values from 
> devsw_attach() available to user-land.
> 
> BTW, devsw_attach() doesn't "automatically generate the major".  It does 
> a lookup in the majors table.  If there is no entry in the table, you 
> get an error.
> 
> (At least, that's how I read that code.  If I've misinterpreted, I'd be 
> happy to have someone explain how it really works!)
> 

I see, so there is no good mechanism for something called by me automatic major pickup.

So my best try is to choose the major number and hard-code it in the module.

Thanks!


Home | Main Index | Thread Index | Old Index