Writing to eventfd from kernel module

后端 未结 3 1197
無奈伤痛
無奈伤痛 2020-12-24 08:45

I have created an eventfd instance in a userspace program using eventfd(). Is there a way in which I can pass some reference (a pointer to its struct or pid+fd pair) to this

3条回答
  •  鱼传尺愫
    2020-12-24 09:16

    Consult the kernel source here:

    http://lxr.free-electrons.com/source/fs/eventfd.c

    Basically, send your userspace file descriptor, as produced by eventfd(), to your module via ioctl() or some other path. From the kernel, call eventfd_ctx_fdget() to get an eventfd context, then eventfd_signal() on the resulting context. Don't forget eventfd_ctx_put() when you're done with the context.

提交回复
热议问题