summaryrefslogtreecommitdiffstats
path: root/libnvme-wrap.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:05 +0000
commit1cc8413aaf5f8fa6595aece1933462c096e88639 (patch)
treee97b4f25c511372d73bdd96c389c5f468d99138a /libnvme-wrap.c
parentInitial commit. (diff)
downloadnvme-cli-1cc8413aaf5f8fa6595aece1933462c096e88639.tar.xz
nvme-cli-1cc8413aaf5f8fa6595aece1933462c096e88639.zip
Adding upstream version 2.4+really2.3.upstream/2.4+really2.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnvme-wrap.c')
-rw-r--r--libnvme-wrap.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/libnvme-wrap.c b/libnvme-wrap.c
new file mode 100644
index 0000000..354e7f7
--- /dev/null
+++ b/libnvme-wrap.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * This file is part of nvme-cli
+ *
+ * Copyright (c) 2022 Daniel Wagner, SUSE
+ */
+
+#include <dlfcn.h>
+#include <errno.h>
+
+#include <libnvme.h>
+
+#define PROTO(args...) args
+#define ARGS(args...) args
+
+#define VOID_FN(name, proto, args) \
+void __attribute__((weak)) name(proto) \
+{ \
+ void (*fn)(proto); \
+ fn = dlsym(RTLD_NEXT, #name); \
+ if (fn) \
+ fn(args); \
+}
+
+#define FN(name, rtype, proto, args, defret) \
+rtype __attribute__((weak)) name(proto) \
+{ \
+ rtype (*fn)(proto); \
+ fn = dlsym(RTLD_NEXT, #name); \
+ if (fn) \
+ return fn(args); \
+ return defret; \
+}
+
+FN(nvme_get_version,
+ const char *, PROTO(enum nvme_version type),
+ ARGS(type), "n/a")
+
+VOID_FN(nvme_init_copy_range_f1,
+ PROTO(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
+ __u64 *slbas, __u64 *eilbrts, __u32 *elbatms,
+ __u32 *elbats, __u16 nr),
+ ARGS(copy, nlbs, slbas, eilbrts, elbatms, elbats, nr))
+
+FN(nvme_get_feature_length2,
+ int,
+ PROTO(int fid, __u32 cdw11, enum nvme_data_tfr dir,
+ __u32 *len),
+ ARGS(fid, cdw11, dir, len),
+ -EEXIST)
+
+FN(nvme_ctrl_is_persistent,
+ bool,
+ PROTO(nvme_ctrl_t c),
+ ARGS(c),
+ false)