/*所有事件的名称列表*/
static const char *kobject_actions[] = {
[KOBJ_ADD] = "add",
[KOBJ_REMOVE] = "remove",
[KOBJ_CHANGE] = "change",
[KOBJ_MOVE] = "move",
[KOBJ_ONLINE] = "online",
[KOBJ_OFFLINE] = "offline",
};
/*用于事件处理的函数列表*/
struct kset_uevent_ops {
/*事件过滤器,返回0表示不用向用户空间报告事件*/
int (* const filter)(struct kset *kset, struct kobject *kobj);
/*返回子系统的名字*/
const char *(* const name)(struct kset *kset, struct kobject *kobj);
/*添加子系统特有的环境变量*/
int (* const uevent)(struct kset *kset, struct kobject *kobj,
struct kobj_uevent_env *env);
}
/*内核表示的环境*/
struct kobj_uevent_env {
//环境变量/值数组
char *envp[UEVENT_NUM_ENVP];
//当前环境变量值索引
int envp_idx;
//环境数据缓冲区
char buf[UEVENT_BUFFER_SIZE];
//环境数据缓冲区的长度
int buflen;
};
/**
* kobject_uevent_env - send an uevent with environmental data
*
* @action: action that is happening
* @kobj: struct kobject that the action is happening to
* @envp_ext: pointer to environmental data
*
* Returns 0 if kobject_uevent() is completed with success or the
* corresponding error when it fails.
*/
int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
char *envp_ext[])
{
struct kobj_uevent_env *env;
//获得事件的名称
const cha
linux内核kobject事件处理详解
最新推荐文章于 2023-08-19 21:43:14 发布