tools/bootconfig: Show the number of bootconfig nodes
authorMasami Hiramatsu <mhiramat@kernel.org>
Wed, 5 Feb 2020 13:50:13 +0000 (22:50 +0900)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 5 Feb 2020 22:17:05 +0000 (17:17 -0500)
Show the number of bootconfig nodes when applying new bootconfig to
initrd.

Since there are limitations of bootconfig not only in its filesize,
but also the number of nodes, the number should be shown when applying
so that user can get the feeling of scale of current bootconfig.

Link: http://lkml.kernel.org/r/158091061337.27924.10886706631693823982.stgit@devnote2
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
lib/bootconfig.c
tools/bootconfig/main.c

index a98ae13..afb2e76 100644 (file)
@@ -728,7 +728,8 @@ void __init xbc_destroy_all(void)
  *
  * This parses the boot config text in @buf. @buf must be a
  * null terminated string and smaller than XBC_DATA_MAX.
- * Return 0 if succeeded, or -errno if there is any error.
+ * Return the number of stored nodes (>0) if succeeded, or -errno
+ * if there is any error.
  */
 int __init xbc_init(char *buf)
 {
@@ -788,6 +789,8 @@ int __init xbc_init(char *buf)
 
        if (ret < 0)
                xbc_destroy_all();
+       else
+               ret = xbc_node_num;
 
        return ret;
 }
index 91c9a5c..47f4884 100644 (file)
@@ -268,6 +268,7 @@ int apply_xbc(const char *path, const char *xbc_path)
                return ret;
        }
        printf("Apply %s to %s\n", xbc_path, path);
+       printf("\tNumber of nodes: %d\n", ret);
        printf("\tSize: %u bytes\n", (unsigned int)size);
        printf("\tChecksum: %d\n", (unsigned int)csum);