Thank you Zlatko.

I actually have no idea how to call init_module() from my Go program. Happy to 
do the legwork in figuring this out, but not even sure where to start.


Is there something I should Google to get my search started? What are the 
keywords I should look up to begin this process?


Would calling this function preclude me from compiling a static binary?

________________________________
From: golang-nuts@googlegroups.com <golang-nuts@googlegroups.com> on behalf of 
Zlatko Čalušić <zcalu...@bitsync.net>
Sent: Monday, February 13, 2017 1:06:54 PM
To: golang-nuts@googlegroups.com
Subject: Re: [go-nuts] two questions

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<mailto:golang-nuts+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

-- 
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.

Reply via email to