Reputation: 495
I need to create a whole bunch of attributes for a driver, which makes it impractical to allocate them statically (64 directories with 5 attributes each).
It looks like there are multiple ways to create directories in sysfs. One seems to be sysfs_create_dir_ns()
and the other seems to be creating struct kobject
s, add them to the sysfs and then add attributes to them.
Is there a recommended (or "best") way to do this?
Upvotes: 2
Views: 2129
Reputation: 495
One possible way, which at least works if you only have to create one level of subdirectories, is using a struct attribute_group
. This structure has a member name
which - if not NULL - will be used as a directory in which the attributes listed in the attribute group will be inserted.
This does not, however, allow multiple layers of directories, because you don't have matching kobject
s for the first level created by sysfs_create_group()
.
Upvotes: 2