ソースを参照

[settings] Add "version" builtin setting

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Robin Smidsrød 11年前
コミット
7016164056
1個のファイルの変更22行の追加0行の削除
  1. 22
    0
      src/core/settings.c

+ 22
- 0
src/core/settings.c ファイルの表示

35
 #include <ipxe/base16.h>
35
 #include <ipxe/base16.h>
36
 #include <ipxe/pci.h>
36
 #include <ipxe/pci.h>
37
 #include <ipxe/init.h>
37
 #include <ipxe/init.h>
38
+#include <ipxe/version.h>
38
 #include <ipxe/settings.h>
39
 #include <ipxe/settings.h>
39
 
40
 
40
 /** @file
41
 /** @file
2176
 	return ( sizeof ( platform ) - 1 /* NUL */ );
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
 /** List of built-in setting operations */
2200
 /** List of built-in setting operations */
2180
 static struct builtin_setting_operation builtin_setting_operations[] = {
2201
 static struct builtin_setting_operation builtin_setting_operations[] = {
2181
 	{ &errno_setting, errno_fetch },
2202
 	{ &errno_setting, errno_fetch },
2182
 	{ &buildarch_setting, buildarch_fetch },
2203
 	{ &buildarch_setting, buildarch_fetch },
2183
 	{ &platform_setting, platform_fetch },
2204
 	{ &platform_setting, platform_fetch },
2205
+	{ &version_setting, version_fetch },
2184
 };
2206
 };
2185
 
2207
 
2186
 /**
2208
 /**

読み込み中…
キャンセル
保存