Procházet zdrojové kódy

[settings] Add "version" builtin setting

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Robin Smidsrød před 11 roky
rodič
revize
7016164056
1 změnil soubory, kde provedl 22 přidání a 0 odebrání
  1. 22
    0
      src/core/settings.c

+ 22
- 0
src/core/settings.c Zobrazit soubor

@@ -35,6 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
35 35
 #include <ipxe/base16.h>
36 36
 #include <ipxe/pci.h>
37 37
 #include <ipxe/init.h>
38
+#include <ipxe/version.h>
38 39
 #include <ipxe/settings.h>
39 40
 
40 41
 /** @file
@@ -2176,11 +2177,32 @@ static int platform_fetch ( void *data, size_t len ) {
2176 2177
 	return ( sizeof ( platform ) - 1 /* NUL */ );
2177 2178
 }
2178 2179
 
2180
+/** Version setting */
2181
+struct setting version_setting __setting ( SETTING_MISC ) = {
2182
+	.name = "version",
2183
+	.description = "Version",
2184
+	.type = &setting_type_string,
2185
+	.scope = &builtin_scope,
2186
+};
2187
+
2188
+/**
2189
+ * Fetch version setting
2190
+ *
2191
+ * @v data		Buffer to fill with setting data
2192
+ * @v len		Length of buffer
2193
+ * @ret len		Length of setting data, or negative error
2194
+ */
2195
+static int version_fetch ( void *data, size_t len ) {
2196
+	strncpy ( data, product_version, len );
2197
+	return ( strlen ( product_version ) );
2198
+}
2199
+
2179 2200
 /** List of built-in setting operations */
2180 2201
 static struct builtin_setting_operation builtin_setting_operations[] = {
2181 2202
 	{ &errno_setting, errno_fetch },
2182 2203
 	{ &buildarch_setting, buildarch_fetch },
2183 2204
 	{ &platform_setting, platform_fetch },
2205
+	{ &version_setting, version_fetch },
2184 2206
 };
2185 2207
 
2186 2208
 /**

Načítá se…
Zrušit
Uložit