PMEMBLK_READ(3)
π PMEMBLK_READ(3) π
okay bestie, we're in the PMDK Programmer's Manual today and we're talking about pmemblk_read() and pmemblk_write() β the iconic duo that reads and writes blocks from a block memory pool. yes, they're both marked DEPRECATED, we'll get to that, but first let's learn the lore π¦
β¨ NAME β¨
pmemblk_read()(DEPRECATED), pmemblk_write()(DEPRECATED) β read or write a block from a block memory pool π
πΈ SYNOPSIS πΈ
#include <libpmemblk.h>
int pmemblk_read(PMEMblkpool *pbp, void *buf, long long blockno);
int pmemblk_write(PMEMblkpool *pbp, const void *buf, long long blockno);
like, that's it. two little functions. two. and they're carrying the whole block-pool situation on their backs fr fr π
π DESCRIPTION π
π§ pmemblk_read()
the pmemblk_read() function reads the block with block number blockno from memory pool pbp into the buffer buf. that's the whole job. she's a reader, she reads π
and here's the cute part β if you read a block that has never been written by pmemblk_write(), you don't get garbage, you don't get an error, you get a block of zeroes. brand new, all clean, all zeroes. slay β¨
π¦ pmemblk_write()
the pmemblk_write() function writes a block from buf to block number blockno in the memory pool pbp.
and the way that this write is atomic with respect to other reads and writes?? no cap. it's giving main character energy π₯
not only that, but the write cannot be torn by program failure or system crash. on recovery, the block is guaranteed to contain either the old data or the new data, never a mixture of both. no franken-block, no half-and-half nonsense, no "oops we wrote 37 bytes of the new thing and 41 bytes of the old thing". it's one or the other, periodt π
β οΈ heads up bestie: both of these functions are marked DEPRECATED. just so we're clear on the vibe check.
β RETURN VALUE β
- on success π«Ά β both
pmemblk_read()andpmemblk_write()return0 - on error π β they return
-1and seterrnoappropriately
that's it, that's the whole contract. zero means we ate, negative one means check your errno.
π SEE ALSO π
PMDK π written 2023-05-31 π that's the version and date, mwah, take care of her, she's deprecated but she's still iconic ππ
π¦ where this page comes from
- debian trixie: libpmemblk-dev 1.13.1-1.1+b1 Β· BSD-3-Clause
- ubuntu noble: libpmemblk-dev 1.13.1-1.1ubuntu2 Β· BSD-3-Clause
- ubuntu questing: libpmemblk-dev 1.13.1-1.1ubuntu3
- ubuntu resolute: libpmemblk-dev 1.13.1-1.1ubuntu4 Β· BSD-3-Clause
- ubuntu stonking: libpmemblk-dev 1.13.1-1.1ubuntu5 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright 2017-2023, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms