Re: Callback function from kernel module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think you are looking for Upcall Functionality

upcall functionality allows a kernel module to invoke a function in user space. It is possible to start a program in user space, and give it some command line arguments, as well as setting environment variables.


**
int call_usermodehelper  (char * path, char ** argv, char ** envp, int wait);

Runs a user-space application. The application is started asynchronously if wait is not set, and runs as a child of keventd. (ie. it runs with full root capabilities).

Must be called from process context. Returns a negative error code if program was not execed successfully, or 0.

**man pages

Regards

Santosh




On Wed, Nov 7, 2012 at 8:30 PM, Bernd Petrovitsch <bernd@xxxxxxxxxxxxxxxxxxx> wrote:
Hi!

On Sam, 2012-11-03 at 19:14 +0530, Jeshwanth Kumar N K Jeshu wrote:
[...]
> Can I call userspace function from kernel module ? Actually I need to
> process some data in user space for every event occured in kernel module.

The usual way to implement this with a character device. The userspace
application opens the character device. It then read()s the events from
it, handles it and write()s results back (if needed).
The kernel part handles to IRQs, puts that into a buffer where it waits
for the read() from user space.

You can use netlink sockets for this which may save some code though or
implement a character device directly.

Kind regards,
        Bernd
--
Bernd Petrovitsch                  Email : bernd@xxxxxxxxxxxxxxxxxxx
                     LUGA : http://www.luga.at


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



--
Regards,
Santosh


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux