logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

pmem2_map_from_existing() - creates a pmem2_map object from an existing mapping

Description

The pmem2_map_from_existing() returns a new *struct pmem2_map formappingprovidedbytheuser.Thisfunctionallowsusageof libpmem2(7)APIwithout pmem2_map_new(3)formappingfile.Mappingisdefinedbyaddrandlen.Youhavetospecifyunderlyingfileasasrc,anddefinegranularityofthismapping.See pmem2_config_set_required_store_granularity(3)and libpmem2**(7) for more details. For the pmem2_map object created by the pmem2_map_from_existing(3) function, the pmem2_map_delete(3) will only destroy the object, but it won’t unmap the mapping this object describes.

Errors

The pmem2_map_from_existing() can fail with the following errors: PMEM2_E_MAPPING_EXISTS - when contiguous region (addr, addr + len) is already registered by libpmem2 It can also return -ENOMEM from the underlying malloc(2) function.

Name

pmem2_map_from_existing() - creates a pmem2_map object from an existing mapping

Return Value

The pmem2_map_from_existing() function returns 0 when it succeeds or a negative error code on failure.

See Also

malloc(2), pmem2_map_delete(3), pmem2_map_new(3), pmem2_source_from_fd(3), libpmem2(7) and <https://pmem.io>

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);

See Also