summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-07-19 02:45:27 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-07-19 02:45:49 -0400
commit6aaa8c2f783cd1b3ac27c5ce40625d032e7e3d71 (patch)
tree704a842601b5ce7ca739c1ab4ba0e675493cb734 /src/shared
parent61ad59b1314060958c6e1b1b480074e230b6ed3e (diff)
core: add %v specifier
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/install-printf.c4
-rw-r--r--src/shared/specifier.c12
-rw-r--r--src/shared/specifier.h1
3 files changed, 16 insertions, 1 deletions
diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c
index c44459b4e0..1157ea989b 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 7577c91052..bb8859fdfd 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 0440dcac48..d13e6406b6 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);