fs/ubifs/lpt.c
Source file repositories/reference/linux-study-clean/fs/ubifs/lpt.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ubifs/lpt.c- Extension
.c- Size
- 63151 bytes
- Lines
- 2436
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ubifs.hlinux/crc16.hlinux/math64.hlinux/slab.h
Detected Declarations
struct lpt_scan_nodefunction Copyrightfunction ubifs_calc_lpt_geomfunction calc_dflt_lpt_geomfunction pack_bitsfunction ubifs_unpack_bitsfunction ubifs_pack_pnodefunction ubifs_pack_nnodefunction ubifs_pack_ltabfunction ubifs_pack_lsavefunction ubifs_add_lpt_dirtfunction set_ltabfunction ubifs_add_nnode_dirtfunction add_pnode_dirtfunction calc_nnode_numfunction calc_nnode_num_from_parentfunction calc_pnode_num_from_parentfunction ubifs_create_dflt_lptfunction update_catsfunction replace_catsfunction check_lpt_crcfunction check_lpt_typefunction unpack_pnodefunction ubifs_unpack_nnodefunction unpack_ltabfunction unpack_lsavefunction validate_nnodefunction validate_pnodefunction set_pnode_lnumfunction ubifs_read_nnodefunction read_pnodefunction read_ltabfunction read_lsavefunction ubifs_lpt_calc_hashfunction lpt_check_hashfunction lpt_init_rdfunction lpt_init_wrfunction ubifs_lpt_initfunction ubifs_lpt_scan_nolockfunction dbg_chk_pnodefunction list_for_each_entryfunction dbg_check_lpt_nodes
Annotated Snippet
struct lpt_scan_node {
union {
struct ubifs_nnode nnode;
struct ubifs_pnode pnode;
struct ubifs_cnode cnode;
};
int in_tree;
union {
struct ubifs_nnode *nnode;
struct ubifs_pnode *pnode;
struct ubifs_cnode *cnode;
} ptr;
};
/**
* scan_get_nnode - for the scan, get a nnode from either the tree or flash.
* @c: the UBIFS file-system description object
* @path: where to put the nnode
* @parent: parent of the nnode
* @iip: index in parent of the nnode
*
* This function returns a pointer to the nnode on success or a negative error
* code on failure.
*/
static struct ubifs_nnode *scan_get_nnode(struct ubifs_info *c,
struct lpt_scan_node *path,
struct ubifs_nnode *parent, int iip)
{
struct ubifs_nbranch *branch;
struct ubifs_nnode *nnode;
void *buf = c->lpt_nod_buf;
int err;
branch = &parent->nbranch[iip];
nnode = branch->nnode;
if (nnode) {
path->in_tree = 1;
path->ptr.nnode = nnode;
return nnode;
}
nnode = &path->nnode;
path->in_tree = 0;
path->ptr.nnode = nnode;
memset(nnode, 0, sizeof(struct ubifs_nnode));
if (branch->lnum == 0) {
/*
* This nnode was not written which just means that the LEB
* properties in the subtree below it describe empty LEBs. We
* make the nnode as though we had read it, which in fact means
* doing almost nothing.
*/
if (c->big_lpt)
nnode->num = calc_nnode_num_from_parent(c, parent, iip);
} else {
err = ubifs_leb_read(c, branch->lnum, buf, branch->offs,
c->nnode_sz, 1);
if (err)
return ERR_PTR(err);
err = ubifs_unpack_nnode(c, buf, nnode);
if (err)
return ERR_PTR(err);
}
err = validate_nnode(c, nnode, parent, iip);
if (err)
return ERR_PTR(err);
if (!c->big_lpt)
nnode->num = calc_nnode_num_from_parent(c, parent, iip);
nnode->level = parent->level - 1;
nnode->parent = parent;
nnode->iip = iip;
return nnode;
}
/**
* scan_get_pnode - for the scan, get a pnode from either the tree or flash.
* @c: the UBIFS file-system description object
* @path: where to put the pnode
* @parent: parent of the pnode
* @iip: index in parent of the pnode
*
* This function returns a pointer to the pnode on success or a negative error
* code on failure.
*/
static struct ubifs_pnode *scan_get_pnode(struct ubifs_info *c,
struct lpt_scan_node *path,
struct ubifs_nnode *parent, int iip)
{
struct ubifs_nbranch *branch;
struct ubifs_pnode *pnode;
void *buf = c->lpt_nod_buf;
Annotation
- Immediate include surface: `ubifs.h`, `linux/crc16.h`, `linux/math64.h`, `linux/slab.h`.
- Detected declarations: `struct lpt_scan_node`, `function Copyright`, `function ubifs_calc_lpt_geom`, `function calc_dflt_lpt_geom`, `function pack_bits`, `function ubifs_unpack_bits`, `function ubifs_pack_pnode`, `function ubifs_pack_nnode`, `function ubifs_pack_ltab`, `function ubifs_pack_lsave`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.