tech-kern archive

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

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.

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

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!)


-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index