Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get kobject from current module

In Linux kernel, given a module how can I know is it's kobject?

Context: I am trying to do a sysfs_create_file(kobj,attr) in a kernel module. I have all the attribute stuff set up, but I want to add an attribute to the current module.

like image 287
kernelator Avatar asked Jun 05 '14 23:06

kernelator


1 Answers

ok after looking through module.h I found it.

struct kobject mod_kobj = (((struct module *)(THIS_MODULE))->mkobj).kobj;
like image 60
kernelator Avatar answered Oct 01 '22 21:10

kernelator