Is it possible to create a character device in a linux kernel module that starts off mod 666? Right now it's always 600 (owned by root), and I have to chmod it. I could create udev entries to resolve it, but I'ld really rather the module do it automagically.
Is it possible? I can't find any information in the cdev_init or cdev_add documentation on this.
You can do it by setting the dev_uevent
method in the class structure. In this method you have to set the DEVMODE
uevent variable. Here an example
static int my_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
{
add_uevent_var(env, "DEVMODE=%#o", 0440);
return 0;
}
static struct class my_class = {
.name = "myname",
.owner = THIS_MODULE,
.dev_uevent = my_dev_uevent,
[...]
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With