PMEM2_SOURCE_SIZE(3)
β¨ PMEM2_SOURCE_SIZE(3) β¨
okay bestie, welcome to the PMDK Programmer's Manual π you're about to learn how to ask a data source how big it is. it's giving "how many bytes are you, babe" and honestly? iconic.
πΈ NAME πΈ
pmem2_source_size() β returns the size of the data source
π SYNOPSIS π
#include <libpmem2.h>
struct pmem2_source;
int pmem2_source_size(const struct pmem2_source *source, size_t *size);
π¦ DESCRIPTION π¦
So basically, pmem2_source_size() goes and gets the size of the file β in bytes β the one pointed at by the file descriptor that's chillin' inside source. and then it just... drops it into *size. like a little gift. π
The way this function is lowkey a hero: it hides all the quirkiness of Device DAX size detection. you don't gotta deal with that mess. it does. periodt. π
π RETURN VALUE π
pmem2_source_size() returns 0 on success. slay. β¨
but if it fails? the *size variable is left unmodified (like, untouched, no notes) and a negative error code is returned. sad girl hours. π
π ERRORS π
pmem2_source_size() can fail with the following errors, bestie, so listen up:
PMEM2_E_INVALID_FILE_HANDLEβ source contains an invalid file handle. not it. πPMEM2_E_INVALID_FILE_TYPEβ the file descriptor points to a directory, block device, pipe, or socket. wrong vibe entirely.PMEM2_E_INVALID_FILE_TYPEβ the file descriptor points to a character device that is not a Device DAX. close but no. πPMEM2_E_INVALID_SIZE_FORMATβ the kernel query for the Device DAX size came back with data in an invalid format. the kernel was not serving. π-errnoset by failingfstat(2), while trying to validate the file descriptor.-errnoset by failingrealpath(3), while trying to determine whether fd points to a Device DAX.-errnoset by failingopen(2), while trying to determine Device DAX's size.-errnoset by failingread(2), while trying to determine Device DAX's size.-errnoset by failingstrtoull(3), while trying to determine Device DAX's size.
π SEE ALSO π
errno(3), fstat(2), realpath(3), open(2), read(2), strtoull(3), pmem2_config_new(3), libpmem2(7) and https://pmem.io
go read those too, iykyk π«Ά
that's the whole page, bestie. this one's from the PMDK crew, dated 2025-07-24 β yeah she's a 2025 girlie and she ate. 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 2019-2023, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms