[systemd-devel] [PATCH v2 1/2] hostnamed: expose KernelVersion on the bus

Lennart Poettering lennart at poettering.net
Wed Apr 23 23:53:27 PDT 2014


On Wed, 23.04.14 23:03, Djalal Harouni (tixxdz at opendz.org) wrote:

> This is needed to fix bug:
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=76498

Hmm, do we really want to expose the version here? I fail to see the
general usefulness of this value. The release is a lot more useful and
we already expose that, so do we really want the version here?

I understand that the plot currently shows the value, but maybe the
right choice is to simply drop it there? Showing this sounds mostly like
folklore to me...

> 
> Reported-by: Zach <zachcook1991 at gmail.com>
> ---
>  src/hostname/hostnamed.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
> index 2be6dcd..a798f16 100644
> --- a/src/hostname/hostnamed.c
> +++ b/src/hostname/hostnamed.c
> @@ -43,6 +43,7 @@ enum {
>          PROP_CHASSIS,
>          PROP_KERNEL_NAME,
>          PROP_KERNEL_RELEASE,
> +        PROP_KERNEL_VERSION,
>          PROP_OS_PRETTY_NAME,
>          PROP_OS_CPE_NAME,
>          _PROP_MAX
> @@ -82,7 +83,9 @@ static int context_read_data(Context *c) {
>          assert_se(uname(&u) >= 0);
>          c->data[PROP_KERNEL_NAME] = strdup(u.sysname);
>          c->data[PROP_KERNEL_RELEASE] = strdup(u.release);
> -        if (!c->data[PROP_KERNEL_NAME] || !c->data[PROP_KERNEL_RELEASE])
> +        c->data[PROP_KERNEL_VERSION] = strdup(u.version);
> +        if (!c->data[PROP_KERNEL_NAME] || !c->data[PROP_KERNEL_RELEASE] ||
> +            !c->data[PROP_KERNEL_VERSION])
>                  return -ENOMEM;
>  
>          c->data[PROP_HOSTNAME] = gethostname_malloc();
> @@ -567,6 +570,7 @@ static const sd_bus_vtable hostname_vtable[] = {
>          SD_BUS_PROPERTY("Chassis", "s", property_get_chassis, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
>          SD_BUS_PROPERTY("KernelName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_KERNEL_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_PROPERTY("KernelRelease", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_KERNEL_RELEASE, SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("KernelVersion", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_KERNEL_VERSION, SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_PROPERTY("OperatingSystemPrettyName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_PRETTY_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_PROPERTY("OperatingSystemCPEName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_CPE_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_METHOD("SetHostname", "sb", NULL, method_set_hostname, SD_BUS_VTABLE_UNPRIVILEGED),


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list