Skip to content

Commit

Permalink
[settings] Add "version" builtin setting
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
robinsmidsrod authored and mcb30 committed Jul 13, 2013
1 parent eba6bb3 commit 7016164
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/core/settings.c
Expand Up @@ -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
Expand Down Expand Up @@ -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 },
};

/**
Expand Down

0 comments on commit 7016164

Please sign in to comment.