linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] libudev: Get all sysfs attrs for a device
@ 2011-03-03  9:17 Thomas Egerer
  0 siblings, 0 replies; only message in thread
From: Thomas Egerer @ 2011-03-03  9:17 UTC (permalink / raw)
  To: linux-hotplug

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
---
 libudev/exported_symbols |    1 +
 libudev/libudev-device.c |   23 +++++++++++++++++++++++
 libudev/libudev.h        |    1 +
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/libudev/exported_symbols b/libudev/exported_symbols
index 2e6a9b7..500e981 100644
--- a/libudev/exported_symbols
+++ b/libudev/exported_symbols
@@ -32,6 +32,7 @@ udev_device_get_is_initialized
 udev_device_get_devlinks_list_entry
 udev_device_get_properties_list_entry
 udev_device_get_tags_list_entry
+udev_device_get_sysattr_list_entry
 udev_device_get_property_value
 udev_device_get_action
 udev_device_get_driver
diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c
index 5baff49..0874041 100644
--- a/libudev/libudev-device.c
+++ b/libudev/libudev-device.c
@@ -1292,6 +1292,29 @@ out:
 	return val;
 }

+/**
+ * udev_device_get_properties_list_entry:
+ * @udev_device: udev device
+ *
+ * Retrieve the list of sysattr key/value pairs, where value might be empty;
+ * This is to be able to read all available sysfs attributes for a particular
+ * device without the necessity to access sysfs from outside libudev.
+ *
+ * Returns: the first entry of the property list
+ **/
+struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device
*udev_device)
+{
+	/* perform initial caching of sysattr list */
+	if (!udev_device->sysattrs_cached) {
+		int ret;
+		ret = cache_sysattrs(udev_device);
+		if (0 > ret)
+			return NULL;
+	}
+
+	return udev_list_get_entry(&udev_device->sysattr_list);
+}
+
 int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath)
 {
 	const char *pos;
diff --git a/libudev/libudev.h b/libudev/libudev.h
index 0abd7c8..892530b 100644
--- a/libudev/libudev.h
+++ b/libudev/libudev.h
@@ -92,6 +92,7 @@ int udev_device_get_is_initialized(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);
 struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device
*udev_device);
+struct udev_list_entry *udev_device_get_sysattr_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);
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-03-03  9:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-03  9:17 [PATCH 2/2] libudev: Get all sysfs attrs for a device Thomas Egerer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).