GUDev Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
GUdevClient; GUdevClientClass; enum GUdevDeviceType; typedef GUdevDeviceNumber; GUdevClient * g_udev_client_new (const gchar * const *subsystems); GList * g_udev_client_query_by_subsystem (GUdevClient *client, const gchar *subsystem); GUdevDevice * g_udev_client_query_by_device_number (GUdevClient *client, GUdevDeviceType type, GUdevDeviceNumber number); GUdevDevice * g_udev_client_query_by_device_file (GUdevClient *client, const gchar *device_file); GUdevDevice * g_udev_client_query_by_sysfs_path (GUdevClient *client, const gchar *sysfs_path); GUdevDevice * g_udev_client_query_by_subsystem_and_name (GUdevClient *client, const gchar *subsystem, const gchar *name);
GUdevClient is used to query information about devices on a Linux system from the Linux kernel and the udev device manager.
Device information is retrieved from the kernel (through the
sysfs
filesystem) and the udev daemon (through a
tmpfs
filesystem) and presented through
GUdevDevice objects. This means that no blocking IO ever happens
(in both cases, we are essentially just reading data from kernel
memory) and as such there are no asynchronous versions of the
provided methods.
To get information about a device, use
g_udev_client_query_by_subsystem()
,
g_udev_client_query_by_device_number()
,
g_udev_client_query_by_device_file()
,
g_udev_client_query_by_sysfs_path()
or
g_udev_client_query_by_subsystem_and_name()
.
To listen to uevents, connect to the "uevent" signal.
typedef struct _GUdevClient GUdevClient;
The GUdevClient struct is opaque and should not be accessed directly.
typedef struct { GObjectClass parent_class; /* signals */ void (*uevent) (GUdevClient *client, const gchar *action, GUdevDevice *device); } GUdevClientClass;
Class structure for GUdevClient.
GObjectClass |
Parent class. |
Signal class handler for the "uevent" signal. |
typedef enum { G_UDEV_DEVICE_TYPE_NONE = 0, G_UDEV_DEVICE_TYPE_BLOCK = 'b', G_UDEV_DEVICE_TYPE_CHAR = 'c', } GUdevDeviceType;
Enumeration used to specify a the type of a device.
Corresponds to the standard dev_t type as defined by POSIX (Until bug 584517 is resolved this work-around is needed).
GUdevClient * g_udev_client_new (const gchar * const *subsystems);
Constructs a GUdevClient object that can be used to query information about devices. Connect to the "uevent" signal to listen for uevents.
|
A NULL terminated string array of subsystems to listen for uevents on, NULL to not listen on uevents at all, or an empty array to listen to uevents on all subsystems. See the documentation for the "subsystems" property for details on this parameter.. allow-none. |
Returns : |
A new GUdevClient object. Free with g_object_unref() .
|
GList * g_udev_client_query_by_subsystem (GUdevClient *client, const gchar *subsystem);
Gets all devices belonging to subsystem
.
|
A GUdevClient. |
|
The subsystem to get devices for or NULL to get all devices.. allow-none. |
Returns : |
A list of GUdevDevice objects. The caller should free the result by using g_object_unref() on each element in the list and then g_list_free() on the list.. element-type GUdevDevice. |
GUdevDevice * g_udev_client_query_by_device_number (GUdevClient *client, GUdevDeviceType type, GUdevDeviceNumber number);
Looks up a device for a type and device number.
|
A GUdevClient. |
|
A value from the GUdevDeviceType enumeration. |
|
A device number. |
Returns : |
A GUdevDevice object or NULL if the device was not found. Free with g_object_unref() .
|
GUdevDevice * g_udev_client_query_by_device_file (GUdevClient *client, const gchar *device_file);
Looks up a device for a device file.
|
A GUdevClient. |
|
A device file. |
Returns : |
A GUdevDevice object or NULL if the device was not found. Free with g_object_unref() .
|
GUdevDevice * g_udev_client_query_by_sysfs_path (GUdevClient *client, const gchar *sysfs_path);
Looks up a device for a sysfs path.
|
A GUdevClient. |
|
A sysfs path. |
Returns : |
A GUdevDevice object or NULL if the device was not found. Free with g_object_unref() .
|
GUdevDevice * g_udev_client_query_by_subsystem_and_name (GUdevClient *client, const gchar *subsystem, const gchar *name);
Looks up a device for a subsystem and name.
|
A GUdevClient. |
|
A subsystem name. |
|
The name of the device. |
Returns : |
A GUdevDevice object or NULL if the device was not found. Free with g_object_unref() .
|
"subsystems"
property"subsystems" GStrv* : Read / Write / Construct Only
The subsystems to listen for uevents on.
To listen for only a specific DEVTYPE for a given SUBSYSTEM, use "subsystem/devtype". For example, to only listen for uevents where SUBSYSTEM is usb and DEVTYPE is usb_interface, use "usb/usb_interface".
If this property is NULL
, then no events will be reported. If
it's the empty array, events from all subsystems will be
reported.
"uevent"
signalvoid user_function (GUdevClient *client, gchar *action, GUdevDevice *device, gpointer user_data) : Run Last
Emitted when client
receives an uevent.
|
The GUdevClient receiving the event. |
|
The action for the uevent e.g. "add", "remove", "change", "move", etc. |
|
Details about the GUdevDevice the event is for. |
|
user data set when the signal handler was connected. |