PMEMLOG_REWIND(3)
π pmemlog_tell(3), pmemlog_rewind(3), pmemlog_walk(3) β PMDK Programmer's Manual π
okay bestie, we're diving into libpmemlog β the PMDK programmer's manual page for three lil functions that are all, sadly, DEPRECATED. Yes, all three. We still love them though. Let's get into it π«Ά
β¨ NAME β¨
pmemlog_tell()(DEPRECATED), pmemlog_rewind()(DEPRECATED), pmemlog_walk()(DEPRECATED) β bestie these check the current write point for the log, or literally walk through the log. that's the whole vibe.
β¨ SYNOPSIS β¨
#include <libpmemlog.h>
long long pmemlog_tell(PMEMlogpool *plp);
void pmemlog_rewind(PMEMlogpool *plp);
void pmemlog_walk(PMEMlogpool *plp, size_t chunksize,
int (*process_chunk)(const void *buf, size_t len, void *arg),
void *arg);
β¨ DESCRIPTION β¨
πΈ pmemlog_tell()
so the pmemlog_tell() function returns the current write point for the log, and it's expressed as a byte offset into the usable log space in the memory pool. β¨
this offset starts off as zero on a newly-created log (baby log, fresh start, no cap π ) and gets incremented by each successful append operation. so basically you can use this function to figure out how much data is currently in the log. it's giving "how full is the cup" energy. π₯€
π¦ pmemlog_rewind()
the pmemlog_rewind() function resets the current write point for the log to zero. after this call, the next append adds to the beginning of the log. yes bestie, we're rewinding it, we're going back to the start, main character origin story fr fr. π
π pmemlog_walk()
the pmemlog_walk() function walks through the log plp, from beginning to end, calling the callback function process_chunk for each chunksize block of data found. πΆβοΈβ¨
- the argument
argis also passed to the callback to help avoid the need for global state (global state? we don't know her π ) - the
chunksizeargument is useful for logs with fixed-length records, and may be specified as0to cause a single call to the callback with the entire log contents passed as thebufargument - the
lenargument tells theprocess_chunkfunction how much databufis holding
the callback function should return 1 if pmemlog_walk() should continue walking through the log, or 0 to terminate the walk. simple as that. π«Ά
β οΈ IMPORTANT BESTIE, READ THIS TWICE β οΈ the callback function is called while holding libpmemlog(7) internal locks that make calls atomic, so the callback function must not try to append to the log itself or deadlock will occur. π deadlock. not cute. do not do it. i'm so serious. π
β¨ RETURN VALUE β¨
on success, pmemlog_tell() returns the current write point for the log. π
on error, it returns -1 and sets errno appropriately. π (classic.)
the pmemlog_rewind() and pmemlog_walk() functions return no value. they're just out here doing the work, no receipts, no return, iconic honestly. π
β¨ SEE ALSO β¨
and that's the page, bestie!! π this was PMDK, dated 2023-05-31 β yeah it's an older one, but she still ate. mwah, go forth and rewind your logs responsibly. ππ¦β¨
π¦ where this page comes from
- debian trixie: libpmemlog-dev 1.13.1-1.1+b1 Β· BSD-3-Clause
- ubuntu noble: libpmemlog-dev 1.13.1-1.1ubuntu2 Β· BSD-3-Clause
- ubuntu questing: libpmemlog-dev 1.13.1-1.1ubuntu3
- ubuntu resolute: libpmemlog-dev 1.13.1-1.1ubuntu4 Β· BSD-3-Clause
- ubuntu stonking: libpmemlog-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