PMEM2_SOURCE_DELETE(3)
π PMEM2_SOURCE_DELETE(3) π
okay bestie, so this is a page from the PMDK Programmer's Manual and it's all about making and yeeting a persistent memory data source. yes, that PMDK. the memory one. sit down, grab a strawberry π, we're doing this.
β¨ NAME β¨
pmem2_source_from_fd(), pmem2_source_delete() β creates or deletes an instance of persistent memory data source. that's it. that's the whole job. one makes it, one un-makes it. iconic duo behavior, honestly π«Ά
β¨ SYNOPSIS β¨
#include <libpmem2.h>
int pmem2_source_from_fd(struct pmem2_source *src, int fd);
int pmem2_source_delete(struct pmem2_source **src);
no cap, that's the whole vibe. two little functions. one include. slay. π
β¨ DESCRIPTION β¨
so. pmem2_source_from_fd() is the one that validates your file descriptor and then instantiates a brand new struct pmem2_source * object that describes the data source. it's giving "I checked your ID and you're on the list, come in" π
and listen, fd must be opened with O_RDONLY or O_RDWR mode. those are the only two fits it's accepting. if fd is invalid? the function fails. periodt. π
then there's pmem2_source_delete(), our cleanup queen π. she frees *src that came back from pmem2_source_from_fd() and sets *src to NULL. and if *src is already NULL? she does literally nothing. no drama, no crash, just vibes. the way that she's polite about it π
β¨ RETURN VALUE β¨
pmem2_source_from_fd()returns0on success, or a negative error code on failure. so if you see a negative number, that's not a vibe check you passed bestie.pmem2_source_delete()always returns0. always. she has never known failure. main character energy fr fr. β¨
β¨ ERRORS β¨
pmem2_source_from_fd() can fail with the following errors, so let's go through them one by one:
PMEM2_E_INVALID_FILE_HANDLEβfdis not an open and valid file descriptor. sorry babe, that handle is not real.PMEM2_E_INVALID_FILE_HANDLEβfdis opened inO_WRONLYmode. yeah no, write-only is NOT it. we don't do that here πPMEM2_E_INVALID_FILE_TYPEβfdpoints to a directory, block device, pipe, or socket. cute but wrong genre of file.PMEM2_E_INVALID_FILE_TYPEβfdpoints to a character device other than Device DAX. so likeβ¦ a character device that isn't Device DAX? nope, not on the guest list.
also, pmem2_source_from_fd() can return -ENOMEM in case of insufficient memory to allocate an instance of struct pmem2_source. ran out of room, the mall is full, we cannot allocate π
heads up bestie: notice how two of those errors share a name and two share another name β that's not a typo, that's literally how it's written. keep it exactly as-is, iykyk.
β¨ SEE ALSO β¨
go read these next, they're the rest of the lore:
errno(3)pmem2_map_new(3)libpmem2(7)- and the mothership herself: https://pmem.io π
and that's the page!! thanks for coming to my ted talk. this was PMDK, dated 2025-07-24. love u, go delete some sources responsibly πβ¨ππ¦
π¦ where this page comes from
- fedora 43: libpmem2-devel 2.1.0-4.fc43 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright 2019-2023, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms