How does linux kernel creates sysfs?
You should not use that kind of functions directly. You should also avoid the use of kobject
(unless you are touching the kernel core).
Usually, sysfs attribute are associated to the device
structure. So, when you register a device the sysfs attribute are created.
Take a look at the device
structure in device.h line 689. At the end of the structure you will find the following field
const struct attribute_group **groups;
You have to create your own attribute, insert them in an attribute group and assigns your groups to your device before invoking device_register()
If you follow the device_register()
function, you will see what it does to create the associated sysfs attribute
How do I make my kernel module's sysfs entry be owned by a non-root user?
Owner's and group's identifiers of a sysfs attribute are determined by the the kobject for which this attribute is created.
Specifically, it is get_ownership
field of the struct kobj_type
which may contain a callback for set owner's and group's identifiers. The field has following signature:
struct kobj_type {
...
void (*get_ownership)(struct kobject *kobj, kuid_t *uid, kgid_t *gid);
};
When the callback is called, both *uid
and *gid
contain 0 (which corresponds to the root user). The callback may set these output parameters to other values.
Related Topics
How to Ping Other Containers in a Docker Network Through Their Hostname
I Would Like to Store All Command-Line Arguments to a Bash Script into a Single Variable
Compilation Gcc 4.6.2 (Cannot Compute Suffix of Object Files)
Install Lisp on My Linux Machine
How to Stop Sed from Buffering
How to Print $ in Shell Script
Error While Installing Mongodb on Ubuntu 16.04
How to Redirect Entire Output of Spark-Submit to a File
Ldd Shows Varied Addresses on X86 Linux
What Is The Maximum Number of Subdirectories Allowed in Ext4
How to Check If One File Is Part of Other
Swift on Linux: Make Very First Step Work
How to Build for Linux 32-Bit with Go1.6.2
How to Handle Bash with Multiple Arguments for Multiple Options
Check for Existence of Wget/Curl