Print the used libnvme version which the nvme-cli fronent is using.
In order to be backward compatible don't expect that the newly
introduce function in libnvme to be 1available.
This is done by providing a weak symbol which is overwritten when
statically build or when libnvme is is used as shared libray the
dlsym() call checks if the function is available.
$ nvme --version
nvme version 2.0 (git
2.0-2-g037372a+)
libnvme version 1.0 (git
1.0-2-gfb628fe)
Signed-off-by: Daniel Wagner <dwagner@suse.de>
'nvme-print.c',
'nvme-rpmb.c',
'plugin.c',
+ 'wrapper.c',
]
subdir('ccan')
sources,
dependencies: [ libnvme_dep, libuuid_dep, json_c_dep, libz_dep,
libhugetlbfs_dep ],
+ link_args: '-ldl',
include_directories: incdir,
install: true,
install_dir: sbindir
#include "plugin.h"
#include "util/argconfig.h"
+#include <libnvme.h>
+
static int version(struct plugin *plugin)
{
struct program *prog = plugin->parent;
printf("%s version %s (git %s)\n",
prog->name, prog->version, GIT_VERSION);
}
+ printf("libnvme version %s (git %s)\n",
+ nvme_get_version(NVME_VERSION_PROJECT),
+ nvme_get_version(NVME_VERSION_GIT));
return 0;
}
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * This file is part of nvme-cli
+ *
+ * Copyright (c) 2022 Daniel Wagner, SUSE
+ */
+
+#include <dlfcn.h>
+
+#include <libnvme.h>
+
+const char * __attribute__((weak)) nvme_get_version(enum nvme_version type)
+{
+ const char *(*libnvme_get_version)(enum nvme_version type);
+
+ libnvme_get_version = dlsym(RTLD_NEXT, "nvme_get_version");
+
+ if (libnvme_get_version)
+ return libnvme_get_version(type);
+
+ return "n/a";
+}