11

On a running Linux system, I want to know which device driver module created a particular sysfs entry. Is it possible to know? I know I can grep for relevant strings in the kernel source and try to identify. But, is there a way without doing that?

Santhosh N
  • 157
  • 10

1 Answers1

2

You can find which driver has created a sysfs entry by going through its source. If the driver uses device_create_file()/device_remove_file() in its init/exit sequences respectively then you can be sure a sysfs attribute file has been created by the driver. You can also find DEVICE_ATTR(_name, _mode, _show, _store) macro in the source to find out what functionality is provided by the sysfs file. Usually you can either cat the file or echo a string to it. A cat /sys/.../file, will correspond to the _show function and an echo /sys/.../file will correspond to the _store function mentioned in the macro.

spitfire88
  • 1,596
  • 3
  • 19
  • 31
  • 1
    Thanks sanrio for the reply. I knew about the thing you have mentioned. My question is, given a sysfs entry, is it possible to tell to which driver module(if listed by lsmod) it belongs to on a running Linux system. – Santhosh N Oct 26 '12 at 04:42
  • i doubt there is a direct way to do that.. If you do come across one then please share it here :) – spitfire88 Nov 06 '12 at 11:42