PMEMPOOL_CHECK_VERSION(3)
π PMEMPOOL_CHECK_VERSION(3) β the libpmempool era π
okay bestie, sit down, hydrate, because we're about to talk about libpmempool, aka the persistent memory pool management library from the PMDK Programmer's Manual. this is the page about version-checking and error messages, but honestly it's a whole vibe. π¦
β¨ NAME β¨
libpmempool β persistent memory pool management library. she manages pools. she's persistent. she's everything. π
β¨ SYNOPSIS β¨
#include <libpmempool.h>
cc -std=gnu99 ... -lpmempool -lpmem
πΈ Library API versioning πΈ
const char *pmempool_check_version(
unsigned major_required,
unsigned minor_required);
πΈ Error handling πΈ
const char *pmempool_errormsg(void);
πΈ Other library functions πΈ
a description of the other libpmempool functions lives on these man pages, no cap:
- health check functions:
pmempool_check_init(3) - pool set synchronization and transformation:
pmempool_sync(3) - pool set management functions:
pmempool_rm(3) - toggle or query pool set features:
pmempool_feature_query(3)
β¨ DESCRIPTION β¨
so libpmempool hands you a whole set of utilities for off-line analysis and manipulation of a pool. and when we say "a pool" in this manpage, we mean a pmemobj pool β independent of whatever storage is underneath it. some libpmempool functions are required to work without any impact on the pool at all, but bestie, some of them may literally create a new pool or modify one you already have. π
libpmempool is for applications that need high reliability or built-in troubleshooting. it's also lowkey useful for testing and debugging purposes. π
and libpmempool introduces the functionality of pool set health check, synchronization, transformation and removal. the whole glow-up package. β¨
β¨ CAVEATS β¨
libpmempoolrelies on the library destructor being called from the main thread. for this reason, all functions that might trigger destruction (e.g.dlclose(3)) should be called in the main thread. otherwise some of the resources associated with that thread might not be cleaned up properly. not me ignoring this and then wondering why everything's leaking π
also libpmempool requires the -std=gnu99 compilation flag to build properly. that flag is not optional, she is mandatory, periodt. π
β¨ LIBRARY API VERSIONING β¨
this section describes how the library API is versioned, allowing applications to work with an evolving API. growth is beautiful, bestie. π±
the pmempool_check_version() function is used to see if the installed libpmempool supports the version of the library API required by an application. the easiest way to do this for the application is to supply the compile-time version information, supplied by defines in <libpmempool.h>, like this:
reason = pmempool_check_version(PMEMPOOL_MAJOR_VERSION,
PMEMPOOL_MINOR_VERSION);
if (reason != NULL) {
/* version check failed, reason string tells you why */
}
any mismatch in the major version number is considered a failure. but a library with a newer minor version number will pass this check, since increasing minor versions imply backwards compatibility. the way that minor versions just keep it cute and compatible π«Ά
an application can also check specifically for the existence of an interface by checking for the version where that interface was introduced. these versions are documented in this man page as follows: unless otherwise specified, all interfaces described here are available in version 1.0 of the library. interfaces added after version 1.0 will contain the text introduced in version x.y in the section of this manual describing the feature. iykyk. π
when the version check performed by pmempool_check_version() is successful, the return value is NULL. otherwise the return value is a static string describing the reason for failing the version check. the string returned by pmempool_check_version() must not be modified or freed. hands off, she's not yours. π
β¨ DEBUGGING AND ERROR HANDLING β¨
if an error is detected during the call to a libpmempool function, the application may retrieve an error message describing the reason for the failure from pmempool_errormsg(). this function returns a pointer to a static buffer containing the last error message logged for the current thread. if errno was set, the error message may include a description of the corresponding error code as returned by strerror(3). the error message buffer is thread-local β errors encountered in one thread do not affect its value in other threads. it's giving boundaries, and honestly? iconic.
the buffer is never cleared by any library function; its content is significant only when the return value of the immediately preceding call to a libpmempool function indicated an error, or if errno was set. the application must not modify or free the error message string, but it may be modified by subsequent calls to other library functions. so read it fast, bestie. πβοΈ
two versions of libpmempool are typically available on a development system:
- the normal version, accessed when a program is linked using the
-lpmempooloption, is optimized for performance. that version skips checks that impact performance and never logs any trace information or performs any run-time assertions. - a second version of
libpmempool, accessed when a program uses the libraries under/usr/lib/pmdk_debug, contains run-time assertions and trace points.
the typical way to access the debug version is to set the environment variable LD_LIBRARY_PATH to /usr/lib/pmdk_debug or /usr/lib64/pmdk_debug, as appropriate. debugging output is controlled using the following environment variables. these variables have no effect on the non-debug version of the library. π
PMEMPOOL_LOG_LEVELβ the value ofPMEMPOOL_LOG_LEVELenables trace points in the debug version of the library, as follows:0β this is the default level whenPMEMPOOL_LOG_LEVELis not set. no log messages are emitted at this level.1β additional details on any errors detected are logged (in addition to returning theerrno-based errors as usual). the same information may be retrieved usingpmempool_errormsg().2β a trace of basic operations is logged.3β enables a very verbose amount of function call tracing in the library.4β enables voluminous and fairly obscure tracing information that is likely only useful to thelibpmempooldevelopers.
unless PMEMPOOL_LOG_FILE is set, debugging output is written to stderr.
PMEMPOOL_LOG_FILEβ specifies the name of a file where all logging information should be written. if the last character in the name isβ-β, the PID of the current process will be appended to the file name when the log file is created. ifPMEMPOOL_LOG_FILEis not set, output is written tostderr.
β¨ EXAMPLE β¨
the following example illustrates how the libpmempool API is used. the program detects the type and checks consistency of given pool. if there are any issues detected, the pool is automatically repaired. self-healing queen behavior. π
#include <stddef.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <libpmempool.h>
#define PATH "./pmem-fs/myfile"
#define CHECK_FLAGS (PMEMPOOL_CHECK_FORMAT_STR|PMEMPOOL_CHECK_REPAIR|\
PMEMPOOL_CHECK_VERBOSE)
int
main(int argc, char *argv[])
{
PMEMpoolcheck *ppc;
struct pmempool_check_status *status;
enum pmempool_check_result ret;
/* arguments for check */
struct pmempool_check_args args = {
.path = PATH,
.backup_path = NULL,
.pool_type = PMEMPOOL_POOL_TYPE_DETECT,
.flags = CHECK_FLAGS
};
/* initialize check context */
if ((ppc = pmempool_check_init(&args, sizeof(args))) == NULL) {
perror("pmempool_check_init");
exit(EXIT_FAILURE);
}
/* perform check and repair, answer 'yes' for each question */
while ((status = pmempool_check(ppc)) != NULL) {
switch (status->type) {
case PMEMPOOL_CHECK_MSG_TYPE_ERROR:
printf("%s\n", status->str.msg);
break;
case PMEMPOOL_CHECK_MSG_TYPE_INFO:
printf("%s\n", status->str.msg);
break;
case PMEMPOOL_CHECK_MSG_TYPE_QUESTION:
printf("%s\n", status->str.msg);
status->str.answer = "yes";
break;
default:
pmempool_check_end(ppc);
exit(EXIT_FAILURE);
}
}
/* finalize the check and get the result */
ret = pmempool_check_end(ppc);
switch (ret) {
case PMEMPOOL_CHECK_RESULT_CONSISTENT:
case PMEMPOOL_CHECK_RESULT_REPAIRED:
return 0;
default:
return 1;
}
}
see https://pmem.io/pmdk/libpmempool for more examples using the libpmempool API. more content, more slay. π
β¨ ACKNOWLEDGEMENTS β¨
libpmempool builds on the persistent memory programming model recommended by the SNIA NVM Programming Technical Work Group:
β¨ SEE ALSO β¨
dlclose(3), pmempool_check_init(3), pmempool_feature_query(3), pmempool_rm(3), pmempool_sync(3), strerror(3), libpmem(7), libpmemobj(7)** and https://pmem.io
and that's the whole page, bestie!! π this one came from the PMDK crew, dated 2025-07-24 β go forth and check your versions, and remember: don't free that string. mwah. ππ¦β¨
π¦ where this page comes from
- fedora 43: libpmempool-devel 2.1.0-4.fc43 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright 2016-2023, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms