kldinfo utility parses ELF header of a given KLD module file, then searches for
available Kernel Loadable objects and shows their dependency and version
information. If path to file is given the utility tries to open it directly.
It quits if open fails. Otherwise, it searches for .ko in directories set by
kern.module_path sysctl variable. Can be used to show builtin modules in kernel.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 78050 Build 74933: arc lint + arc unit
Event Timeline
The kldstat works with modules loaded into kernel memory, it finds module by its name and prints what module_stat has (id, refs, and a pointer to modspecific_t). It does not print version information and dependencies.
The proposed kldinfo works with files: it parses ELF, searches for KObjs, extracts their dependency and version info and fine-prints what it finds. Note, that one module file may have many KObjs those also may have deps on other modules. Extracting such info from module is not easy, one has to write a script that juggles other tools like nm, objdump, hexdump. Thus, kldinfo is that script written in pure C that does it on its own. ;) No sorting is currently implemented.
To illustrate:
% kldinfo amdgpio MODULE: amdgpio_acpi DEPENDS: kernel VERSION: 1501000 1501000 1501000 MODULE: amdgpio DEPENDS: acpi VERSION: 1 1 1 MODULE: amdgpio DEPENDS: gpiobus VERSION: 1 1 1 Found 3 dependencies in file /boot/kernel/amdgpio.ko
Calling on kernel file will print all modules built-in into that particular kernel:
% kldinfo /boot/kernel/kernel MODULE: xpt DEPENDS: kernel VERSION: 1501000 1501000 1599999 MODULE: xpt DEPENDS: cam VERSION: 1 1 1 MODULE: cam DEPENDS: kernel VERSION: 1501000 1501000 1599999 MODULE: aprobe DEPENDS: kernel VERSION: 1501000 1501000 1599999 MODULE: aprobe DEPENDS: cam VERSION: 1 1 1 ... MODULE: ixl DEPENDS: iflib VERSION: 1 1 1 MODULE: smartpqi_pci DEPENDS: kernel VERSION: 1501000 1501000 1599999 MODULE: smartpqi DEPENDS: pci VERSION: 1 1 1 MODULE: x86bios DEPENDS: kernel VERSION: 1501000 1501000 1599999 MODULE: ioapic_pci DEPENDS: kernel VERSION: 1501000 1501000 1599999 MODULE: apic_nexus DEPENDS: kernel VERSION: 1501000 1501000 1599999 Found 926 dependencies in file /boot/kernel/kernel
Also, FreeBSD module has three version values: min, preferred and max. All three are printed.
Generally, I like this.
If there's demand, we can add pnp info as well, but that's harder to format and should be separate form this commit.
I'll investigate what it takes to extract and fine-print MODULE_PNP_INFO. Will provide a separate patch if something comes out of my keyboard.
I only looked at the single function.
Please ensure that the sources are in KNF, see style(9). Then I will read it more.
| sbin/kldinfo/kldinfo.c | ||
|---|---|---|
| 46 | Why this var is not bool? | |
| 59 | Indent is wrong. Previous line can be filled more. | |
| 63 | There must be a blank line between var declarations and statements. | |
| 64 | Why is this not just str(n)cpy? | |
| 66 | Why there is so many blank lines in the bodies? They do not serve any purpose. | |
| 68 | Why new line is only printed for verbose mode? | |