PMEMLOG_APPENDV(3)

πŸ“¦
version 1.13.1 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– PMEMLOG_APPEND πŸ’–

okay bestie, welcome to pmemlog_append() and pmemlog_appendv() β€” two little legends from the PMDK Programmer's Manual πŸ’…

⚠️ heads up queen: both of these are DEPRECATED. Like, they still work, but they're giving "we don't talk about that era anymore". Use with the knowledge that the universe is gently side-eyeing them.

They do one thing and they do it fabulously: append bytes to the persistent memory resident log file. periodt. ✨


πŸ“œ SYNOPSIS

#include <libpmemlog.h>

int pmemlog_append(PMEMlogpool *plp, const void *buf, size_t count);
int pmemlog_appendv(PMEMlogpool *plp, const struct iovec *iov, int iovcnt);

🌸 DESCRIPTION

✨ pmemlog_append()

So basically, pmemlog_append() takes count bytes from buf and appends them to the current write offset in the log memory pool plp. It's literally the same energy as appending to a file β€” you know the vibe.

And here's the slay part: the append is atomic and cannot be torn by a program failure or system crash. no cap. πŸ’€πŸ”₯

✨ pmemlog_appendv()

pmemlog_appendv() appends to the log memory pool plp from the scatter/gather list iov, in a manner similar to writev(2). The entire list of buffers gets appended atomically, as if the buffers in iov were concatenated in order. πŸ¦‹

And same deal: the append is atomic and cannot be torn by a program failure or system crash. iconic behaviour fr fr πŸ’–


πŸŽ€ RETURN VALUE

On success, both pmemlog_append() and pmemlog_appendv() return 0. πŸ₯³

On error, they return -1 and set errno appropriately. (yes bestie, that's the standard "something went wrong" ritual.)


😭 ERRORS

  • EINVAL β€” the vector count iovcnt is less than zero. ma'am. that's not a number of buffers, that's a cry for help.
  • ENOSPC β€” there is no room for the data in the log file. the log said "full, not accepting new entries, respectfully". 🚫
  • EROFS β€” the log file is open in read-only mode. you cannot write to it. you simply cannot. read-only means read-only, babe. πŸ™ˆ

🧚 NOTES

okay so this is important and lowkey kinda unhinged: since libpmemlog(7) is designed as a low-latency code path, many of the checks that the operating system routinely does for writev(2) are just not practical in the library's implementation of pmemlog_appendv().

πŸ’€ Not a single attempt is made to detect NULL or incorrect pointers. For example. None. Zero. It's giving "you're on your own, bestie, but with love".

So like, please double-check your own pointers. The library trusts you completely and that is both beautiful and terrifying. 🫢


πŸ‘‘ SEE ALSO

writev(2), libpmemlog(7) and <https://pmem.io>


PMDK Β· 2023-05-31 β€” that's the source, the version, and the date, mwah πŸ’‹ hope this helped, go forth and append responsibly, ily πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from