On 13.02.2017 17:50, Simon Perfer wrote:
I've been working on a pet science project: building an initramfs with
only one file. Specifically, an executable written in Go.
The only thing I can't figure out is how to do a "modprobe" in Go
without actually having the modprobe utility. Is there a libkmod
library available? If not, how would I go about creating a wrapper for
the libkmod library? Never done this before.
Finally, if I'm relying on C libraries like libkmod does this preclude
me from creating a statically-compiled binary? Goal being, again, that
I am creating an initramfs with only a single file: the compiled Go
binary.
Thanks!
Hello Simon,
that definitely looks like a nice project. I like simplicity. Do share
when you feel ready.
I straced modprobe, and behind the scenes it just calls init_module().
So, it should be pretty simple to call from Go.
NAME
init_module, finit_module - load a kernel module
DESCRIPTION
init_module() loads an ELF image into kernel space, performs
any necessary symbol
relocations, initializes module parameters to values provided
by the caller, and then
runs the module's init function. This system call requires
privilege.
Hope it helps!
--
Zlatko
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.