Reputation: 2382
I am new to kernel programming and am working with sysfs in a kernel module. With reference to some sample codes at http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/samples/kobject/kobject-example.c and http://lxr.free-electrons.com/source/samples/kobject/kset-example.c I wrote a kernel module to create multiple kobjects with a common kset. But I wanted to know if it is possible to create a file/attribute within this kset.
The hierarchy i created is like this: /sys/my_module/----> this directory contains three other directories dir1, dir2, dir3
dir1, dir2, dir3 contains attributes or files file1, file2, file3 in each of them.
So my question is if i can create a file in /sys/my_module directory. I feel it is possible because i saw such an implementation in the /sys/kernel directory. Any suggestion will be of great help. I have searched a lot about creating attribute under a Kset but couldnt find a well documented material.
Thanks
Upvotes: 1
Views: 300
Reputation: 2382
ksets is not as I interpreted it. Actually it is a field/member in the struct kobject
which is used to link up multiple kojects. So it cannot have an attribute similar to a kobject. I implemented this hierarchy using sysctl
s.
Upvotes: 1