Hi,
This might sound weird but here is what I am trying to do.
I have a library foo.so which has functions bar1() and bar2(). This library is at /usr/lib/
I have implemented a system call called sys_mysyscall(). Inside this call I have a socket server running using raw sockets to which a client can connect from another machine and pass some information. The information is the name of the function which it wants to run on this machine as a thread.
So when the system call gets the name of the function (say) bar1 from the client, it needs to create a thread based on the bar1() function in foo.so using clone().
Is it possible to access the foo.so which is in /usr/lib and load the function bar1() as a thread from within the system call?
Thanks,
- Gary
No. You need to load foo.so
No. You need to load foo.so ahead of time with an insmod command.
since when are libraries loaded with insmod?
Since when are libraries loaded with insmod?
using dlopen
I want to know if this would work instead.
Have a service that loads foo.so using dlopen() and then get the pointers to the functions using dlsym(). Then create a system calls sys_register_service() which would take the function pointer and a const char *name. The kernel would create a service table with the name and function pointer.
Have a kernel thread that implements a socket server using raw sockets and waits for client. Client connect and pass the name of the function that they want to invoke. The kernel thread looks at the service table and based on the name, gets the function pointer and creates a threads and runs it!
I understand that we can create kernel thread using the kernel_thread call but then there is also sys_clone() and the do_fork() that is used to create threads. How can I create a thread using the do_fork () based on the function pointer that I have now found?
thanks,
Gary