summaryrefslogtreecommitdiffstats
path: root/src/core/settings.c
diff options
context:
space:
mode:
authorRobin Smidsrød2013-07-13 20:57:39 +0200
committerMichael Brown2013-07-13 22:15:51 +0200
commit7016164056fb1065c1379d6ac58d1e9cc475c4db (patch)
tree1dcd79f7642ebd5463aeae52ba7dc58a428e55a9 /src/core/settings.c
parent[cmdline] Accept "netX" in iPXE commands (diff)
downloadipxe-7016164056fb1065c1379d6ac58d1e9cc475c4db.tar.gz
ipxe-7016164056fb1065c1379d6ac58d1e9cc475c4db.tar.xz
ipxe-7016164056fb1065c1379d6ac58d1e9cc475c4db.zip
[settings] Add "version" builtin setting
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/settings.c')
-rw-r--r--src/core/settings.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/settings.c b/src/core/settings.c
index 80cd6a9f..8cdabe09 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -35,6 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/base16.h>
#include <ipxe/pci.h>
#include <ipxe/init.h>
+#include <ipxe/version.h>
#include <ipxe/settings.h>
/** @file
@@ -2176,11 +2177,32 @@ static int platform_fetch ( void *data, size_t len ) {
return ( sizeof ( platform ) - 1 /* NUL */ );
}
+/** Version setting */
+struct setting version_setting __setting ( SETTING_MISC ) = {
+ .name = "version",
+ .description = "Version",
+ .type = &setting_type_string,
+ .scope = &builtin_scope,
+};
+
+/**
+ * Fetch version setting
+ *
+ * @v data Buffer to fill with setting data
+ * @v len Length of buffer
+ * @ret len Length of setting data, or negative error
+ */
+static int version_fetch ( void *data, size_t len ) {
+ strncpy ( data, product_version, len );
+ return ( strlen ( product_version ) );
+}
+
/** List of built-in setting operations */
static struct builtin_setting_operation builtin_setting_operations[] = {
{ &errno_setting, errno_fetch },
{ &buildarch_setting, buildarch_fetch },
{ &platform_setting, platform_fetch },
+ { &version_setting, version_fetch },
};
/**