bootconfig: Add xbc_get_info() for the node information
Add xbc_get_info() API which allows user to get the number of used xbc_nodes and the size of bootconfig data. This is also useful for checking the bootconfig is initialized or not. Link: https://lkml.kernel.org/r/163177340877.682366.4360676589783197627.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
Родитель
bdac5c2b24
Коммит
e306220cb7
|
@ -273,6 +273,8 @@ static inline int __init xbc_node_compose_key(struct xbc_node *node,
|
||||||
/* XBC node initializer */
|
/* XBC node initializer */
|
||||||
int __init xbc_init(const char *buf, size_t size, const char **emsg, int *epos);
|
int __init xbc_init(const char *buf, size_t size, const char **emsg, int *epos);
|
||||||
|
|
||||||
|
/* XBC node and size information */
|
||||||
|
int __init xbc_get_info(int *node_size, size_t *data_size);
|
||||||
|
|
||||||
/* XBC cleanup data structures */
|
/* XBC cleanup data structures */
|
||||||
void __init xbc_destroy_all(void);
|
void __init xbc_destroy_all(void);
|
||||||
|
|
|
@ -450,6 +450,7 @@ static void __init setup_boot_config(void)
|
||||||
pr_err("Failed to parse bootconfig: %s at %d.\n",
|
pr_err("Failed to parse bootconfig: %s at %d.\n",
|
||||||
msg, pos);
|
msg, pos);
|
||||||
} else {
|
} else {
|
||||||
|
xbc_get_info(&ret, NULL);
|
||||||
pr_info("Load bootconfig: %d bytes %d nodes\n", size, ret);
|
pr_info("Load bootconfig: %d bytes %d nodes\n", size, ret);
|
||||||
/* keys starting with "kernel." are passed via cmdline */
|
/* keys starting with "kernel." are passed via cmdline */
|
||||||
extra_command_line = xbc_make_cmdline("kernel");
|
extra_command_line = xbc_make_cmdline("kernel");
|
||||||
|
|
|
@ -34,6 +34,27 @@ static int xbc_err_pos __initdata;
|
||||||
static int open_brace[XBC_DEPTH_MAX] __initdata;
|
static int open_brace[XBC_DEPTH_MAX] __initdata;
|
||||||
static int brace_index __initdata;
|
static int brace_index __initdata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xbc_get_info() - Get the information of loaded boot config
|
||||||
|
* node_size: A pointer to store the number of nodes.
|
||||||
|
* data_size: A pointer to store the size of bootconfig data.
|
||||||
|
*
|
||||||
|
* Get the number of used nodes in @node_size if it is not NULL,
|
||||||
|
* and the size of bootconfig data in @data_size if it is not NULL.
|
||||||
|
* Return 0 if the boot config is initialized, or return -ENODEV.
|
||||||
|
*/
|
||||||
|
int __init xbc_get_info(int *node_size, size_t *data_size)
|
||||||
|
{
|
||||||
|
if (!xbc_data)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
if (node_size)
|
||||||
|
*node_size = xbc_node_num;
|
||||||
|
if (data_size)
|
||||||
|
*data_size = xbc_data_size;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int __init xbc_parse_error(const char *msg, const char *p)
|
static int __init xbc_parse_error(const char *msg, const char *p)
|
||||||
{
|
{
|
||||||
xbc_err_msg = msg;
|
xbc_err_msg = msg;
|
||||||
|
|
|
@ -391,6 +391,7 @@ static int apply_xbc(const char *path, const char *xbc_path)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
printf("Apply %s to %s\n", xbc_path, path);
|
printf("Apply %s to %s\n", xbc_path, path);
|
||||||
|
xbc_get_info(&ret, NULL);
|
||||||
printf("\tNumber of nodes: %d\n", ret);
|
printf("\tNumber of nodes: %d\n", ret);
|
||||||
printf("\tSize: %u bytes\n", (unsigned int)size);
|
printf("\tSize: %u bytes\n", (unsigned int)size);
|
||||||
printf("\tChecksum: %d\n", (unsigned int)csum);
|
printf("\tChecksum: %d\n", (unsigned int)csum);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче