Repository: openwrt/packages
Pull request #26142: libnvme and nvme-cli update
Author: login: graysky2
Created: 2025-03-15T12:53:42Z | Merged: 2025-03-25T11:07:27Z

Bump to latest upstream release.

Removed upstreamed: 020-replace_uint16_t
Manually rebased: 010-gcc14.patch

To fix the following build error, added two commits from upstream:
020-nvme-print-add-fallback-for-.patch
021-pligins-netapp-add-include-of-libgen.h-for-basename.patch

Tested the resulting binary and it seems fine:
```
% nvme smart-log /dev/nvme0 | grep "temperature"
temperature                             : 42 °C (315 K)
```
Link to upstream issue: https://github.com/linux-nvme/nvme-cli/issues/2743

Build error:
```
../nvme-print.c: In function 'is_temperature_fahrenheit':
../nvme-print.c:805:19: error: 'LC_MEASUREMENT' undeclared (first use in this function)
  805 |         setlocale(LC_MEASUREMENT, "");
      |                   ^~~~~~~~~~~~~~
../nvme-print.c:805:19: note: each undeclared identifier is reported only once for each function it appears in
```
Build system: x86/64
Build-tested: x86/64
Run-tested: x86/64

Maintainer: @lu-zero



Diff:
diff --git a/libs/libnvme/Makefile b/libs/libnvme/Makefile
index 50a6aeb4624e1e..14581fcdc0ac4c 100644
--- a/libs/libnvme/Makefile
+++ b/libs/libnvme/Makefile
@@ -5,12 +5,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libnvme
-PKG_VERSION:=1.9
+PKG_VERSION:=1.11.1
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/linux-nvme/libnvme/archive/refs/tags/v$(PKG_VERSION)
-PKG_HASH:=455867060d2b7563eab59fe21779dff469d98465028997178c7efbe4b8763206
+PKG_HASH:=6d5d8ba2cc4c94a61a994c9f7f25b3b26ef973fb5c0daa37729890903f37a1f1
 
 PKG_LICENSE:=GPL-2.0-or-later
 PKG_LICENSE_FILES:=LICENSE
diff --git a/utils/nvme-cli/Makefile b/utils/nvme-cli/Makefile
index 7502943b134686..90ad3983f390a5 100644
--- a/utils/nvme-cli/Makefile
+++ b/utils/nvme-cli/Makefile
@@ -5,12 +5,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=nvme-cli
-PKG_VERSION:=2.9.1
+PKG_VERSION:=2.11
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/linux-nvme/nvme-cli/archive/refs/tags/v$(PKG_VERSION)
-PKG_HASH:=4b61684a1d23de1d9d0abd3f273799c60256c0e2a2e68a790d7945183fe33874
+PKG_HASH:=5e4dc73dbb488c6b1e6ad1c78d0c62b624076fcb0c052bd9039674a1dbd6517b
 
 PKG_LICENSE:=GPL-2.0-or-later
 PKG_LICENSE_FILES:=LICENSE
diff --git a/utils/nvme-cli/patches/010-gcc14.patch b/utils/nvme-cli/patches/010-gcc14.patch
index 63bc2415e34761..5badc8b0730b23 100644
--- a/utils/nvme-cli/patches/010-gcc14.patch
+++ b/utils/nvme-cli/patches/010-gcc14.patch
@@ -1,22 +1,5 @@
 --- a/plugins/virtium/virtium-nvme.c
 +++ b/plugins/virtium/virtium-nvme.c
-@@ -32,14 +32,14 @@ static char vt_default_log_file_name[256
- struct vtview_log_header {
- 	char				path[256];
- 	char				test_name[256];
--	long				time_stamp;
-+	time_t				time_stamp;
- 	struct nvme_id_ctrl		raw_ctrl;
- 	struct nvme_firmware_slot	raw_fw;
- };
- 
- struct vtview_smart_log_entry {
- 	char			path[256];
--	long			time_stamp;
-+	time_t			time_stamp;
- 	struct nvme_id_ns	raw_ns;
- 	struct nvme_id_ctrl	raw_ctrl;
- 	struct nvme_smart_log	raw_smart;
 @@ -127,7 +127,7 @@ static void vt_convert_smart_data_to_hum
  
  	capacity = le64_to_cpu(smart->raw_ns.nsze) * lba;
diff --git a/utils/nvme-cli/patches/020-nvme-print-add-fallback-for-.patch b/utils/nvme-cli/patches/020-nvme-print-add-fallback-for-.patch
new file mode 100644
index 00000000000000..50df4945d9a259
--- /dev/null
+++ b/utils/nvme-cli/patches/020-nvme-print-add-fallback-for-.patch
@@ -0,0 +1,31 @@
+From 9444ce03a27b8d423f8170cf75f56d48d8a0a659 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20N=C3=A9ri?= <dne+commits@rb67.eu>
+Date: Mon, 11 Nov 2024 23:06:03 +0100
+Subject: [PATCH] nvme-print: add fallback for non-standard locale category
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+LC_MEASUREMENT is a GNU (libc) extension - fall back to LC_ALL if it's
+not defined.
+
+Fixes build with musl libc
+
+Signed-off-by: Daniel Néri <dne+commits@rb67.eu>
+---
+ nvme-print.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/nvme-print.c
++++ b/nvme-print.c
+@@ -797,6 +797,10 @@ static bool is_fahrenheit_country(const
+ 	return false;
+ }
+ 
++#ifndef LC_MEASUREMENT
++#define LC_MEASUREMENT LC_ALL
++#endif
++
+ static bool is_temperature_fahrenheit(void)
+ {
+ 	const char *locale, *underscore;
diff --git a/utils/nvme-cli/patches/020-replace_uint16_t b/utils/nvme-cli/patches/020-replace_uint16_t
deleted file mode 100644
index 0e247f0670b148..00000000000000
--- a/utils/nvme-cli/patches/020-replace_uint16_t
+++ /dev/null
@@ -1,28 +0,0 @@
-From 650070ad5d4a97fc87f9018743e3b566deba36c8 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Tue, 21 May 2024 14:09:32 -0700
-Subject: [PATCH] plugins/ssstc: Replace __uint16_t with uint16_t
-
-uint16_t is ISO defined and comes from stdint.h, makes it
-portable across glibc and musl on linux.
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- plugins/ssstc/ssstc-nvme.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
---- a/plugins/ssstc/ssstc-nvme.c
-+++ b/plugins/ssstc/ssstc-nvme.c
-@@ -64,9 +64,9 @@ void show_ssstc_add_smart_log_jsn(struct
- 		unsigned int nsid, const char *devname)
- {
- 	struct json_object *root, *entry_stats, *dev_stats, *multi;
--	__uint16_t wear_level_min = 0;
--	__uint16_t wear_level_max = 0;
--	__uint16_t wear_level_avg = 0;
-+	uint16_t wear_level_min = 0;
-+	uint16_t wear_level_max = 0;
-+	uint16_t wear_level_avg = 0;
- 	uint64_t raw_val = 0;
- 
- 	root = json_create_object();
diff --git a/utils/nvme-cli/patches/021-pligins-netapp-add-include-of-libgen.h-for-basename.patch b/utils/nvme-cli/patches/021-pligins-netapp-add-include-of-libgen.h-for-basename.patch
new file mode 100644
index 00000000000000..016cdbcb17a04c
--- /dev/null
+++ b/utils/nvme-cli/patches/021-pligins-netapp-add-include-of-libgen.h-for-basename.patch
@@ -0,0 +1,26 @@
+From ac4818952c872ba465a2d0f48634f9a79aae064f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20N=C3=A9ri?= <dne+commits@rb67.eu>
+Date: Mon, 11 Nov 2024 22:34:57 +0100
+Subject: [PATCH] plugins/netapp: add include of libgen.h for basename(3)
+ prototype
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Fixes build with musl libc.
+
+Signed-off-by: Daniel Néri <dne+commits@rb67.eu>
+---
+ plugins/netapp/netapp-nvme.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/plugins/netapp/netapp-nvme.c
++++ b/plugins/netapp/netapp-nvme.c
+@@ -22,6 +22,7 @@
+ #include <unistd.h>
+ #include <errno.h>
+ #include <string.h>
++#include <libgen.h>
+ 
+ #include "common.h"
+ #include "nvme.h"


Reviews:
user: login: lu-zero
body: Looks fine, but is this problem reported upstream?
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-15T17:41:22Z
user: login: BKPepe
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-16T08:18:26Z
user: login: graysky2
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-16T10:42:47Z

Review comments:
diff_hunk: @@ -0,0 +1,44 @@
+I don't think musl has the ability to read the locale of the build system
+so in order to fix the following build error, just set it with this commit.
path: utils/nvme-cli/patches/020-usl-fix-build-due-to-undeclared-locale.patch
user: login: BKPepe
body: May I know, if this patch is included in upstream and if not, could you please upstream it?
created_at: 2025-03-16T08:18:26Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,44 @@
+I don't think musl has the ability to read the locale of the build system
+so in order to fix the following build error, just set it with this commit.
path: utils/nvme-cli/patches/020-usl-fix-build-due-to-undeclared-locale.patch
user: login: graysky2
body: Please see @hnyman's comment. I backported two of their commits and our package is good.
created_at: 2025-03-16T10:42:47Z
author_association: CONTRIBUTOR

PR comments:
user: login: graysky2
created_at: 2025-03-15T18:37:51Z
body: Yes: https://github.com/linux-nvme/nvme-cli/issues/2743
author_association: CONTRIBUTOR
user: login: hnyman
created_at: 2025-03-16T10:34:12Z
body: Based on feedback in your upstream bug report, the problem may have been already fixed after a few weeks after the release: 
https://github.com/linux-nvme/nvme-cli/commit/9444ce03a27b8d423f8170cf75f56d48d8a0a659

It might be better to backport the upstream fix instead of crafting a new fix here.

author_association: CONTRIBUTOR
user: login: graysky2
created_at: 2025-03-16T10:43:07Z
body: @hnyman - yes, I did just this, please see latest commit.
author_association: CONTRIBUTOR