Re: call insmod in C program



Hi,

On Apr 25, 7:11 pm, Josef Moellers <josef.moell...@fujitsu-
siemens.com> wrote:
mbm wrote:
Hi

I need to insert kernel modules from a C application , is it possible
to do that without calling system("insmod ..")

Definitely. All you need to do is to take the insmod source code and
copy it into your application.
Simple as that. Open Source.


Just compile your module at a source directory , and run the following
after compiling the following with gcc.

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
setuid(0);
system("/sbin/insmod /.../sourcedirectory/yourmodule.ko");
system("/sbin/rmmod yourmodule.ko");

return 0;

}

Thanks
Kartik


.



Relevant Pages

  • Re: return from main
    ... undertand the following lines (mentioned in n1124.pdf at page 13. ... int, a return from the ... The start-up code performs whatever processing is needed prior to calling main, such as setting up the argv array. ... However, recursive calls to mainare such a bizarre thing to do that you ordinarily wouldn't have any reason to use them, particular if you want to compile the same code in C++, where they are not allowed. ...
    (comp.lang.c)
  • Re: call insmod in C program
    ... to do that without calling system ... All you need to do is to take the insmod source code and ... compile it with GCC, get back to me in case of any errors. ...
    (comp.os.linux.development.system)
  • Re: Threads and garbage collection
    ... create a test framework which I *can* compile and run, ... I also strongly suggest that rather than calling Monitor.Enter/Exit ... GC.KeepAlive is pointless with Thread references. ... In short, it's all still very confused, with lots of locks which aren't ...
    (microsoft.public.dotnet.framework.performance)
  • Thanks : Re: How to get Code Segment Base Address in PM
    ... (there is a intruction reading eip on the x86:) ... and compile it with nasmw.exe myfile.asm -o myfileout.bin ... Then I copy that output of the NASM compiler in a string in the upper level language and call that assembler code by calling ...
    (comp.lang.asm.x86)
  • Re: gawk for windows: system() does not yield exit status
    ... *OR* my versions of gawk is calling an old command.com by default (which ... Ruby or Perl without problems. ... If you have a version of GAWK-for-Windows ... compiler/toolchain/library used in the compile. ...
    (comp.lang.awk)