summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDjalal Harouni <tixxdz@opendz.org>2014-04-23 22:41:13 +0100
committerLennart Poettering <lennart@poettering.net>2014-04-23 23:44:39 +0200
commitfa4f8f9bc1fbef6a658cff39ac185bbedea6caf4 (patch)
treee15c70aeaa64b14fae3748988ddca431230abf81
parentf426cc5d4e30b05a0661c74e93ff3e95414f7a3c (diff)
downloadsystemd-fa4f8f9bc1fbef6a658cff39ac185bbedea6caf4.tar.gz
hostnamectl: read kernel name and release from remote
-rw-r--r--src/hostname/hostnamectl.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index 326f371746..70049d31f6 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -67,6 +67,8 @@ typedef struct StatusInfo {
char *pretty_hostname;
char *icon_name;
char *chassis;
+ char *kernel_name;
+ char *kernel_release;
char *os_pretty_name;
char *os_cpe_name;
char *virtualization;
@@ -76,7 +78,6 @@ typedef struct StatusInfo {
static void print_status_info(StatusInfo *i) {
sd_id128_t mid = {}, bid = {};
int r;
- struct utsname u;
assert(i);
@@ -112,8 +113,8 @@ static void print_status_info(StatusInfo *i) {
if (!isempty(i->os_cpe_name))
printf(" CPE OS Name: %s\n", i->os_cpe_name);
- assert_se(uname(&u) >= 0);
- printf(" Kernel: %s %s\n", u.sysname, u.release);
+ if (!isempty(i->kernel_name) && !isempty(i->kernel_release))
+ printf(" Kernel: %s %s\n", i->kernel_name, i->kernel_release);
if (!isempty(i->architecture))
printf(" Architecture: %s\n", i->architecture);
@@ -156,6 +157,8 @@ static int show_all_names(sd_bus *bus) {
{ "PrettyHostname", "s", NULL, offsetof(StatusInfo, pretty_hostname) },
{ "IconName", "s", NULL, offsetof(StatusInfo, icon_name) },
{ "Chassis", "s", NULL, offsetof(StatusInfo, chassis) },
+ { "KernelName", "s", NULL, offsetof(StatusInfo, kernel_name) },
+ { "KernelRelease", "s", NULL, offsetof(StatusInfo, kernel_release) },
{ "OperatingSystemPrettyName", "s", NULL, offsetof(StatusInfo, os_pretty_name) },
{ "OperatingSystemCPEName", "s", NULL, offsetof(StatusInfo, os_cpe_name) },
{}
@@ -191,6 +194,8 @@ fail:
free(info.pretty_hostname);
free(info.icon_name);
free(info.chassis);
+ free(info.kernel_name);
+ free(info.kernel_release);
free(info.os_pretty_name);
free(info.os_cpe_name);
free(info.virtualization);