Search notes:

include/linux/kobject.h

struct kobject

A kobject controls access to a domain-specific object.
In object-oriented speach, a kobject is an abstract base class that specifies some capabilities which are then used by concrete users of these capabilities.
struct kobject {

  const        char             *name;
        struct list_head         entry;
        struct kobject          *parent;
        struct kset             *kset;
  const struct kobj_type        *ktype;
        struct kernfs_node      *sd;       /* sysfs directory entry */
        struct kref              kref;

#ifdef CONFIG_DEBUG_KOBJECT_RELEASE
        struct delayed_work     release;
#endif

        unsigned int state_initialized:1;
        unsigned int state_in_sysfs:1;
        unsigned int state_add_uevent_sent:1;
        unsigned int state_remove_uevent_sent:1;
        unsigned int uevent_suppress:1;
};
See also struct device.

struct kobj_type (ktype)

The kobj_type (ktype) describes the type of an object that embeds a kobject.
struct kobj_type {
               void                    (*release)(struct kobject *kobj);
  const struct sysfs_ops               *sysfs_ops;
  const struct attribute_group        **default_groups;
  const struct kobj_ns_type_operations *(*child_ns_type)(const struct kobject *kobj);
  const void                           *(*namespace)(const struct kobject *kobj);
        void                          (*get_ownership)(const struct kobject *kobj, kuid_t *uid, kgid_t *gid);
};

struct kset

A kset is a list of kobject (whose type does not necessarily need to be equal for all members).
ksets are used to define the attribute callbacks and other common events that happen to a kobject.
Each directory in In sysfs directory that contains other directories usually corresponds to a kobject of the same kset.
struct kset {
        struct list_head        list;      /* The list                                   */
               spinlock_t       list_lock; /* Lock for iterating over the kobjects       */
        struct kobject          kobj;      /* The embedded kobect for this kset          */
  const struct kset_uevent_ops *uevent_ops;/* The set of uevent operations for this kset */
} __randomize_layout;
The operations in kset_uevent_ops are called whenever a kobject has something happen to it so that the kset can add new environment variables or filter out the uevents if so desired.

struct kset_uevent_ops

struct kset_uevent_ops {
       int   (* const filter)(const struct kobject *kobj);
 const char *(* const name  )(const struct kobject *kobj);
       int   (* const uevent)(const struct kobject *kobj, struct kobj_uevent_env *env);
};

enum kobject_action

enum kobject_action {
	KOBJ_ADD,
	KOBJ_REMOVE,
	KOBJ_CHANGE,
	KOBJ_MOVE,
	KOBJ_ONLINE,
	KOBJ_OFFLINE,
	KOBJ_BIND,
	KOBJ_UNBIND,
};
The enumerated actions must match the index to the string array in lib/kobject_uevent.c.

See also

kobject

Links

https://github.com/torvalds/linux/blob/master/include/linux/kobject.h

Index