October 2017
Intermediate to advanced
586 pages
14h 8m
English
So far, we have seen how to individually add attributes and call (directly or indirectly through a wrapper function such as device_create_file(), class_create_file(), and so on) sysfs_create_file() on each of them. Why bother with multiple calls if we can do it once? Here is where the attribute group comes in. It relies on the struct attribute_group structure:
struct attribute_group {
struct attribute **attrs;
};
Of course, we have removed fields that are not of interest. The attrs field is a pointer to a NULL-terminated list of attributes. Each attribute group must be given a pointer to a list/array of struct attribute elements. The group is just a helper wrapper that makes it easier to manage multiple attributes.
Read now
Unlock full access