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 *id is NULL β€” the function calculates a buffer length required for storing the identifier of the *source device 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 *id is not NULL β€” it must point to a buffer of length *len provided 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 *len is 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." πŸ™ˆ
  • -errno set by failing fstat(2), while trying to validate the file descriptor.
  • -errno set by failing ndctl_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