PMEM2_SOURCE_DEVICE_ID(3)
β¨ pmem2_source_device_id() β¨
okay bestie, so this one lives in the PMDK Programmer's Manual and it's giving "who even are you, hardware?" energy. It's pmem2_source_device_id() β the function that β¨doxxesβ¨ your device (affectionately). We're talking libpmem2, we're talking NVDIMMs, we're talking the unique identifier of the whole squad of hardware backing your data source. Periodt. π
πΈ NAME πΈ
pmem2_source_device_id() β returns the unique identifier of a device
π SYNOPSIS π
#include <libpmem2.h>
struct pmem2_source;
int pmem2_source_device_id(const struct pmem2_source *source, char *id, size_t *len);
π¦ DESCRIPTION π¦
so like. The pmem2_source_device_id() function retrieves a unique identifier of all the NVDIMMs backing the data source. Not one NVDIMM, bestie β all of them. It's a group project and everyone's getting credited. π«Ά
This function has two operating modes, and honestly the way it flips between them is main character energy:
- if
*idisNULLβ the function calculates a buffer length required for storing the identifier of the*sourcedevice and puts this length in*len. And lowkey the more hardware devices back the data source, the longer the length is. More friends = bigger group chat. π - if
*idis notNULLβ it must point to a buffer of length*lenprovided by the previous call to this function. On success,pmem2_source_device_id()will store a unique identifier of all hardware devices backing the data source. Two-step dance, no skipping step one. β¨
For details on how to use the unique identifier for detecting the unsafe shutdown please refer to libpmem2_unsafe_shutdown(7) manual page. (iykyk β go read it, it's important. π¨)
π RETURN VALUE π
The pmem2_source_device_id() function returns 0 on success. Slay. β
If the function fails, the *id and *len variables contents are left unmodified and a negative error code is returned. Not me leaving your buffer exactly how I found it β no notes, no edits, no crumbs. π
π₯ ERRORS π₯
The pmem2_source_device_id() can fail with the following errors:
PMEM2_E_BUFFER_TOO_SMALLβ the provided buffer of length*lenis too small to store the full identifier of the backing devices. Bestie the bag is too small, we cannot fit. πPMEM2_E_NOSUPPβ the underlying platform does not expose hardware identification. It's giving mystery. It's giving "we don't do that here." π-errnoset by failingfstat(2), while trying to validate the file descriptor.-errnoset by failingndctl_new(), while trying to initiate a new NDCTL library context.
π SEE ALSO π
fstat(2), errno(3), malloc(3), libpmem2_unsafe_shutdown(7), and https://pmem.io
fr fr, that's the whole page. go forth and identify some devices, queen π
PMDK β 2025-07-24 π mwah, thanks for reading, ily, see u in the next manpage πβ¨
π¦ 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-2023, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms