ubifs_check_node(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ubifs_check_node(9) β€” the kernel API manual, but make it make sense πŸŽ€

okay so bestie, welcome to ubifs_check_node(9) from the Kernel API Manual ✨ this is literally the vibe-check function for UBIFS nodes and you're gonna slay understanding it, i promise 🫢


✨ NAME ✨

ubifs_check_node β€” check node. that's it. that's the whole name. iconic brevity πŸ’…


🌸 SYNOPSIS 🌸

int ubifs_check_node (const struct ubifs_info *c , const void *buf , int
len , int lnum , int offs , int quiet , int must_chk_crc );

like, seven arguments bestie. seven. but we handle it πŸ’ͺ


πŸ¦‹ ARGUMENTS πŸ¦‹

  • c β€” the UBIFS file-system description object. the main character of this whole operation ngl πŸ‘‘
  • buf β€” node to check. the thing we're scrutinizing under a magnifying glass πŸ”
  • len β€” node length. how big the node is fr fr
  • lnum β€” logical eraseblock number. which eraseblock we're in, iykyk
  • offs β€” offset within the logical eraseblock. exactly where inside it, no cap πŸ“
  • quiet β€” print no messages. silence mode activated 🀫
  • must_chk_crc β€” indicates whether to always check the CRC. no skipping, no excuses, we're checking it πŸ’€

πŸ’– DESCRIPTION πŸ’–

so what does this function actually do?? it checks the node magic number and the CRC checksum. that's the core slay ✨

but ALSO β€” and this part is lowkey important β€” it validates node length to prevent UBIFS from becoming crazy when an attacker feeds it a file-system image with incorrect nodes. like, genuinely dangerous energy. for example, a too large node length in the common header could cause UBIFS to read memory outside of allocated buffer when checking the CRC checksum 😭 so yeah, this length check is doing the lord's work 🫢

okay now the nuance, pay attention bestie:

this function may skip data nodes CRC checking if c->no_chk_data_crc is true, which is controlled by corresponding UBIFS mount option. so that's the default-ish shortcut path.

but wait πŸ‘€ there are exceptions where the skip gets IGNORED.
  • if must_chk_crc is true, then c->no_chk_data_crc is ignored and CRC is checked. periodt.
  • similarly, if c->mounting or c->remounting_rw is true (we are mounting or re-mounting to R/W mode), c->no_chk_data_crc is ignored and CRC is checked.

and why?? bestie i'm so glad you asked πŸ’œ this is because during mounting or re-mounting from R/O mode to R/W mode we may read journal nodes (when replying the journal or doing the recovery) and the journal nodes may potentially be corrupted, so checking is required. safety first always 🧚

this function returns zero in case of success and -EUCLEAN in case of bad CRC or magic. two outcomes, both valid, one of them is not great πŸ’€


πŸŽ€ SEE ALSO πŸŽ€

Kernel file ./fs/ubifs/io.c β€” and like, the whole friend group of related functions:


and that's the whole page bestie!! 🌈 it lives in ./fs/ubifs, dated October 2026 β€” go off, kernel docs, we stan a timestamped source πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from