libudev Reference Manual | ||||
---|---|---|---|---|
Top | Description |
struct udev_device; struct udev_device * udev_device_ref (struct udev_device *udev_device); void udev_device_unref (struct udev_device *udev_device); struct udev * udev_device_get_udev (struct udev_device *udev_device); struct udev_device * udev_device_new_from_syspath (struct udev *udev, const char *syspath); struct udev_device * udev_device_new_from_devnum (struct udev *udev, char type, dev_t devnum); struct udev_device * udev_device_new_from_subsystem_sysname (struct udev *udev, const char *subsystem, const char *sysname); struct udev_device * udev_device_get_parent (struct udev_device *udev_device); struct udev_device * udev_device_get_parent_with_subsystem_devtype (struct udev_device *udev_device, const char *subsystem, const char *devtype); const char * udev_device_get_devpath (struct udev_device *udev_device); const char * udev_device_get_subsystem (struct udev_device *udev_device); const char * udev_device_get_devtype (struct udev_device *udev_device); const char * udev_device_get_syspath (struct udev_device *udev_device); const char * udev_device_get_sysname (struct udev_device *udev_device); const char * udev_device_get_sysnum (struct udev_device *udev_device); const char * udev_device_get_devnode (struct udev_device *udev_device); struct udev_list_entry * udev_device_get_devlinks_list_entry (struct udev_device *udev_device); struct udev_list_entry * udev_device_get_properties_list_entry (struct udev_device *udev_device); const char * udev_device_get_property_value (struct udev_device *udev_device, const char *key); const char * udev_device_get_driver (struct udev_device *udev_device); dev_t udev_device_get_devnum (struct udev_device *udev_device); const char * udev_device_get_action (struct udev_device *udev_device); const char * udev_device_get_sysattr_value (struct udev_device *udev_device, const char *sysattr);
Representation of kernel sys devices. Devices are uniquely identified by their syspath, every device has exactly one path in the kernel sys filesystem. Devices usually belong to a kernel subsystem, and and have a unique name inside that subsystem.
struct udev_device * udev_device_ref (struct udev_device *udev_device);
Take a reference of a udev device.
|
udev device |
Returns : |
the passed udev device |
void udev_device_unref (struct udev_device *udev_device);
Drop a reference of a udev device. If the refcount reaches zero, the resources of the device will be released.
|
udev device |
struct udev * udev_device_get_udev (struct udev_device *udev_device);
Retrieve the udev library context the device was created with.
|
udev device |
Returns : |
the udev library context |
struct udev_device * udev_device_new_from_syspath (struct udev *udev, const char *syspath);
Create new udev device, and fill in information from the sys device and the udev database entry. The syspath is the absolute path to the device, including the sys mount point.
The initial refcount is 1, and needs to be decremented to release the resources of the udev device.
|
udev library context |
|
sys device path including sys directory |
Returns : |
a new udev device, or NULL, if it does not exist |
struct udev_device * udev_device_new_from_devnum (struct udev *udev, char type, dev_t devnum);
Create new udev device, and fill in information from the sys device and the udev database entry. The device is looked up by its major/minor number. Character and block device numbers are not unique across the two types, they do not share the same range of numbers.
The initial refcount is 1, and needs to be decremented to release the resources of the udev device.
|
udev library context |
|
char or block device |
|
device major/minor number |
Returns : |
a new udev device, or NULL, if it does not exist |
struct udev_device * udev_device_new_from_subsystem_sysname (struct udev *udev, const char *subsystem, const char *sysname);
Create new udev device, and fill in information from the sys device and the udev database entry. The device is looked up by the subsystem and name string of the device, like "mem", "zero", or "block", "sda".
The initial refcount is 1, and needs to be decremented to release the resources of the udev device.
|
udev library context |
|
the subsystem of the device |
|
the name of the device |
Returns : |
a new udev device, or NULL, if it does not exist |
struct udev_device * udev_device_get_parent (struct udev_device *udev_device);
Find the next parent device, and fill in information from the sys device and the udev database entry.
The returned the device is not referenced. It is attached to the child device, and will be cleaned up when the child device is cleaned up.
It is not necessarily just the upper level directory, empty or not recognized sys directories are ignored.
It can be called as many times as needed, without caring about references.
|
the device to start searching from |
Returns : |
a new udev device, or NULL, if it no parent exist. |
struct udev_device * udev_device_get_parent_with_subsystem_devtype (struct udev_device *udev_device, const char *subsystem, const char *devtype);
Find the next parent device, with a matching subsystem and devtype value, and fill in information from the sys device and the udev database entry.
The returned the device is not referenced. It is attached to the child device, and will be cleaned up when the child device is cleaned up.
It can be called as many times as needed, without caring about references.
|
udev device to start searching from |
|
the subsystem of the device |
|
the type (DEVTYPE) of the device |
Returns : |
a new udev device, or NULL if no matching parent exists. |
const char * udev_device_get_devpath (struct udev_device *udev_device);
Retrieve the kernel devpath value of the udev device. The path does not contain the sys mount point, and starts with a '/'.
|
udev device |
Returns : |
the devpath of the udev device |
const char * udev_device_get_subsystem (struct udev_device *udev_device);
Retrieve the subsystem string of the udev device. The string does not contain any "/".
|
udev device |
Returns : |
the subsystem name of the udev device, or NULL if it can not be determined |
const char * udev_device_get_devtype (struct udev_device *udev_device);
Retrieve the devtype string of the udev device.
|
udev device |
Returns : |
the devtype name of the udev device, or NULL if it can not be determined |
const char * udev_device_get_syspath (struct udev_device *udev_device);
Retrieve the sys path of the udev device. The path is an absolute path and starts with the sys mount point.
|
udev device |
Returns : |
the sys path of the udev device |
const char * udev_device_get_sysname (struct udev_device *udev_device);
|
udev device |
Returns : |
the sys name of the device device |
const char * udev_device_get_sysnum (struct udev_device *udev_device);
|
udev device |
Returns : |
the trailing number of of the device name |
const char * udev_device_get_devnode (struct udev_device *udev_device);
Retrieve the device node file name belonging to the udev device. The path is an absolute path, and starts with the device directory.
|
udev device |
Returns : |
the device node file name of the udev device, or NULL if no device node exists |
struct udev_list_entry * udev_device_get_devlinks_list_entry (struct udev_device *udev_device);
Retrieve the list of device links pointing to the device file of
the udev device. The next list entry can be retrieved with
udev_list_entry_next()
, which returns NULL if no more entries exist.
The devlink path can be retrieved from the list entry by
udev_list_entry_get_name()
. The path is an absolute path, and starts with
the device directory.
|
udev device |
Returns : |
the first entry of the device node link list |
struct udev_list_entry * udev_device_get_properties_list_entry (struct udev_device *udev_device);
Retrieve the list of key/value device properties of the udev
device. The next list entry can be retrieved with udev_list_entry_next()
,
which returns NULL if no more entries exist. The property name
can be retrieved from the list entry by udev_list_get_name()
,
the property value by udev_list_get_value()
.
|
udev device |
Returns : |
the first entry of the property list |
const char * udev_device_get_property_value (struct udev_device *udev_device, const char *key);
|
udev device |
|
property name |
Returns : |
the value of a device property, or NULL if there is no such property. |
const char * udev_device_get_driver (struct udev_device *udev_device);
|
udev device |
Returns : |
the driver string, or NULL if there is no driver attached. |
dev_t udev_device_get_devnum (struct udev_device *udev_device);
This is only valid if the device was received through a monitor. Devices read from sys do not have a sequence number.
|
udev device |
Returns : |
the kernel event sequence number, or 0 if there is no sequence number available. |
const char * udev_device_get_action (struct udev_device *udev_device);
This is only valid if the device was received through a monitor. Devices read from sys do not have an action string. Usual actions are: add, remove, change, online, offline.
|
udev device |
Returns : |
the kernel action value, or NULL if there is no action value available. |
const char * udev_device_get_sysattr_value (struct udev_device *udev_device, const char *sysattr);
The retrieved value is cached in the device. Repeated calls will return the same value and not open the attribute again.
|
udev device |
|
attribute name |
Returns : |
the content of a sys attribute file, or NULL if there is no sys attribute value. |