PMEM2_MAP_FROM_EXISTING(3)
π pmem2_map_from_existing π
okay bestie, welcome to the PMDK Programmer's Manual πΈ β this one's about pmem2_map_from_existing(), and fr fr it's the glow-up your existing mapping deserves β¨
π NAME π
pmem2_map_from_existing() β creates a pmem2_map object from an existing mapping π
π SYNOPSIS π
#include <libpmem2.h>
int pmem2_map_from_existing(struct pmem2_map **map, const struct pmem2_source *src,
void *addr, size_t len, enum pmem2_granularity gran);
β¨ DESCRIPTION β¨
so basically, pmem2_map_from_existing() hands you back a brand new *struct pmem2_map for a mapping you already brought to the party π«Ά like, the user provides the mapping, and this function is the one that wraps it up cute.
the whole point? it lets you use the libpmem2(7) API without having to call pmem2_map_new(3) to map a file. no cap. π
your mapping is defined by addr and len β those two are the vibe check for what region we're talking about. you also have to specify the underlying file as src, and you gotta define the granularity of this mapping with gran. lowkey important.
for the deets on granularity, go peek at pmem2_config_set_required_store_granularity(3) and libpmem2(7) β they spill the tea β
β οΈ real talk, don't skip this one: for apmem2_mapobject created by thepmem2_map_from_existing(3)function,pmem2_map_delete(3)will only destroy the object β it will not unmap the mapping this object describes. it's giving "I'll clean my room" but only the object part. π the mapping itself stays mapped, bestie.
π₯ RETURN VALUE π₯
pmem2_map_from_existing() returns 0 when it succeeds π or a negative error code on failure π
π ERRORS π
pmem2_map_from_existing() can fail with the following errors:
PMEM2_E_MAPPING_EXISTSβ when the contiguous region(addr, addr + len)is already registered bylibpmem2π βοΈ like, girl, that spot is taken.
it can also return -ENOMEM from the underlying malloc(2) function π
π SEE ALSO π
malloc(2), pmem2_map_delete(3), pmem2_map_new(3), pmem2_source_from_fd(3), libpmem2(7) and https://pmem.io π
okay that's the whole page, bestie, you ate that π this was the PMDK era, dated 2025-07-24 β go forth and map responsibly, mwah ππ¦
π¦ 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 2020-2021, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms