]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[settings] Add "version" builtin setting
authorRobin Smidsrød <robin@smidsrod.no>
Sat, 13 Jul 2013 18:57:39 +0000 (20:57 +0200)
committerMichael Brown <mcb30@ipxe.org>
Sat, 13 Jul 2013 20:15:51 +0000 (22:15 +0200)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/settings.c

index 80cd6a9f4b5ab3771db6294ae9e06d62f0de72e1..8cdabe098fbf59ebf0b6f50be4fa7eb54381f7e6 100644 (file)
@@ -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 },
 };
 
 /**