ubifs_compress_folio(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ubifs_compress_folio (Kernel API Manual, bestie) πŸ’…

Okay so real talk, this one is from the Kernel API Manual and it's genuinely so useful once it clicks. Strap in πŸŽ€

✨ NAME ✨

ubifs_compress_folio β€” compress folio. That's the whole vibe. It compresses a folio, no cap. πŸ¦‹

🌸 SYNOPSIS 🌸

void ubifs_compress_folio (const struct ubifs_info *c , struct folio
*in_folio , size_t in_offset , int in_len , void *out_buf , int *out_len
, int *compr_type );

Yes it returns void, yes there are seven arguments, and yes we're gonna go through every single one of them because that's just who I am πŸ’…

🧚 ARGUMENTS 🧚

  • c β€” the UBIFS file-system description object. Your whole filesystem's little identity card, basically πŸ‘‘
  • in_folio β€” the data to compress. The main character of this function, fr 🫢
  • in_offset β€” offset into in_folio. Like, where in the folio we actually start looking.
  • in_len β€” length of the data to compress. How much of it we're grabbing.
  • out_buf β€” output buffer where the compressed data should be stored. The destination, the moment, the slay ✨
  • out_len β€” output buffer length is returned here. So you hand it a pointer and it writes the length back. It's giving "I'll tell you how big it ended up being" 😌
  • compr_type β€” type of compression to use on enter, and the actually used compression type on exit. Lowkey a two-way street, it reads it on the way in and rewrites it on the way out πŸ”₯

πŸ’– DESCRIPTION πŸ’–

So what does it do? It compresses the input folio in_folio of length in_len, and it stores the result in the output buffer out_buf plus the resulting length in out_len. Iconic behavior, truly. πŸŽ€

But here's the part everyone forgets: if the input buffer does not compress, it's just copied to out_buf. No drama, no error, it just gets yeeted straight through as-is. And the exact same thing happens if compr_type is UBIFS_COMPR_NONE β€” or if a compression error occurred. So like, three different roads, all leading to "fine, we copy it then" πŸ’€

Note, and this is the important bit bestie: if the input buffer was not compressed, it is copied to the output buffer and UBIFS_COMPR_NONE is returned in compr_type. So always check compr_type after, iykyk πŸ‘€

🌈 SEE ALSO 🌈

Kernel file ./fs/ubifs/compress.c, plus the whole friend group:


And that's the page! πŸ“ Huge thanks to ./fs/ubifs for existing, dated October 2026, and to this manual page itself for being ubifs_compress_folio(9) β€” go compress something, bestie, you got this πŸ’œβœ¨

πŸ“¦ where this page comes from