<div dir="ltr"><div>Ok, I'll try my luck with git send-email then. I was unaware of this gmail-oddity. Sorry about that.<br><br>Any ideas, why lubudev consideres so many things as attributes ?<br><br></div>Cheers,<br><div>
Andreas<br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-14 1:07 GMT+01:00 Lennart Poettering <span dir="ltr"><<a href="mailto:lennart@poettering.net" target="_blank">lennart@poettering.net</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">On Mon, 13.01.14 21:19, Andreas Fuchs (<a href="mailto:anduchs@gmail.com">anduchs@gmail.com</a>) wrote:<br>
<br>
> For gudev -> gudevdevice:<br>
> - Add support for get_sysfs_attr_keys()<br>
> - Add support for has_sysfs_attr()<br>
><br>
> Note: Only tested against systemd-204 on Ubuntu 13.10's patch-set...<br>
> RFC1: For some reason libudev cosiders every link or file as sysfs<br>
> attribute (opposed to udevadm). Is this intended ?<br>
> RFC2: Since this is my first patch, please comment on any changes it needs<br>
> and I'll iterate. Thank you...<br>
<br>
</div>Hmm, so this certainly looks useful, given that the low-level libudev<br>
API supports something like this.<br>
<br>
Your patch is broken though, it got line-wrapper by your mailer?<br>
<br>
Kay, what's the deal with patches for gudev? Are you looking after this?<br>
I wonder if David is still maintaining it?<br>
<div><div class="h5"><br>
><br>
> Signed-off-by: Andreas Fuchs <<a href="mailto:anduchs@gmail.com">anduchs@gmail.com</a>><br>
> ---<br>
> src/gudev/gudevdevice.c | 53<br>
> +++++++++++++++++++++++++++++++++++++++++++++++++<br>
> src/gudev/gudevdevice.h | 3 +++<br>
> 2 files changed, 56 insertions(+)<br>
><br>
> diff --git a/src/gudev/gudevdevice.c b/src/gudev/gudevdevice.c<br>
> index 6c9e0f5..2c768b7 100644<br>
> --- a/src/gudev/gudevdevice.c<br>
> +++ b/src/gudev/gudevdevice.c<br>
> @@ -59,6 +59,8 @@<br>
> * g_udev_device_get_property_as_strv().<br>
> *<br>
> * To access sysfs attributes for the device, use<br>
> + * g_udev_device_get_sysfs_attr_keys(),<br>
> + * g_udev_device_has_sysfs_attr(),<br>
> * g_udev_device_get_sysfs_attr(),<br>
> * g_udev_device_get_sysfs_attr_as_int(),<br>
> * g_udev_device_get_sysfs_attr_as_uint64(),<br>
> @@ -84,6 +86,7 @@ struct _GUdevDevicePrivate<br>
> /* computed ondemand and cached */<br>
> gchar **device_file_symlinks;<br>
> gchar **property_keys;<br>
> + gchar **sysfs_attr_keys;<br>
> gchar **tags;<br>
> GHashTable *prop_strvs;<br>
> GHashTable *sysfs_attr_strvs;<br>
> @@ -98,6 +101,7 @@ g_udev_device_finalize (GObject *object)<br>
><br>
> g_strfreev (device->priv->device_file_symlinks);<br>
> g_strfreev (device->priv->property_keys);<br>
> + g_strfreev (device->priv->sysfs_attr_keys);<br>
> g_strfreev (device->priv->tags);<br>
><br>
> if (device->priv->udevice != NULL)<br>
> @@ -699,6 +703,55 @@ out:<br>
> /*<br>
> ----------------------------------------------------------------------------------------------------<br>
> */<br>
><br>
> /**<br>
> + * g_udev_device_get_sysfs_attr_keys:<br>
> + * @device: A #GUdevDevice.<br>
> + *<br>
> + * Gets all keys for sysfs attributes on @device.<br>
> + *<br>
> + * Returns: (transfer none) (array zero-terminated=1) (element-type utf8):<br>
> A %NULL terminated string array of sysfs attribute keys. This array is<br>
> owned by @device and should not be freed by the caller.<br>
> + */<br>
> +const gchar * const *<br>
> +g_udev_device_get_sysfs_attr_keys (GUdevDevice *device)<br>
> +{<br>
> + struct udev_list_entry *l;<br>
> + GPtrArray *p;<br>
> +<br>
> + g_return_val_if_fail (G_UDEV_IS_DEVICE (device), NULL);<br>
> +<br>
> + if (device->priv->sysfs_attr_keys != NULL)<br>
> + goto out;<br>
> +<br>
> + p = g_ptr_array_new ();<br>
> + for (l = udev_device_get_sysattr_list_entry (device->priv->udevice); l<br>
> != NULL; l = udev_list_entry_get_next (l))<br>
> + {<br>
> + g_ptr_array_add (p, g_strdup (udev_list_entry_get_name (l)));<br>
> + }<br>
> + g_ptr_array_add (p, NULL);<br>
> + device->priv->sysfs_attr_keys = (gchar **) g_ptr_array_free (p, FALSE);<br>
> +<br>
> + out:<br>
> + return (const gchar * const *) device->priv->sysfs_attr_keys;<br>
> +}<br>
> +<br>
> +/**<br>
> + * g_udev_device_has_sysfs_attr:<br>
> + * @device: A #GUdevDevice.<br>
> + * @key: Name of sysfs attribute.<br>
> + *<br>
> + * Check if a the sysfs attribute with the given key exists.<br>
> + *<br>
> + * Returns: %TRUE only if the value for @key exist.<br>
> + */<br>
> +gboolean<br>
> +g_udev_device_has_sysfs_attr (GUdevDevice *device,<br>
> + const gchar *key)<br>
> +{<br>
> + g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE);<br>
> + g_return_val_if_fail (key != NULL, FALSE);<br>
> + return udev_device_get_sysattr_value (device->priv->udevice, key) !=<br>
> NULL;<br>
> +}<br>
> +<br>
> +/**<br>
> * g_udev_device_get_sysfs_attr:<br>
> * @device: A #GUdevDevice.<br>
> * @name: Name of the sysfs attribute.<br>
> diff --git a/src/gudev/gudevdevice.h b/src/gudev/gudevdevice.h<br>
> index 457b961..72ec180 100644<br>
> --- a/src/gudev/gudevdevice.h<br>
> +++ b/src/gudev/gudevdevice.h<br>
> @@ -108,6 +108,9 @@ gboolean<br>
> g_udev_device_get_property_as_boolean (GUdevDevice *devic<br>
> const gchar* const *g_udev_device_get_property_as_strv (GUdevDevice<br>
> *device,<br>
> const gchar<br>
> *key);<br>
><br>
> +const gchar* const *g_udev_device_get_sysfs_attr_keys (GUdevDevice<br>
> *device);<br>
> +gboolean g_udev_device_has_sysfs_attr (GUdevDevice<br>
> *device,<br>
> + const gchar<br>
> *key);<br>
> const gchar *g_udev_device_get_sysfs_attr (GUdevDevice<br>
> *device,<br>
> const gchar<br>
> *name);<br>
> gint g_udev_device_get_sysfs_attr_as_int (GUdevDevice<br>
> *device,<br>
<br>
</div></div>> _______________________________________________<br>
> systemd-devel mailing list<br>
> <a href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/systemd-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
<span class=""><font color="#888888"><br>
<br>
<br>
Lennart<br>
<br>
--<br>
Lennart Poettering, Red Hat<br>
</font></span></blockquote></div><br></div></div></div>