ubifs_check_node(9)
π 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 frlnumβ logical eraseblock number. which eraseblock we're in, iykykoffsβ 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_crcis true, thenc->no_chk_data_crcis ignored and CRC is checked. periodt. - similarly, if
c->mountingorc->remounting_rwis true (we are mounting or re-mounting to R/W mode),c->no_chk_data_crcis 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:
ubifs_ro_mode(9)ubifs_pad(9)next_sqnum(9)ubifs_prepare_node_hmac(9)ubifs_prepare_node(9)ubifs_prep_grp_node(9)wbuf_timer_callback_nolock(9)new_wbuf_timer_nolock(9)cancel_wbuf_timer_nolock(9)ubifs_wbuf_sync_nolock(9)ubifs_wbuf_seek_nolock(9)ubifs_bg_wbufs_sync(9)ubifs_wbuf_write_nolock(9)ubifs_write_node_hmac(9)ubifs_write_node(9)ubifs_read_node_wbuf(9)ubifs_read_node(9)ubifs_wbuf_init(9)ubifs_wbuf_add_ino_nolock(9)wbuf_has_ino(9)ubifs_sync_wbufs_by_inode(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms