PMEM2_BADBLOCK_NEXT(3)

πŸ’– PMEM2_BADBLOCK_NEXT(3) πŸ’–

okay bestie, welcome to the PMDK Programmer's Manual ✨ this one's a lil function called pmem2_badblock_next() and honestly? it's giving "sequel energy" β€” it just reads the next bad block for a bad block context. that's it. that's the whole job. and it eats. πŸ’…


🌸 NAME 🌸

pmem2_badblock_next() β€” read the next bad block for the given bad block context *bbctx.

like, the next one. the one after the one you already looked at. slay.


✨ SYNOPSIS ✨

#include <libpmem2.h>

struct pmem2_badblock;
struct pmem2_badblock_context;

int pmem2_badblock_next(
        struct pmem2_badblock_context *bbctx,
        struct pmem2_badblock *bb);

no cap, that's the whole signature 🫢 two structs declared up front, one function that takes a pointer to a bad block context and a pointer to a bad block. iconic.


πŸ¦‹ DESCRIPTION πŸ¦‹

The pmem2_badblock_next() function reads the next bad block for the given bad block context *bbctx.

that's the vibe check, fr fr. you hand it your *bbctx, it goes and finds the next bad block, and it drops it right into *bb. it's basically a little iterator moment β€” call it again, get the next one, call it again, keep going, main character energy until there's nothing left. ✨


πŸŽ€ RETURN VALUE πŸŽ€

so here's the deal:

  • on success, pmem2_badblock_next() returns 0 and stores the next bad block in *bb πŸ’–
  • if there are no more bad blocks for the given bad block context *bbctx, it returns a negative error code 😭

yes queen, 0 means good, negative means we've run out. periodt.


πŸ”₯ ERRORS πŸ”₯

pmem2_badblock_next() can fail with the following error:

  • PMEM2_E_NO_BAD_BLOCK_FOUND β€” there are no more bad blocks for the given bad block context *bbctx, and *bb is undefined in this case. 🫠
bestie listen to me. *bb is undefined here. do not go reading it, do not go printing it, do not pass go. we do not touch undefined values in this house. πŸ™ˆ
  • PMEM2_E_NOSUPP β€” when the OS does not support this functionality. πŸ’€

🌈 SEE ALSO 🌈

go read those too, iykyk πŸ‘‘


okay that's the whole page bestie, no notes πŸ’œ this was the PMDK Programmer's Manual entry for pmem2_badblock_next(), and the footer said PMDK and dated it 2025-07-24 β€” so shoutout to the PMDK girlies and that date, mwah πŸŽ€βœ¨ bye pookie, go read some more manpages πŸ’…

πŸ“¦ where this page comes from