Invoking user-space applications from the kernel
Invoking specific kernel functions (system calls) is a natural part of application development on GNU/Linux. But what about going in the other direction, kernel space calling user space? It turns out that there are a number of applications for this feature that you likely use every day. For example, when the kernel finds a device for which a module needs to be loaded, how does this process occur? Dynamic module loading occurs from the kernel through the usermode-helper process.
Data structure that is used for the API is struct subprocess_info
.
1 | /linux/include/kmod.h |
Simple example from the reference:
1 | static int umh_test( void ) |
This code will executes /usr/bin/logger
executable file. It should be called from device driver, or another kernel space.
Simpler version of process creation is as follows.
1 | static int umh_test( void ) |
参考资料: