![]() |
![]() |
![]() |
libudev Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
struct udev_monitor; struct udev_monitor * udev_monitor_ref (struct udev_monitor *udev_monitor
); struct udev_monitor * udev_monitor_unref (struct udev_monitor *udev_monitor
); struct udev * udev_monitor_get_udev (struct udev_monitor *udev_monitor
); struct udev_monitor * udev_monitor_new_from_netlink (struct udev *udev
,const char *name
); int udev_monitor_enable_receiving (struct udev_monitor *udev_monitor
); int udev_monitor_set_receive_buffer_size (struct udev_monitor *udev_monitor
,int size
); int udev_monitor_get_fd (struct udev_monitor *udev_monitor
); struct udev_device * udev_monitor_receive_device (struct udev_monitor *udev_monitor
); int udev_monitor_filter_add_match_subsystem_devtype (struct udev_monitor *udev_monitor
,const char *subsystem
,const char *devtype
); int udev_monitor_filter_add_match_tag (struct udev_monitor *udev_monitor
,const char *tag
); int udev_monitor_filter_update (struct udev_monitor *udev_monitor
); int udev_monitor_filter_remove (struct udev_monitor *udev_monitor
);
struct udev_monitor * udev_monitor_ref (struct udev_monitor *udev_monitor
);
Take a reference of a udev monitor.
|
udev monitor |
Returns : |
the passed udev monitor |
struct udev_monitor * udev_monitor_unref (struct udev_monitor *udev_monitor
);
Drop a reference of a udev monitor. If the refcount reaches zero, the bound socket will be closed, and the resources of the monitor will be released.
|
udev monitor |
Returns : |
NULL |
struct udev * udev_monitor_get_udev (struct udev_monitor *udev_monitor
);
Retrieve the udev library context the monitor was created with.
|
udev monitor |
Returns : |
the udev library context |
struct udev_monitor * udev_monitor_new_from_netlink (struct udev *udev
,const char *name
);
Create new udev monitor and connect to a specified event source. Valid sources identifiers are "udev" and "kernel".
Applications should usually not connect directly to the "kernel" events, because the devices might not be useable at that time, before udev has configured them, and created device nodes. Accessing devices at the same time as udev, might result in unpredictable behavior. The "udev" events are sent out after udev has finished its event processing, all rules have been processed, and needed device nodes are created.
The initial refcount is 1, and needs to be decremented to release the resources of the udev monitor.
|
udev library context |
|
name of event source |
Returns : |
a new udev monitor, or NULL, in case of an error |
int udev_monitor_enable_receiving (struct udev_monitor *udev_monitor
);
Binds the udev_monitor
socket to the event source.
|
the monitor which should receive events |
Returns : |
0 on success, otherwise a negative error value. |
int udev_monitor_set_receive_buffer_size (struct udev_monitor *udev_monitor
,int size
);
Set the size of the kernel socket buffer. This call needs the appropriate privileges to succeed.
|
the monitor which should receive events |
|
the size in bytes |
Returns : |
0 on success, otherwise -1 on error. |
int udev_monitor_get_fd (struct udev_monitor *udev_monitor
);
Retrieve the socket file descriptor associated with the monitor.
|
udev monitor |
Returns : |
the socket file descriptor |
struct udev_device * udev_monitor_receive_device (struct udev_monitor *udev_monitor
);
Receive data from the udev monitor socket, allocate a new udev device, fill in the received data, and return the device.
Only socket connections with uid=0 are accepted.
The monitor socket is by default set to NONBLOCK. A variant of poll()
on
the file descriptor returned by udev_monitor_get_fd()
should to be used to
wake up when new devices arrive, or alternatively the file descriptor
switched into blocking mode.
The initial refcount is 1, and needs to be decremented to release the resources of the udev device.
|
udev monitor |
Returns : |
a new udev device, or NULL, in case of an error |
int udev_monitor_filter_add_match_subsystem_devtype (struct udev_monitor *udev_monitor
,const char *subsystem
,const char *devtype
);
This filter is efficiently executed inside the kernel, and libudev subscribers will usually not be woken up for devices which do not match.
The filter must be installed before the monitor is switched to listening mode.
|
the monitor |
|
the subsystem value to match the incoming devices against |
|
the devtype value to match the incoming devices against |
Returns : |
0 on success, otherwise a negative error value. |
int udev_monitor_filter_add_match_tag (struct udev_monitor *udev_monitor
,const char *tag
);
This filter is efficiently executed inside the kernel, and libudev subscribers will usually not be woken up for devices which do not match.
The filter must be installed before the monitor is switched to listening mode.
|
the monitor |
|
the name of a tag |
Returns : |
0 on success, otherwise a negative error value. |
int udev_monitor_filter_update (struct udev_monitor *udev_monitor
);
Update the installed socket filter. This is only needed, if the filter was removed or changed.
|
monitor |
Returns : |
0 on success, otherwise a negative error value. |