Quantcast
Channel: Active questions tagged kernel-modules - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 1184

How do I check if a kobject exists?

$
0
0

I'm following this guide on sysfs: https://embetronicx.com/tutorials/linux/device-drivers/sysfs-in-linux-kernel/

If I use kobject_create_and_add to add a new kobject, the function will fail if the specified kobject already exists.

    struct kobject *kobj_ref = kobject_create_and_add("my_object",kernel_kobj); 

So I want to know how to get this kobject if it already exists, and create it otherwise.

I assumed that kobject_get would allow me to do this but it doesn't accept a name and a parent as its arguments in the same way kobject_create_and_add does, and I'm a little confused on how one would even use it.

struct kobject *kobject_get(struct kobject *kobj);

Viewing all articles
Browse latest Browse all 1184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>