udev - change event from udev_device_get_action

0

I am monitoring the events of all devices connected to the host. Linux has udev daemon , which listens to all the device specific events such as online, offline, add, remove and change.

I use a function provided by linux udev_device_get_action, which is used to get the events / actions on that device.

On my machine, I am continuously getting change events returned from this function in my code's variable. [It returns the character pointer]

I checked the linux code for function udev_device_get_action, it just returns the action from the udev device structure.

UDEV_EXPORT const char *udev_device_get_action(struct udev_device *udev_device)
{
        if (udev_device == NULL)
                return NULL;
        return udev_device->action;
}

So, how can i know, where exactly those change events are coming from ??

amitam

Posted 2015-10-06T03:58:54.913

Reputation: 1

Answers

1

uevents are generated by the kernel itself (that is, by kernel drivers).

udev receives them over netlink(7), using the family NETLINK_KOBJECT_UEVENT, group 1. It then adds various extra fields from rules & hwdb, and re-broadcasts the extended uevents to kobject-uevent group 2, where libudev finally receives them.

It is possible to trigger uevents manually (e.g. by writing "add" or "change" to a given device's /sys/…/uevent file), but that's usually not done, except when using "udevadm trigger".

user1686

Posted 2015-10-06T03:58:54.913

Reputation: 283 655

But what is the meaning of CHANGE_EVENTS which i am getting a lot from udevd..?

In my driver, i have taken care of ADD, REMOVE, ONLINE, OFFLINE events of UDEV for devices, but i am not getting purpose rather behaviour behind listening to CHANGE_EVENTS.

What is the cause for this and what would be use of it for any block-driver.? – amitam – 2016-01-04T07:05:38.043