Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
e306220c bdac5c2b

+25
+2
include/linux/bootconfig.h
··· 273 273 /* XBC node initializer */ 274 274 int __init xbc_init(const char *buf, size_t size, const char **emsg, int *epos); 275 275 276 + /* XBC node and size information */ 277 + int __init xbc_get_info(int *node_size, size_t *data_size); 276 278 277 279 /* XBC cleanup data structures */ 278 280 void __init xbc_destroy_all(void);
+1
init/main.c
··· 450 450 pr_err("Failed to parse bootconfig: %s at %d.\n", 451 451 msg, pos); 452 452 } else { 453 + xbc_get_info(&ret, NULL); 453 454 pr_info("Load bootconfig: %d bytes %d nodes\n", size, ret); 454 455 /* keys starting with "kernel." are passed via cmdline */ 455 456 extra_command_line = xbc_make_cmdline("kernel");
+21
lib/bootconfig.c
··· 34 34 static int open_brace[XBC_DEPTH_MAX] __initdata; 35 35 static int brace_index __initdata; 36 36 37 + /** 38 + * xbc_get_info() - Get the information of loaded boot config 39 + * node_size: A pointer to store the number of nodes. 40 + * data_size: A pointer to store the size of bootconfig data. 41 + * 42 + * Get the number of used nodes in @node_size if it is not NULL, 43 + * and the size of bootconfig data in @data_size if it is not NULL. 44 + * Return 0 if the boot config is initialized, or return -ENODEV. 45 + */ 46 + int __init xbc_get_info(int *node_size, size_t *data_size) 47 + { 48 + if (!xbc_data) 49 + return -ENODEV; 50 + 51 + if (node_size) 52 + *node_size = xbc_node_num; 53 + if (data_size) 54 + *data_size = xbc_data_size; 55 + return 0; 56 + } 57 + 37 58 static int __init xbc_parse_error(const char *msg, const char *p) 38 59 { 39 60 xbc_err_msg = msg;
+1
tools/bootconfig/main.c
··· 391 391 return ret; 392 392 } 393 393 printf("Apply %s to %s\n", xbc_path, path); 394 + xbc_get_info(&ret, NULL); 394 395 printf("\tNumber of nodes: %d\n", ret); 395 396 printf("\tSize: %u bytes\n", (unsigned int)size); 396 397 printf("\tChecksum: %d\n", (unsigned int)csum);