diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/unit-printf.c | 4 | ||||
-rw-r--r-- | src/shared/install-printf.c | 4 | ||||
-rw-r--r-- | src/shared/specifier.c | 12 | ||||
-rw-r--r-- | src/shared/specifier.h | 1 |
4 files changed, 19 insertions, 2 deletions
diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index caf51259d..ffc203dd9 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -268,6 +268,7 @@ char *unit_full_printf(Unit *u, const char *format) { * %m the machine ID of the running system * %H the host name of the running system * %b the boot ID of the running system + * %v `uname -r` of the running system */ const Specifier table[] = { @@ -291,7 +292,8 @@ char *unit_full_printf(Unit *u, const char *format) { { 'm', specifier_machine_id, NULL }, { 'H', specifier_host_name, NULL }, { 'b', specifier_boot_id, NULL }, - { 0, NULL, NULL } + { 'v', specifier_kernel_release, NULL }, + {} }; assert(format); diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c index c44459b4e..1157ea989 100644 --- a/src/shared/install-printf.c +++ b/src/shared/install-printf.c @@ -108,6 +108,7 @@ char *install_full_printf(InstallInfo *i, const char *format) { * %m the machine ID of the running system * %H the host name of the running system * %b the boot ID of the running system + * %v `uname -r` of the running system */ const Specifier table[] = { @@ -122,7 +123,8 @@ char *install_full_printf(InstallInfo *i, const char *format) { { 'm', specifier_machine_id, NULL }, { 'H', specifier_host_name, NULL }, { 'b', specifier_boot_id, NULL }, - { 0, NULL, NULL } + { 'v', specifier_kernel_release, NULL }, + {} }; assert(i); diff --git a/src/shared/specifier.c b/src/shared/specifier.c index 7577c9105..bb8859fdf 100644 --- a/src/shared/specifier.c +++ b/src/shared/specifier.c @@ -20,6 +20,7 @@ ***/ #include <string.h> +#include <sys/utsname.h> #include "macro.h" #include "util.h" @@ -145,3 +146,14 @@ char *specifier_boot_id(char specifier, void *data, void *userdata) { char *specifier_host_name(char specifier, void *data, void *userdata) { return gethostname_malloc(); } + +char *specifier_kernel_release(char specifier, void *data, void *userdata) { + struct utsname uts; + int r; + + r = uname(&uts); + if (r < 0) + return NULL; + + return strdup(uts.release); +} diff --git a/src/shared/specifier.h b/src/shared/specifier.h index 0440dcac4..d13e6406b 100644 --- a/src/shared/specifier.h +++ b/src/shared/specifier.h @@ -36,3 +36,4 @@ char *specifier_string(char specifier, void *data, void *userdata); char *specifier_machine_id(char specifier, void *data, void *userdata); char *specifier_boot_id(char specifier, void *data, void *userdata); char *specifier_host_name(char specifier, void *data, void *userdata); +char *specifier_kernel_release(char specifier, void *data, void *userdata); |