PMEM2_SOURCE_GET_FD(3)

πŸ’– pmem2_source_get_fd() β€” PMDK Programmer's Manual πŸ’–

okay bestie, gather round, because today we're getting the file descriptor out of a data source and honestly? it's giving one-liner legend. this is a page from the PMDK Programmer's Manual, and it's short, it's sweet, it's iconic. no cap. πŸŽ€


✨ NAME ✨

pmem2_source_get_fd() β€” reads file descriptor of the data source


🌸 SYNOPSIS 🌸

#include <libpmem2.h>

int pmem2_source_get_fd(const struct pmem2_source *src, int *fd);

like… that's it. that's the whole vibe. one function, two args, zero drama. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the pmem2_source_get_fd() function reads the file descriptor of the struct pmem2_source object that's describing your data source, and hands it back to you through the fd parameter. that's the whole thing. it's a little peek-behind-the-curtain moment β€” you pass in your source, you get the fd back through the pointer. 🫢

lowkey the most straightforward function on this whole manual page, and we love her for that.


⭐ RETURN VALUE ⭐

  • 0 on success β€” slay, you got your fd πŸŽ‰
  • a negative error code on failure β€” not slay, go check ERRORS below

πŸ’€ ERRORS πŸ’€

pmem2_source_get_fd() can fail with the following errors:

  • PMEM2_E_FILE_DESCRIPTOR_NOT_SET β€” this one hits when you've got an instance of struct pmem2_source that does not come from a source type that supports file descriptors, eg. an anonymous data source. so basically: no fd to read, bestie, because there was never one to begin with. πŸ™ˆ
fr fr, if your source is anonymous, don't come looking for a file descriptor. she's not there. she never was. 😭

🌈 SEE ALSO 🌈


and that's the whole page, bestie!! this was PMEM2_SOURCE_GET_FD(3) from the PMDK Programmer's Manual, dated 2025-07-24, brought to you by the fine humans of the PMDK project. go forth, grab those file descriptors, and stay iconic. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ‘‘πŸŒˆ

πŸ“¦ where this page comes from