lib/bootconfig.c
Source file repositories/reference/linux-study-clean/lib/bootconfig.c
File Facts
- System
- Linux kernel
- Corpus path
lib/bootconfig.c- Extension
.c- Size
- 24409 bytes
- Lines
- 1066
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bootconfig.hlinux/bug.hlinux/ctype.hlinux/errno.hlinux/cache.hlinux/compiler.hlinux/sprintf.hlinux/memblock.hlinux/string.h
Detected Declarations
function xbc_get_embedded_bootconfigfunction xbc_alloc_memfunction xbc_free_memfunction xbc_free_memfunction xbc_get_infofunction xbc_parse_errorfunction xbc_root_nodefunction xbc_node_indexfunction xbc_node_get_parentfunction xbc_node_get_childfunction xbc_node_get_nextfunction xbc_node_get_datafunction xbc_node_match_prefixfunction xbc_node_find_subkeyfunction xbc_node_find_valuefunction xbc_node_compose_key_afterfunction xbc_node_find_next_leaffunction xbc_node_find_next_key_valuefunction xbc_snprint_cmdlinefunction xbc_node_for_each_key_valuefunction xbc_array_for_each_valuefunction xbc_init_nodefunction xbc_add_nodefunction __xbc_add_siblingfunction xbc_add_siblingfunction xbc_add_head_siblingfunction xbc_valid_keywordfunction __xbc_open_bracefunction __xbc_close_bracefunction __xbc_parse_valuefunction xbc_parse_arrayfunction __xbc_add_keyfunction __xbc_parse_keysfunction xbc_parse_kvfunction xbc_parse_keyfunction xbc_open_bracefunction xbc_close_bracefunction xbc_verify_treefunction xbc_parse_treefunction _xbc_exitfunction xbc_init
Annotated Snippet
if (ret >= size) {
size = 0;
} else {
size -= ret;
buf += ret;
}
total += ret;
}
return total;
}
/**
* xbc_node_find_next_leaf() - Find the next leaf node under given node
* @root: An XBC root node
* @node: An XBC node which starts from.
*
* Search the next leaf node (which means the terminal key node) of @node
* under @root node (including @root node itself).
* Return the next node or NULL if next leaf node is not found.
*/
struct xbc_node * __init xbc_node_find_next_leaf(struct xbc_node *root,
struct xbc_node *node)
{
struct xbc_node *next;
if (unlikely(!xbc_data))
return NULL;
if (!node) { /* First try */
node = root;
if (!node)
node = xbc_nodes;
} else {
/* Leaf node may have a subkey */
next = xbc_node_get_subkey(node);
if (next) {
node = next;
goto found;
}
if (node == root) /* @root was a leaf, no child node. */
return NULL;
while (!node->next) {
node = xbc_node_get_parent(node);
if (node == root)
return NULL;
/* User passed a node which is not under parent */
if (WARN_ON(!node))
return NULL;
}
node = xbc_node_get_next(node);
}
found:
while (node && !xbc_node_is_leaf(node))
node = xbc_node_get_child(node);
return node;
}
/**
* xbc_node_find_next_key_value() - Find the next key-value pair nodes
* @root: An XBC root node
* @leaf: A container pointer of XBC node which starts from.
*
* Search the next leaf node (which means the terminal key node) of *@leaf
* under @root node. Returns the value and update *@leaf if next leaf node
* is found, or NULL if no next leaf node is found.
* Note that this returns 0-length string if the key has no value, or
* the value of the first entry if the value is an array.
*/
const char * __init xbc_node_find_next_key_value(struct xbc_node *root,
struct xbc_node **leaf)
{
/* tip must be passed */
if (WARN_ON(!leaf))
return NULL;
*leaf = xbc_node_find_next_leaf(root, *leaf);
if (!*leaf)
return NULL;
if ((*leaf)->child)
return xbc_node_get_data(xbc_node_get_child(*leaf));
else
return ""; /* No value key */
}
static char xbc_namebuf[XBC_KEYLEN_MAX] __initdata;
Annotation
- Immediate include surface: `linux/bootconfig.h`, `linux/bug.h`, `linux/ctype.h`, `linux/errno.h`, `linux/cache.h`, `linux/compiler.h`, `linux/sprintf.h`, `linux/memblock.h`.
- Detected declarations: `function xbc_get_embedded_bootconfig`, `function xbc_alloc_mem`, `function xbc_free_mem`, `function xbc_free_mem`, `function xbc_get_info`, `function xbc_parse_error`, `function xbc_root_node`, `function xbc_node_index`, `function xbc_node_get_parent`, `function xbc_node_get_child`.
- Atlas domain: Kernel Services / lib.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.