]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: export nvme_submit_passthru{64} as weak symbol
authorDaniel Wagner <dwagner@suse.de>
Tue, 5 Mar 2024 14:32:59 +0000 (15:32 +0100)
committerDaniel Wagner <wagi@monom.org>
Wed, 6 Mar 2024 09:56:14 +0000 (10:56 +0100)
Export the two low level ioctl function as weak symbol. This allows the
user application to provide their own version of this function, e.g. in
order to allow meassuring the time spend in the function or printing the
struct nvme_passthru_cmd{64}.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/libnvme.map
src/nvme/ioctl.c
src/nvme/linux.h

index c8163cbd4f602bbb0e06829c161ff437889b9d04..e8bd9f10780f2d3e77bb6a47837890ba39001cda 100644 (file)
@@ -1,4 +1,10 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
+LIBNVME_1.9 {
+       global:
+               nvme_submit_passthru;
+               nvme_submit_passthru64;
+};
+
 LIBNVME_1_8 {
        global:
                nvme_uuid_find;
index 04dc8894ebfc8ba17083be48638dd73b2b4ffd4f..42b614c3dd4784ce533c9d6b2189007a01c013d0 100644 (file)
@@ -78,9 +78,10 @@ int nvme_get_nsid(int fd, __u32 *nsid)
        return -1 * (errno != 0);
 }
 
-static int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd,
-                                 struct nvme_passthru_cmd64 *cmd,
-                                 __u64 *result)
+__attribute__((weak))
+int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd,
+                          struct nvme_passthru_cmd64 *cmd,
+                          __u64 *result)
 {
        int err = ioctl(fd, ioctl_cmd, cmd);
 
@@ -115,8 +116,9 @@ static void nvme_show_command(struct nvme_passthru_cmd *cmd, int err, struct tim
               (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec));
 }
 
-static int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
-                               struct nvme_passthru_cmd *cmd, __u32 *result)
+__attribute__((weak))
+int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
+                        struct nvme_passthru_cmd *cmd, __u32 *result)
 {
        struct timeval start;
        struct timeval end;
index 11ee76e23d37f992c976025b45d7a286255a6ada..f38b6a6071f969d99576d03130ca1b8502ee3365 100644 (file)
@@ -335,4 +335,39 @@ char *nvme_generate_tls_key_identity(const char *hostnqn, const char *subsysnqn,
                                     int version, int hmac,
                                     unsigned char *configured_key, int key_len);
 
+/**
+ * nvme_submit_passthru - Low level ioctl wrapper for passthru commands
+ * @fd:                File descriptor of the nvme device
+ * @ioctl_cmd: IOCTL command id
+ * @cmd:       Passhtru command
+ * @result:    Optional field to return the result
+ *
+ * This is a low level library function which should not be used directly. It is
+ * exposed as weak symbol so that the user application is able to provide their own
+ * implementation of this function with additional debugging or logging code.
+ *
+ * Return: The value from the ioctl system call (see ioctl documentation)
+ */
+__attribute__((weak))
+int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
+                        struct nvme_passthru_cmd *cmd, __u32 *result);
+
+/**
+ * nvme_submit_passthru64 - Low level ioctl wrapper for passthru commands
+ * @fd:                File descriptor of the nvme device
+ * @ioctl_cmd: IOCTL command id
+ * @cmd:       Passhtru command
+ * @result:    Optional field to return the result
+ *
+ * This is a low level library function which should not be used directly. It is
+ * exposed as weak symbol so that the user application is able to provide their own
+ * implementation of this function with additional debugging or logging code.
+ *
+ * Return: The value from the ioctl system call (see ioctl documentation)
+ */
+__attribute__((weak))
+int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd,
+                          struct nvme_passthru_cmd64 *cmd,
+                          __u64 *result);
+
 #endif /* _LIBNVME_LINUX_H */