2010-05-16 19:59:07 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-05-22 00:04:00 -07:00
|
|
|
#include <Eeze.h>
|
|
|
|
#include "eeze_private.h"
|
2010-05-16 19:59:07 -07:00
|
|
|
#include "eeze_udev_private.h"
|
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
extern _udev *udev;
|
2010-05-16 19:59:07 -07:00
|
|
|
|
2010-05-22 14:44:26 -07:00
|
|
|
/**
|
|
|
|
* @defgroup find Find
|
|
|
|
*
|
|
|
|
* These are functions which find/supplement lists of devices.
|
|
|
|
*
|
|
|
|
* @ingroup udev
|
|
|
|
*/
|
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
/**
|
2010-05-22 22:03:17 -07:00
|
|
|
* Returns a stringshared list of all syspaths that are (or should be) the same
|
2010-05-16 19:59:07 -07:00
|
|
|
* device as the device pointed at by @p syspath.
|
|
|
|
*
|
|
|
|
* @param syspath The syspath of the device to find matches for
|
|
|
|
* @return All devices which are the same as the one passed
|
|
|
|
*
|
2010-05-22 14:44:26 -07:00
|
|
|
* @ingroup find
|
2010-05-16 19:59:07 -07:00
|
|
|
*/
|
|
|
|
EAPI Eina_List *
|
|
|
|
eeze_udev_find_similar_from_syspath(const char *syspath)
|
|
|
|
{
|
2010-05-21 18:55:14 -07:00
|
|
|
_udev_device *device;
|
|
|
|
_udev_list_entry *devs, *cur;
|
|
|
|
_udev_enumerate *en;
|
2010-05-16 19:59:07 -07:00
|
|
|
Eina_List *l, *ret = NULL;
|
|
|
|
Eina_Strbuf *sbuf;
|
|
|
|
const char *vendor, *model, *revision, *devname, *dev;
|
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
if (!syspath)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
en = udev_enumerate_new((udev));
|
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
if (!en)
|
2010-05-21 18:55:14 -07:00
|
|
|
return NULL;
|
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
sbuf = eina_strbuf_new();
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
if (!strstr(syspath, "/sys/"))
|
|
|
|
eina_strbuf_append(sbuf, "/sys/");
|
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
eina_strbuf_append(sbuf, syspath);
|
2010-05-16 19:59:07 -07:00
|
|
|
device = udev_device_new_from_syspath(udev, syspath);
|
|
|
|
vendor = udev_device_get_property_value(device, "ID_VENDOR_ID");
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
if (vendor)
|
|
|
|
udev_enumerate_add_match_property(en, "ID_VENDOR_ID", vendor);
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
model = udev_device_get_property_value(device, "ID_MODEL_ID");
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
if (model)
|
|
|
|
udev_enumerate_add_match_property(en, "ID_MODEL_ID", model);
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
revision = udev_device_get_property_value(device, "ID_REVISION");
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
if (revision)
|
|
|
|
udev_enumerate_add_match_property(en, "ID_REVISION", revision);
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_scan_devices(en);
|
|
|
|
udev_device_unref(device);
|
|
|
|
devs = udev_enumerate_get_list_entry(en);
|
|
|
|
udev_list_entry_foreach(cur, devs)
|
|
|
|
{
|
|
|
|
devname = udev_list_entry_get_name(cur);
|
2010-05-21 18:55:14 -07:00
|
|
|
/* verify unlisted device */
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ret, l, dev) if (!strcmp(dev, devname))
|
|
|
|
continue;
|
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
ret = eina_list_prepend(ret, eina_stringshare_add(devname));
|
|
|
|
device = udev_device_new_from_syspath(udev, devname);
|
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
/* only device roots have this sysattr,
|
|
|
|
* and we only need to check parents of the roots
|
|
|
|
*/
|
2010-05-16 19:59:07 -07:00
|
|
|
if (udev_device_get_sysattr_value(device, "idVendor"))
|
2010-07-30 11:19:04 -07:00
|
|
|
ret = _get_unlisted_parents(ret, device);
|
2010-05-16 19:59:07 -07:00
|
|
|
|
|
|
|
udev_device_unref(device);
|
2010-05-21 18:55:14 -07:00
|
|
|
}
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_unref(en);
|
|
|
|
eina_strbuf_free(sbuf);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates a list of all syspaths that are (or should be) the same
|
|
|
|
* device.
|
|
|
|
*
|
2010-05-22 22:47:30 -07:00
|
|
|
* @param list The list of devices to update
|
2010-07-30 11:19:04 -07:00
|
|
|
* @return The updated list
|
2010-05-16 19:59:07 -07:00
|
|
|
*
|
|
|
|
* This function will update @p list to include all devices matching
|
2010-05-22 22:03:17 -07:00
|
|
|
* devices with syspaths currently stored in @p list. All strings are
|
|
|
|
* stringshared.
|
2010-05-16 19:59:07 -07:00
|
|
|
*
|
2010-05-22 14:44:26 -07:00
|
|
|
* @ingroup find
|
2010-05-16 19:59:07 -07:00
|
|
|
*/
|
2010-07-30 11:19:04 -07:00
|
|
|
EAPI Eina_List *
|
2010-05-21 18:55:14 -07:00
|
|
|
eeze_udev_find_unlisted_similar(Eina_List * list)
|
2010-05-16 19:59:07 -07:00
|
|
|
{
|
2010-05-21 18:55:14 -07:00
|
|
|
_udev_device *device;
|
|
|
|
_udev_list_entry *devs, *cur;
|
|
|
|
_udev_enumerate *en;
|
2010-05-16 19:59:07 -07:00
|
|
|
Eina_List *l;
|
|
|
|
const char *vendor, *model, *revision, *devname, *dev;
|
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
if (!list)
|
|
|
|
return;
|
2010-05-16 19:59:07 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(list, l, dev)
|
|
|
|
{
|
2010-05-21 18:55:14 -07:00
|
|
|
en = udev_enumerate_new((udev));
|
|
|
|
|
|
|
|
if (!en)
|
|
|
|
return;
|
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
device = udev_device_new_from_syspath(udev, dev);
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-20 21:11:58 -07:00
|
|
|
if ((vendor = udev_device_get_property_value(device, "ID_VENDOR_ID")))
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_add_match_property(en, "ID_VENDOR_ID", vendor);
|
2010-05-21 18:55:14 -07:00
|
|
|
else
|
|
|
|
if ((vendor = udev_device_get_property_value(device, "ID_VENDOR")))
|
|
|
|
udev_enumerate_add_match_property(en, "ID_VENDOR", vendor);
|
|
|
|
|
2010-05-20 21:11:58 -07:00
|
|
|
if ((model = udev_device_get_property_value(device, "ID_MODEL_ID")))
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_add_match_property(en, "ID_MODEL_ID", model);
|
2010-05-21 18:55:14 -07:00
|
|
|
else
|
|
|
|
if ((model = udev_device_get_property_value(device, "ID_MODEL")))
|
|
|
|
udev_enumerate_add_match_property(en, "ID_MODEL", model);
|
|
|
|
|
2010-05-20 21:11:58 -07:00
|
|
|
if ((revision = udev_device_get_property_value(device, "ID_REVISION")))
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_add_match_property(en, "ID_REVISION", revision);
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_scan_devices(en);
|
|
|
|
udev_device_unref(device);
|
|
|
|
devs = udev_enumerate_get_list_entry(en);
|
|
|
|
udev_list_entry_foreach(cur, devs)
|
|
|
|
{
|
|
|
|
devname = udev_list_entry_get_name(cur);
|
|
|
|
device = udev_device_new_from_syspath(udev, devname);
|
|
|
|
|
|
|
|
/* only device roots have this sysattr,
|
|
|
|
* and we only need to check parents of the roots
|
|
|
|
*/
|
|
|
|
if (udev_device_get_sysattr_value(device, "idVendor"))
|
2010-07-30 11:19:04 -07:00
|
|
|
list = _get_unlisted_parents(list, device);
|
2010-05-16 19:59:07 -07:00
|
|
|
|
|
|
|
udev_device_unref(device);
|
2010-05-21 18:55:14 -07:00
|
|
|
}
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_unref(en);
|
|
|
|
}
|
2010-07-30 11:19:04 -07:00
|
|
|
return list;
|
2010-05-16 19:59:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-05-22 14:44:26 -07:00
|
|
|
* Find devices using an @ref type and/or a name.
|
2010-05-16 19:59:07 -07:00
|
|
|
*
|
2010-05-22 22:47:30 -07:00
|
|
|
* @param etype An @ref Eeze_Udev_Type or 0
|
2010-05-16 19:59:07 -07:00
|
|
|
* @param name A filter for the device name or NULL
|
2010-05-22 22:03:17 -07:00
|
|
|
* @return A stringshared Eina_List of matched devices or NULL on failure
|
2010-05-21 18:55:14 -07:00
|
|
|
*
|
2010-05-16 19:59:07 -07:00
|
|
|
* Return a list of syspaths (/sys/$syspath) for matching udev devices.
|
|
|
|
*
|
2010-05-22 14:44:26 -07:00
|
|
|
* @ingroup find
|
2010-05-16 19:59:07 -07:00
|
|
|
*/
|
|
|
|
EAPI Eina_List *
|
2010-07-30 11:19:04 -07:00
|
|
|
eeze_udev_find_by_type(Eeze_Udev_Type etype, const char *name)
|
2010-05-16 19:59:07 -07:00
|
|
|
{
|
2010-05-21 18:55:14 -07:00
|
|
|
_udev_enumerate *en;
|
|
|
|
_udev_list_entry *devs, *cur;
|
|
|
|
_udev_device *device, *parent;
|
2010-05-19 22:34:08 -07:00
|
|
|
const char *devname, *test;
|
2010-05-16 19:59:07 -07:00
|
|
|
Eina_List *ret = NULL;
|
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
if ((!etype) && (!name))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
en = udev_enumerate_new((udev));
|
2010-05-16 19:59:07 -07:00
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
if (!en)
|
|
|
|
return NULL;
|
2010-05-16 19:59:07 -07:00
|
|
|
|
|
|
|
switch (etype)
|
|
|
|
{
|
|
|
|
case EEZE_UDEV_TYPE_NONE:
|
|
|
|
break;
|
|
|
|
case EEZE_UDEV_TYPE_KEYBOARD:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "input");
|
2010-05-20 21:11:58 -07:00
|
|
|
#ifndef OLD_UDEV_RRRRRRRRRRRRRR
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_add_match_property(en, "ID_INPUT_KEYBOARD", "1");
|
2010-05-20 21:11:58 -07:00
|
|
|
#else
|
|
|
|
udev_enumerate_add_match_property(en, "ID_CLASS", "kbd");
|
|
|
|
#endif
|
2010-05-16 19:59:07 -07:00
|
|
|
break;
|
|
|
|
case EEZE_UDEV_TYPE_MOUSE:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "input");
|
2010-05-20 21:11:58 -07:00
|
|
|
#ifndef OLD_UDEV_RRRRRRRRRRRRRR
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_add_match_property(en, "ID_INPUT_MOUSE", "1");
|
2010-05-20 21:11:58 -07:00
|
|
|
#else
|
|
|
|
udev_enumerate_add_match_property(en, "ID_CLASS", "mouse");
|
|
|
|
#endif
|
2010-05-16 19:59:07 -07:00
|
|
|
break;
|
|
|
|
case EEZE_UDEV_TYPE_TOUCHPAD:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "input");
|
2010-05-20 21:11:58 -07:00
|
|
|
#ifndef OLD_UDEV_RRRRRRRRRRRRRR
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_add_match_property(en, "ID_INPUT_TOUCHPAD", "1");
|
2010-05-20 21:11:58 -07:00
|
|
|
#endif
|
2010-05-16 19:59:07 -07:00
|
|
|
break;
|
|
|
|
case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "block");
|
|
|
|
udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem");
|
|
|
|
udev_enumerate_add_nomatch_sysattr(en, "capability", "52");
|
|
|
|
break;
|
|
|
|
case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "block");
|
|
|
|
udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
|
|
|
|
udev_enumerate_add_match_property(en, "ID_BUS", "ata");
|
|
|
|
udev_enumerate_add_match_sysattr(en, "removable", "0");
|
|
|
|
break;
|
|
|
|
case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "block");
|
|
|
|
udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
|
|
|
|
break;
|
|
|
|
case EEZE_UDEV_TYPE_DRIVE_CDROM:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "block");
|
|
|
|
udev_enumerate_add_match_property(en, "ID_CDROM", "1");
|
|
|
|
break;
|
|
|
|
case EEZE_UDEV_TYPE_POWER_AC:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "power_supply");
|
|
|
|
udev_enumerate_add_match_property(en, "POWER_SUPPLY_TYPE", "Mains");
|
|
|
|
break;
|
|
|
|
case EEZE_UDEV_TYPE_POWER_BAT:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "power_supply");
|
|
|
|
udev_enumerate_add_match_property(en, "POWER_SUPPLY_TYPE", "Battery");
|
|
|
|
break;
|
2010-05-19 22:34:08 -07:00
|
|
|
case EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "hwmon");
|
|
|
|
break;
|
2010-05-21 18:55:14 -07:00
|
|
|
/*
|
|
|
|
case EEZE_UDEV_TYPE_ANDROID:
|
|
|
|
udev_enumerate_add_match_subsystem(en, "block");
|
|
|
|
udev_enumerate_add_match_property(en, "ID_MODEL", "Android_*");
|
|
|
|
break;
|
|
|
|
*/
|
2010-05-16 19:59:07 -07:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
udev_enumerate_scan_devices(en);
|
|
|
|
devs = udev_enumerate_get_list_entry(en);
|
|
|
|
udev_list_entry_foreach(cur, devs)
|
|
|
|
{
|
|
|
|
devname = udev_list_entry_get_name(cur);
|
|
|
|
device = udev_device_new_from_syspath(udev, devname);
|
|
|
|
|
2010-05-19 22:34:08 -07:00
|
|
|
if (etype == EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR)
|
2010-05-21 18:55:14 -07:00
|
|
|
{ /* ensure that temp input exists somewhere in this device chain */
|
|
|
|
if (!_walk_parents_test_attr(device, "temp1_input", NULL))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* if device is not the one which has the temp input, we must go up the chain */
|
|
|
|
if (!(test = udev_device_get_sysattr_value(device, "temp1_input")))
|
|
|
|
{
|
|
|
|
devname = NULL;
|
|
|
|
|
|
|
|
for (parent = udev_device_get_parent(device); parent; parent = udev_device_get_parent(parent)) /*check for parent */
|
|
|
|
if (((test = udev_device_get_sysattr_value(parent, "temp1_input"))))
|
|
|
|
{
|
|
|
|
devname = udev_device_get_syspath(parent);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!devname)
|
|
|
|
goto out;
|
|
|
|
}
|
2010-05-20 22:18:24 -07:00
|
|
|
}
|
2010-05-21 18:55:14 -07:00
|
|
|
else
|
|
|
|
if (etype == EEZE_UDEV_TYPE_DRIVE_INTERNAL)
|
|
|
|
{
|
|
|
|
if (udev_device_get_property_value(device, "ID_USB_DRIVER"))
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (etype == EEZE_UDEV_TYPE_DRIVE_REMOVABLE)
|
|
|
|
{
|
|
|
|
if (!
|
|
|
|
(test = udev_device_get_property_value(device, "ID_USB_DRIVER")))
|
|
|
|
goto out;
|
|
|
|
}
|
2010-05-20 22:18:24 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
if (name)
|
2010-05-21 18:55:14 -07:00
|
|
|
if (!strstr(devname, name))
|
|
|
|
goto out;
|
2010-05-16 19:59:07 -07:00
|
|
|
|
|
|
|
ret = eina_list_append(ret, eina_stringshare_add(devname));
|
|
|
|
out:
|
|
|
|
udev_device_unref(device);
|
2010-05-21 18:55:14 -07:00
|
|
|
}
|
|
|
|
udev_enumerate_unref(en);
|
|
|
|
return ret;
|
2010-05-16 19:59:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A more advanced find, allows finds using udev properties.
|
|
|
|
*
|
|
|
|
* @param subsystem The udev subsystem to filter by, or NULL
|
|
|
|
* @param type "ID_INPUT_KEY", "ID_INPUT_MOUSE", "ID_INPUT_TOUCHPAD", NULL, etc
|
|
|
|
* @param name A filter for the device name, or NULL
|
2010-05-22 22:03:17 -07:00
|
|
|
* @return A stringshared Eina_List* of matched devices or NULL on failure
|
2010-05-21 18:55:14 -07:00
|
|
|
*
|
2010-05-16 19:59:07 -07:00
|
|
|
* Return a list of syspaths (/sys/$syspath) for matching udev devices.
|
|
|
|
* Requires at least one filter.
|
|
|
|
*
|
2010-05-22 14:44:26 -07:00
|
|
|
* @ingroup find
|
2010-05-16 19:59:07 -07:00
|
|
|
*/
|
|
|
|
EAPI Eina_List *
|
2010-05-21 18:55:14 -07:00
|
|
|
eeze_udev_find_by_filter(const char *subsystem, const char *type,
|
|
|
|
const char *name)
|
2010-05-16 19:59:07 -07:00
|
|
|
{
|
2010-05-21 18:55:14 -07:00
|
|
|
_udev_enumerate *en;
|
|
|
|
_udev_list_entry *devs, *cur;
|
|
|
|
_udev_device *device;
|
2010-05-16 19:59:07 -07:00
|
|
|
const char *devname;
|
|
|
|
Eina_List *ret = NULL;
|
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
if ((!subsystem) && (!type) && (!name))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
en = udev_enumerate_new((udev));
|
2010-05-16 19:59:07 -07:00
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
if (!en)
|
|
|
|
return NULL;
|
2010-05-16 19:59:07 -07:00
|
|
|
|
|
|
|
if (subsystem)
|
|
|
|
udev_enumerate_add_match_subsystem(en, subsystem);
|
|
|
|
|
|
|
|
udev_enumerate_add_match_property(en, type, "1");
|
|
|
|
udev_enumerate_scan_devices(en);
|
|
|
|
devs = udev_enumerate_get_list_entry(en);
|
|
|
|
udev_list_entry_foreach(cur, devs)
|
|
|
|
{
|
|
|
|
devname = udev_list_entry_get_name(cur);
|
|
|
|
device = udev_device_new_from_syspath(udev, devname);
|
|
|
|
|
|
|
|
if (name)
|
2010-05-21 18:55:14 -07:00
|
|
|
if (!strstr(devname, name))
|
|
|
|
goto out;
|
2010-05-16 19:59:07 -07:00
|
|
|
|
|
|
|
ret = eina_list_append(ret, eina_stringshare_add(devname));
|
|
|
|
out:
|
|
|
|
udev_device_unref(device);
|
2010-05-21 18:55:14 -07:00
|
|
|
}
|
|
|
|
udev_enumerate_unref(en);
|
|
|
|
return ret;
|
2010-05-16 19:59:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find a list of devices by a sysattr (and, optionally, a value of that sysattr).
|
2010-05-21 18:55:14 -07:00
|
|
|
*
|
2010-05-16 19:59:07 -07:00
|
|
|
* @param sysattr The attribute to find
|
|
|
|
* @param value Optional: the value that the attribute should have
|
2010-05-21 18:55:14 -07:00
|
|
|
*
|
2010-05-22 22:03:17 -07:00
|
|
|
* @return A stringshared list of the devices found with the attribute
|
2010-05-22 14:44:26 -07:00
|
|
|
*
|
|
|
|
* @ingroup find
|
2010-05-16 19:59:07 -07:00
|
|
|
*/
|
|
|
|
EAPI Eina_List *
|
|
|
|
eeze_udev_find_by_sysattr(const char *sysattr, const char *value)
|
|
|
|
{
|
2010-05-21 18:55:14 -07:00
|
|
|
_udev_enumerate *en;
|
|
|
|
_udev_list_entry *devs, *cur;
|
|
|
|
_udev_device *device;
|
2010-05-16 19:59:07 -07:00
|
|
|
const char *devname;
|
|
|
|
Eina_List *ret = NULL;
|
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
if (!sysattr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
en = udev_enumerate_new((udev));
|
2010-05-16 19:59:07 -07:00
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
if (!en)
|
|
|
|
return NULL;
|
2010-05-16 19:59:07 -07:00
|
|
|
|
|
|
|
udev_enumerate_add_match_sysattr(en, sysattr, value);
|
|
|
|
udev_enumerate_scan_devices(en);
|
|
|
|
devs = udev_enumerate_get_list_entry(en);
|
|
|
|
udev_list_entry_foreach(cur, devs)
|
|
|
|
{
|
|
|
|
devname = udev_list_entry_get_name(cur);
|
|
|
|
device = udev_device_new_from_syspath(udev, devname);
|
|
|
|
ret = eina_list_append(ret, eina_stringshare_add(devname));
|
|
|
|
udev_device_unref(device);
|
2010-05-21 18:55:14 -07:00
|
|
|
}
|
|
|
|
udev_enumerate_unref(en);
|
|
|
|
return ret;
|
2010-05-16 19:59:07 -07:00
|
|
|
}
|