Re: [systemd-devel] discussions of pkg-config black magic over at gentoo

2014-02-22 Thread Kay Sievers
On Thu, Feb 20, 2014 at 7:34 PM, Lennart Poettering
 wrote:
> On Thu, 20.02.14 19:31, Jason A. Donenfeld (ja...@zx2c4.com) wrote:

>> So right now we're considering something like this [2] or [3]. A bit of a
>> bummer to patch the build system like this, but we don't want to rely on
>> IFUNC, and this seems like the cleanest solution. So I thought I'd mention
>> this up here in case folks have opinions and such.
>
> Harald found a way to do what we want to do without ifunc. Expect this
> to be fixed shortly in git. And we are likely going to do another
> release soon. Maybe today, maybe tomorrow.

We now just build the compat libraries from the code and don't use
indirect functions. Not nice, but should work fine and not require any
magic. Please test systemd git if the compat stuff works for you now.

Thanks,
Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/2] udev: use "bit" as unit for network card speeds

2014-02-22 Thread Tom Gundersen
On Wed, Nov 13, 2013 at 3:58 AM, Lennart Poettering
 wrote:
> On Tue, 12.11.13 05:49, Jan Engelhardt (jeng...@inai.de) wrote:
>
>> Given a card that can do 100 Mbit/s, that would be about 12.5 MByte/s,
>> but you cannot seriously expect me to use that value. Although it is
>> quite compelling for 40 Gbit/s because that divides nicely to 5
>> GByte/sec, and we will be seeing increasing speeds :)
>
> Hmm, so, for the byte options we actually used a syntax where the unit
> factor was included in the value, not the key. For example, in
> journald.conf you can write SystemMaxUse=100M to express that 100MBytes
> at max are used for system journals.
>
> I am not entirely sure what this means for the network configuration
> bits.
>
> Maybe "BitsPerSecond=100M" to indicate 100MBit? It might be nicer to
> allow this given that there are Gigabit links too ("BitsPerSecond=4G")
> and (at least in theory) much slower links too ("BitsPerSecond=28800").

Sorry for dropping the ball on this. This suggestion has now been
committed as 
.

Cheers,

Tom
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] fix SECCOMP_CFLAGS usage

2014-02-22 Thread Kay Sievers
On Sat, Feb 22, 2014 at 2:54 AM, Cristian Rodríguez
 wrote:

> This is broken again...
>
> In file included from ./src/core/unit.h:40:0,
>  from src/shared/condition-util.c:35:
> ./src/core/execute.h:37:21: fatal error: seccomp.h: No such file or
> directory
>  #include 
>  ^
> compilation terminated.

Added it where needed.

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] gudev: add device::get_sysfs_attr_keys and device::has_sysfs_attr

2014-02-22 Thread Kay Sievers
On Sat, Feb 22, 2014 at 12:02 PM, Andreas Fuchs  wrote:
> For gudev -> gudevdevice:
> - Add support for get_sysfs_attr_keys()
> - Add support for has_sysfs_attr()

Applied.

Thanks,
Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH/RFC] gudev: add device::get_sysfs_attr_keys() and device::has_sysfs_attr()

2014-02-22 Thread Kay Sievers
On Sat, Feb 22, 2014 at 11:55 AM, Andreas Fuchs  wrote:
> Ok, I'll try my luck with git send-email then. I was unaware of this
> gmail-oddity. Sorry about that.
>
> Any ideas, why lubudev consideres so many things as attributes ?

What do you mean with attributes? Attributes are just the files in
/sys below a device directory.

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot boot after upgrading to latest git version

2014-02-22 Thread Armin K.
On 02/22/2014 05:18 PM, Dave Reisner wrote:
> On Sat, Feb 22, 2014 at 04:05:31PM +0100, Armin K. wrote:
>> Hi, I just finished upgrading to latest git master and I can't boot anymore.
> 
> Without knowing what version you upgraded *from*, this is incomplete
> information.
> 

Sorry, I was using version 208, tarball from fd.o, no additional patches.

>> Partitions are failing to mount, even though I can confirm that correct
>> device nodes exist in /dev when I enter the rescue mode shell. I don't
>> use initramfs on this system, so all drivers are mostly built into
>> kernel and devtmpfs is mounted even before systemd is started, so at
>> least /dev/sda7 should be detected, but it isn't as you can see.
>>
>> Attached is the journalctl -xb log from rescue console.
> 
> There's been a number posts like this on the list recently, all of
> which point to the kernel not having CONFIG_FHANDLE=y.
> 

Indeed, I don't have CONFIG_FHANDLE set in my kernel. I didn't notice it
before though, and changelog didn't mention it like it did compat-libs
and kdbus. Oh well, it's my mistake for not reading README again.

Rebuilding kernel now, I'll complain again if something breaks.

Thanks.

-- 
Note: My last name is not Krejzi.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/2] build-sys: Also move libsystemd-journal to rootlibdir

2014-02-22 Thread Kay Sievers
On Sat, Feb 22, 2014 at 5:48 PM, Armin K.  wrote:
> On 02/22/2014 05:44 PM, Kay Sievers wrote:
>> On Sat, Feb 22, 2014 at 3:22 PM, Armin K  wrote:
>>> ---
>>>  Makefile.am | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/Makefile.am b/Makefile.am
>>> index e25d532..b1f0670 100644
>>> --- a/Makefile.am
>>> +++ b/Makefile.am
>>> @@ -4479,11 +4479,13 @@ lib_LTLIBRARIES += \
>>>  # move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
>>>  compat-lib-install-hook:
>>> libname=libsystemd-login.so && $(move-to-rootlibdir)
>>> +   libname=libsystemd-journal.so && $(move-to-rootlibdir)
>>> libname=libsystemd-id128.so && $(move-to-rootlibdir)
>>> libname=libsystemd-daemon.so && $(move-to-rootlibdir)
>>
>> Hmm, that is already in the libsystemd section and does not belong in
>> the compat libs section.
>>
>> Please check does not work for you?

> When --enable-compat-libs is used, and rootlibdir != libdir,
> libsystemd-{login,id128,daemon}.so.* (versioned libraries) get installed
> in rootlibdir, but libsystemd-daemon.so.* remains in libdir. Either
> don't move any or move them all, simple as that.

Ah, I mis-read that as libsystemd.so, sorry, simple as that.

Applied.

Thanks,
Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/2] build-sys: Always install compat pkg-config files

2014-02-22 Thread Kay Sievers
On Sat, Feb 22, 2014 at 3:21 PM, Armin K  wrote:
> Packages are still looking for the old pkg-config files,
> so until everything has been ported over, install them
> always, no matter if compat-libs are built or not.

So far, we think that compat should stay compat, and not mix with the
non-compat stuff.

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/2] build-sys: Also move libsystemd-journal to rootlibdir

2014-02-22 Thread Armin K.
On 02/22/2014 05:44 PM, Kay Sievers wrote:
> On Sat, Feb 22, 2014 at 3:22 PM, Armin K  wrote:
>> ---
>>  Makefile.am | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/Makefile.am b/Makefile.am
>> index e25d532..b1f0670 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -4479,11 +4479,13 @@ lib_LTLIBRARIES += \
>>  # move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
>>  compat-lib-install-hook:
>> libname=libsystemd-login.so && $(move-to-rootlibdir)
>> +   libname=libsystemd-journal.so && $(move-to-rootlibdir)
>> libname=libsystemd-id128.so && $(move-to-rootlibdir)
>> libname=libsystemd-daemon.so && $(move-to-rootlibdir)
> 
> Hmm, that is already in the libsystemd section and does not belong in
> the compat libs section.
> 
> Please check does not work for you?
> 
> Kay
> 

When --enable-compat-libs is used, and rootlibdir != libdir,
libsystemd-{login,id128,daemon}.so.* (versioned libraries) get installed
in rootlibdir, but libsystemd-daemon.so.* remains in libdir. Either
don't move any or move them all, simple as that.

-- 
Note: My last name is not Krejzi.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/2] build-sys: Also move libsystemd-journal to rootlibdir

2014-02-22 Thread Kay Sievers
On Sat, Feb 22, 2014 at 3:22 PM, Armin K  wrote:
> ---
>  Makefile.am | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/Makefile.am b/Makefile.am
> index e25d532..b1f0670 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -4479,11 +4479,13 @@ lib_LTLIBRARIES += \
>  # move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
>  compat-lib-install-hook:
> libname=libsystemd-login.so && $(move-to-rootlibdir)
> +   libname=libsystemd-journal.so && $(move-to-rootlibdir)
> libname=libsystemd-id128.so && $(move-to-rootlibdir)
> libname=libsystemd-daemon.so && $(move-to-rootlibdir)

Hmm, that is already in the libsystemd section and does not belong in
the compat libs section.

Please check does not work for you?

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot boot after upgrading to latest git version

2014-02-22 Thread Dave Reisner
On Sat, Feb 22, 2014 at 04:05:31PM +0100, Armin K. wrote:
> Hi, I just finished upgrading to latest git master and I can't boot anymore.

Without knowing what version you upgraded *from*, this is incomplete
information.

> Partitions are failing to mount, even though I can confirm that correct
> device nodes exist in /dev when I enter the rescue mode shell. I don't
> use initramfs on this system, so all drivers are mostly built into
> kernel and devtmpfs is mounted even before systemd is started, so at
> least /dev/sda7 should be detected, but it isn't as you can see.
> 
> Attached is the journalctl -xb log from rescue console.

There's been a number posts like this on the list recently, all of
which point to the kernel not having CONFIG_FHANDLE=y.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/2] build-sys: Always install compat pkg-config files

2014-02-22 Thread Armin K
Packages are still looking for the old pkg-config files,
so until everything has been ported over, install them
always, no matter if compat-libs are built or not.

Compat .pc files use -lsystemd anyways, so no harm is done.
---
 Makefile.am | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0b879f1..e25d532 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2084,7 +2084,11 @@ INSTALL_EXEC_HOOKS += libsystemd-install-hook
 UNINSTALL_EXEC_HOOKS += libsystemd-uninstall-hook
 
 pkgconfiglib_DATA += \
-   src/libsystemd/libsystemd.pc
+   src/libsystemd/libsystemd.pc \
+   src/compat-libs/libsystemd-journal.pc \
+   src/compat-libs/libsystemd-login.pc \
+   src/compat-libs/libsystemd-id128.pc \
+   src/compat-libs/libsystemd-daemon.pc
 
 pkginclude_HEADERS += \
src/systemd/sd-login.h \
@@ -4472,12 +4476,6 @@ lib_LTLIBRARIES += \
libsystemd-id128.la \
libsystemd-daemon.la
 
-pkgconfiglib_DATA += \
-   src/compat-libs/libsystemd-journal.pc \
-   src/compat-libs/libsystemd-login.pc \
-   src/compat-libs/libsystemd-id128.pc \
-   src/compat-libs/libsystemd-daemon.pc
-
 # move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
 compat-lib-install-hook:
libname=libsystemd-login.so && $(move-to-rootlibdir)
-- 
1.9.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/2] build-sys: Also move libsystemd-journal to rootlibdir

2014-02-22 Thread Armin K
---
 Makefile.am | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index e25d532..b1f0670 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4479,11 +4479,13 @@ lib_LTLIBRARIES += \
 # move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
 compat-lib-install-hook:
libname=libsystemd-login.so && $(move-to-rootlibdir)
+   libname=libsystemd-journal.so && $(move-to-rootlibdir)
libname=libsystemd-id128.so && $(move-to-rootlibdir)
libname=libsystemd-daemon.so && $(move-to-rootlibdir)
 
 compat-lib-uninstall-hook:
rm -f $(DESTDIR)$(rootlibdir)/libsystemd-login.so*
+   rm -f $(DESTDIR)$(rootlibdir)/libsystemd-journal.so*
rm -f $(DESTDIR)$(rootlibdir)/libsystemd-id128.so*
rm -f $(DESTDIR)$(rootlibdir)/libsystemd-daemon.so*
 
-- 
1.9.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] detect_virtualization: make Virtualization an out value

2014-02-22 Thread Thomas H.P. Andersen
From: Thomas Hindoe Paaboel Andersen 

The return value from detect_virtualization used to be a
Virtualization enum but in cases of error it would also be a
negative errno. This caused a warning in clang when test-architecture
began comparing the return value to -EPERM and -EACCES.
---
 src/core/dbus-manager.c   |  2 +-
 src/core/main.c   |  2 +-
 src/detect-virt/detect-virt.c |  6 +++---
 src/hostname/hostnamectl.c|  3 ++-
 src/hostname/hostnamed.c  |  2 +-
 src/shared/condition-util.c   |  8 
 src/shared/virt.c | 20 ++--
 src/shared/virt.h |  2 +-
 src/test/test-architecture.c  |  5 +++--
 9 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 75004cb..f5a06ba 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -84,7 +84,7 @@ static int property_get_virtualization(
 assert(bus);
 assert(reply);
 
-detect_virtualization(&id);
+detect_virtualization(&id, NULL);
 
 return sd_bus_message_append(reply, "s", id);
 }
diff --git a/src/core/main.c b/src/core/main.c
index 086e283..5facd17 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1507,7 +1507,7 @@ int main(int argc, char *argv[]) {
 
 log_info(PACKAGE_STRING " running in system mode. (" 
SYSTEMD_FEATURES ")");
 
-detect_virtualization(&virtualization);
+detect_virtualization(&virtualization, NULL);
 if (virtualization)
 log_info("Detected virtualization '%s'.", 
virtualization);
 
diff --git a/src/detect-virt/detect-virt.c b/src/detect-virt/detect-virt.c
index 2f8b0eb..698658c 100644
--- a/src/detect-virt/detect-virt.c
+++ b/src/detect-virt/detect-virt.c
@@ -131,9 +131,9 @@ int main(int argc, char *argv[]) {
 case ANY_VIRTUALIZATION: {
 Virtualization v;
 
-v = detect_virtualization(&id);
-if (v < 0) {
-log_error("Failed to check for virtualization: %s", 
strerror(-v));
+r = detect_virtualization(&id, &v);
+if (r < 0) {
+log_error("Failed to check for virtualization: %s", 
strerror(-r));
 return EXIT_FAILURE;
 }
 
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index e455249..2e1e6d7 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -104,7 +104,8 @@ static void print_status_info(StatusInfo *i) {
 if (r >= 0)
 printf("   Boot ID: " SD_ID128_FORMAT_STR "\n", 
SD_ID128_FORMAT_VAL(bid));
 
-if (detect_virtualization(&id) > 0)
+r = detect_virtualization(&id, NULL);
+if (r > 0)
 printf("Virtualization: %s\n", id);
 
 r = parse_env_file("/etc/os-release", NEWLINE,
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index e57891b..2e36d01 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -125,7 +125,7 @@ static const char* fallback_chassis(void) {
 unsigned t;
 Virtualization v;
 
-v = detect_virtualization(NULL);
+r = detect_virtualization(NULL, &v);
 
 if (v == VIRTUALIZATION_VM)
 return "vm";
diff --git a/src/shared/condition-util.c b/src/shared/condition-util.c
index 4aea3ca..44feabe 100644
--- a/src/shared/condition-util.c
+++ b/src/shared/condition-util.c
@@ -121,7 +121,7 @@ bool condition_test_kernel_command_line(Condition *c) {
 }
 
 bool condition_test_virtualization(Condition *c) {
-int b;
+int b, r;
 Virtualization v;
 const char *id;
 
@@ -129,9 +129,9 @@ bool condition_test_virtualization(Condition *c) {
 assert(c->parameter);
 assert(c->type == CONDITION_VIRTUALIZATION);
 
-v = detect_virtualization(&id);
-if (v < 0) {
-log_warning("Failed to detect virtualization, ignoring: %s", 
strerror(-v));
+r = detect_virtualization(&id, &v);
+if (r < 0) {
+log_warning("Failed to detect virtualization, ignoring: %s", 
strerror(-r));
 return c->negate;
 }
 
diff --git a/src/shared/virt.c b/src/shared/virt.c
index c79d35d..73ce9ff 100644
--- a/src/shared/virt.c
+++ b/src/shared/virt.c
@@ -278,20 +278,28 @@ finish:
 }
 
 /* Returns a short identifier for the various VM/container implementations */
-Virtualization detect_virtualization(const char **id) {
+int detect_virtualization(const char **id, Virtualization *type) {
 int r;
 
 r = detect_container(id);
 if (r < 0)
 return r;
-if (r > 0)
-return VIRTUALIZATION_CONTAINER;
+if (r > 0) {
+if (type != NULL)
+*type = VIRTUALIZATION_CONTAINER;
+return r;
+}
 
 r = dete

Re: [systemd-devel] [HEADS-UP] It's release time!

2014-02-22 Thread Jan Janssen



On 02/18/2014 01:33 PM, Tom Gundersen wrote:

On Tue, Feb 18, 2014 at 1:20 PM, Jan Janssen  wrote:

the *.link files for networkd completely lack documentation.


They are documented in udev(8). Let me know if anything is unclear or lacking.


And in general,
I would say that networkd could benefit from a more detailed man page before
this gets released.


Anything in particular you feel is unclear or lacking (I'm going
through it now anyway, but more input is always better)?

Cheers,

Tom



Hi,

I now installed systemd 209 from arch testing and it lacks documentation 
about resolv.conf. It appears that you're supposed to create your own 
one or link the one created in /run. This really needs mentioning in the 
man page of networkd.


Jan
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] gudev: add device::get_sysfs_attr_keys and device::has_sysfs_attr

2014-02-22 Thread Andreas Fuchs
For gudev -> gudevdevice:
- Add support for get_sysfs_attr_keys()
- Add support for has_sysfs_attr()

Signed-off-by: Andreas Fuchs 
---
 src/gudev/gudevdevice.c | 53 +
 src/gudev/gudevdevice.h |  3 +++
 2 files changed, 56 insertions(+)

diff --git a/src/gudev/gudevdevice.c b/src/gudev/gudevdevice.c
index 6c9e0f5..2c768b7 100644
--- a/src/gudev/gudevdevice.c
+++ b/src/gudev/gudevdevice.c
@@ -59,6 +59,8 @@
  * g_udev_device_get_property_as_strv().
  *
  * To access sysfs attributes for the device, use
+ * g_udev_device_get_sysfs_attr_keys(),
+ * g_udev_device_has_sysfs_attr(),
  * g_udev_device_get_sysfs_attr(),
  * g_udev_device_get_sysfs_attr_as_int(),
  * g_udev_device_get_sysfs_attr_as_uint64(),
@@ -84,6 +86,7 @@ struct _GUdevDevicePrivate
   /* computed ondemand and cached */
   gchar **device_file_symlinks;
   gchar **property_keys;
+  gchar **sysfs_attr_keys;
   gchar **tags;
   GHashTable *prop_strvs;
   GHashTable *sysfs_attr_strvs;
@@ -98,6 +101,7 @@ g_udev_device_finalize (GObject *object)
 
   g_strfreev (device->priv->device_file_symlinks);
   g_strfreev (device->priv->property_keys);
+  g_strfreev (device->priv->sysfs_attr_keys);
   g_strfreev (device->priv->tags);
 
   if (device->priv->udevice != NULL)
@@ -699,6 +703,55 @@ out:
 /* 

 */
 
 /**
+ * g_udev_device_get_sysfs_attr_keys:
+ * @device: A #GUdevDevice.
+ *
+ * Gets all keys for sysfs attributes on @device.
+ *
+ * Returns: (transfer none) (array zero-terminated=1) (element-type utf8): A 
%NULL terminated string array of sysfs attribute keys. This array is owned by 
@device and should not be freed by the caller.
+ */
+const gchar * const *
+g_udev_device_get_sysfs_attr_keys (GUdevDevice *device)
+{
+  struct udev_list_entry *l;
+  GPtrArray *p;
+
+  g_return_val_if_fail (G_UDEV_IS_DEVICE (device), NULL);
+
+  if (device->priv->sysfs_attr_keys != NULL)
+goto out;
+
+  p = g_ptr_array_new ();
+  for (l = udev_device_get_sysattr_list_entry (device->priv->udevice); l != 
NULL; l = udev_list_entry_get_next (l))
+{
+  g_ptr_array_add (p, g_strdup (udev_list_entry_get_name (l)));
+}
+  g_ptr_array_add (p, NULL);
+  device->priv->sysfs_attr_keys = (gchar **) g_ptr_array_free (p, FALSE);
+
+ out:
+  return (const gchar * const *) device->priv->sysfs_attr_keys;
+}
+
+/**
+ * g_udev_device_has_sysfs_attr:
+ * @device: A #GUdevDevice.
+ * @key: Name of sysfs attribute.
+ *
+ * Check if a the sysfs attribute with the given key exists.
+ *
+ * Returns: %TRUE only if the value for @key exist.
+ */
+gboolean
+g_udev_device_has_sysfs_attr (GUdevDevice  *device,
+const gchar  *key)
+{
+  g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE);
+  g_return_val_if_fail (key != NULL, FALSE);
+  return udev_device_get_sysattr_value (device->priv->udevice, key) != NULL;
+}
+
+/**
  * g_udev_device_get_sysfs_attr:
  * @device: A #GUdevDevice.
  * @name: Name of the sysfs attribute.
diff --git a/src/gudev/gudevdevice.h b/src/gudev/gudevdevice.h
index 457b961..72ec180 100644
--- a/src/gudev/gudevdevice.h
+++ b/src/gudev/gudevdevice.h
@@ -108,6 +108,9 @@ gbooleang_udev_device_get_property_as_boolean   
(GUdevDevice  *devic
 const gchar* const *g_udev_device_get_property_as_strv  (GUdevDevice  
*device,
  const gchar  
*key);
 
+const gchar* const *g_udev_device_get_sysfs_attr_keys   (GUdevDevice  
*device);
+gbooleang_udev_device_has_sysfs_attr(GUdevDevice  
*device,
+ const gchar  
*key);
 const gchar*g_udev_device_get_sysfs_attr(GUdevDevice  
*device,
  const gchar  
*name);
 gintg_udev_device_get_sysfs_attr_as_int (GUdevDevice  
*device,
-- 
1.8.3.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH/RFC] gudev: add device::get_sysfs_attr_keys() and device::has_sysfs_attr()

2014-02-22 Thread Andreas Fuchs
Ok, I'll try my luck with git send-email then. I was unaware of this
gmail-oddity. Sorry about that.

Any ideas, why lubudev consideres so many things as attributes ?

Cheers,
Andreas


2014-02-14 1:07 GMT+01:00 Lennart Poettering :

> On Mon, 13.01.14 21:19, Andreas Fuchs (andu...@gmail.com) wrote:
>
> > For gudev -> gudevdevice:
> > - Add support for get_sysfs_attr_keys()
> > - Add support for has_sysfs_attr()
> >
> > Note: Only tested against systemd-204 on Ubuntu 13.10's patch-set...
> > RFC1: For some reason libudev cosiders every link or file as sysfs
> > attribute (opposed to udevadm). Is this intended ?
> > RFC2: Since this is my first patch, please comment on any changes it
> needs
> > and I'll iterate. Thank you...
>
> Hmm, so this certainly looks useful, given that the low-level libudev
> API supports something like this.
>
> Your patch is broken though, it got line-wrapper by your mailer?
>
> Kay, what's the deal with patches for gudev? Are you looking after this?
> I wonder if David is still maintaining it?
>
> >
> > Signed-off-by: Andreas Fuchs 
> > ---
> >  src/gudev/gudevdevice.c | 53
> > +
> >  src/gudev/gudevdevice.h |  3 +++
> >  2 files changed, 56 insertions(+)
> >
> > diff --git a/src/gudev/gudevdevice.c b/src/gudev/gudevdevice.c
> > index 6c9e0f5..2c768b7 100644
> > --- a/src/gudev/gudevdevice.c
> > +++ b/src/gudev/gudevdevice.c
> > @@ -59,6 +59,8 @@
> >   * g_udev_device_get_property_as_strv().
> >   *
> >   * To access sysfs attributes for the device, use
> > + * g_udev_device_get_sysfs_attr_keys(),
> > + * g_udev_device_has_sysfs_attr(),
> >   * g_udev_device_get_sysfs_attr(),
> >   * g_udev_device_get_sysfs_attr_as_int(),
> >   * g_udev_device_get_sysfs_attr_as_uint64(),
> > @@ -84,6 +86,7 @@ struct _GUdevDevicePrivate
> >/* computed ondemand and cached */
> >gchar **device_file_symlinks;
> >gchar **property_keys;
> > +  gchar **sysfs_attr_keys;
> >gchar **tags;
> >GHashTable *prop_strvs;
> >GHashTable *sysfs_attr_strvs;
> > @@ -98,6 +101,7 @@ g_udev_device_finalize (GObject *object)
> >
> >g_strfreev (device->priv->device_file_symlinks);
> >g_strfreev (device->priv->property_keys);
> > +  g_strfreev (device->priv->sysfs_attr_keys);
> >g_strfreev (device->priv->tags);
> >
> >if (device->priv->udevice != NULL)
> > @@ -699,6 +703,55 @@ out:
> >  /*
> >
> 
> > */
> >
> >  /**
> > + * g_udev_device_get_sysfs_attr_keys:
> > + * @device: A #GUdevDevice.
> > + *
> > + * Gets all keys for sysfs attributes on @device.
> > + *
> > + * Returns: (transfer none) (array zero-terminated=1) (element-type
> utf8):
> > A %NULL terminated string array of sysfs attribute keys. This array is
> > owned by @device and should not be freed by the caller.
> > + */
> > +const gchar * const *
> > +g_udev_device_get_sysfs_attr_keys (GUdevDevice *device)
> > +{
> > +  struct udev_list_entry *l;
> > +  GPtrArray *p;
> > +
> > +  g_return_val_if_fail (G_UDEV_IS_DEVICE (device), NULL);
> > +
> > +  if (device->priv->sysfs_attr_keys != NULL)
> > +goto out;
> > +
> > +  p = g_ptr_array_new ();
> > +  for (l = udev_device_get_sysattr_list_entry (device->priv->udevice); l
> > != NULL; l = udev_list_entry_get_next (l))
> > +{
> > +  g_ptr_array_add (p, g_strdup (udev_list_entry_get_name (l)));
> > +}
> > +  g_ptr_array_add (p, NULL);
> > +  device->priv->sysfs_attr_keys = (gchar **) g_ptr_array_free (p,
> FALSE);
> > +
> > + out:
> > +  return (const gchar * const *) device->priv->sysfs_attr_keys;
> > +}
> > +
> > +/**
> > + * g_udev_device_has_sysfs_attr:
> > + * @device: A #GUdevDevice.
> > + * @key: Name of sysfs attribute.
> > + *
> > + * Check if a the sysfs attribute with the given key exists.
> > + *
> > + * Returns: %TRUE only if the value for @key exist.
> > + */
> > +gboolean
> > +g_udev_device_has_sysfs_attr (GUdevDevice  *device,
> > +const gchar  *key)
> > +{
> > +  g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE);
> > +  g_return_val_if_fail (key != NULL, FALSE);
> > +  return udev_device_get_sysattr_value (device->priv->udevice, key) !=
> > NULL;
> > +}
> > +
> > +/**
> >   * g_udev_device_get_sysfs_attr:
> >   * @device: A #GUdevDevice.
> >   * @name: Name of the sysfs attribute.
> > diff --git a/src/gudev/gudevdevice.h b/src/gudev/gudevdevice.h
> > index 457b961..72ec180 100644
> > --- a/src/gudev/gudevdevice.h
> > +++ b/src/gudev/gudevdevice.h
> > @@ -108,6 +108,9 @@ gboolean
> > g_udev_device_get_property_as_boolean   (GUdevDevice  *devic
> >  const gchar* const *g_udev_device_get_property_as_strv  (GUdevDevice
> > *device,
> >   const gchar
> > *key);
> >
> > +const gchar* const *g_udev_device_get_sysfs_attr_keys   (GUdevDevice
> > *device);
> > +gbooleang_udev_device_has_sysfs_attr