[PATCH] gnu: lsof: fix build in Linux 6.9

  • Done
  • quality assurance status badge
Details
2 participants
  • Efraim Flashner
  • Ekaitz Zarraga
Owner
unassigned
Submitted by
Ekaitz Zarraga
Severity
normal

Debbugs page

Ekaitz Zarraga wrote 5 months ago
(address . guix-patches@gnu.org)(name . Ekaitz Zarraga)(address . ekaitz@elenq.tech)
0e032dbca5f08b3e0ea45748a4290336306e639e.1728566057.git.ekaitz@elenq.tech
This commit adds the patch that fixes:

The issue was triggering the following error in the `test` phase that
resulted in a build failure in Linux 6.9 or higher:

FAIL: lib/dialects/linux/tests/case-20-pidfd-pid.bash

* gnu/packages/lsof.scm(patches): Add `lsof-compat-linux-6.9.patch`.
* gnu/packages/patches/lsof-compat-linux-6.9.patch: New file.

Change-Id: I98b895ecaf1b952bfd33ea7ae3af70b1c39a0a94
---
gnu/packages/lsof.scm | 4 +-
.../patches/lsof-compat-linux-6.9.patch | 58 +++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/lsof-compat-linux-6.9.patch

Toggle diff (83 lines)
diff --git a/gnu/packages/lsof.scm b/gnu/packages/lsof.scm
index 7d849c80b5..d76ef585c3 100644
--- a/gnu/packages/lsof.scm
+++ b/gnu/packages/lsof.scm
@@ -46,7 +46,9 @@ (define-public lsof
(file-name (git-file-name name version))
(sha256
(base32
- "1v32407al4j0hhcph95lv4xvr9h012lii29iyq41iwj39zwfavax"))))
+ "1v32407al4j0hhcph95lv4xvr9h012lii29iyq41iwj39zwfavax"))
+ ;; FIXES: https://github.com/lsof-org/lsof/issues/317
+ (patches (search-patches "lsof-compat-linux-6.9.patch"))))
(build-system gnu-build-system)
(native-inputs (list automake
autoconf
diff --git a/gnu/packages/patches/lsof-compat-linux-6.9.patch b/gnu/packages/patches/lsof-compat-linux-6.9.patch
new file mode 100644
index 0000000000..419cae927a
--- /dev/null
+++ b/gnu/packages/patches/lsof-compat-linux-6.9.patch
@@ -0,0 +1,58 @@
+From c1678e3f6e4b4d984cb3078b7bf0c9e24bedb8ca Mon Sep 17 00:00:00 2001
+From: Jiajie Chen <c@jia.je>
+Date: Fri, 17 May 2024 15:22:35 +0800
+Subject: [PATCH] [linux] Maintain original output for pidfd in linux 6.9
+
+---
+ 00DIST | 3 +++
+ lib/dialects/linux/dproc.c | 13 +++++++++++++
+ 2 files changed, 16 insertions(+)
+
+diff --git a/00DIST b/00DIST
+index d5a0349..9a29611 100644
+--- a/00DIST
++++ b/00DIST
+@@ -5605,6 +5605,9 @@ Supplement Regenerated the 4.04 distribution to correct a non-
+
+ [linux] Do not embed kernel version in CFLAGS (#314)
+
++ [linux] Linux 6.9 changed the pidfs appearence in procfs. Try
++ to maintain original output in lsof (#317)
++
+
+ Vic Abell <abe@purdue.edu>
+ July 14, 2018
+diff --git a/lib/dialects/linux/dproc.c b/lib/dialects/linux/dproc.c
+index cb6bb64..3a7a120 100644
+--- a/lib/dialects/linux/dproc.c
++++ b/lib/dialects/linux/dproc.c
+@@ -1273,6 +1273,10 @@ static int process_id(struct lsof_context *ctx, /* context */
+ #endif /* defined(HASEPTOPTS) */
+ if (rest && rest[0] == '[' && rest[1] == 'p')
+ fdinfo_mask |= FDINFO_PID;
++ else if (Lf->ntype == N_REGLR && rest && *rest && strcmp(pbuf, "pidfd") == 0) {
++ // https://github.com/lsof-org/lsof/issues/317
++ fdinfo_mask |= FDINFO_PID;
++ }
+
+ if ((av = get_fdinfo(ctx, pathi, fdinfo_mask, &fi)) &
+ FDINFO_POS) {
+@@ -1338,6 +1342,15 @@ static int process_id(struct lsof_context *ctx, /* context */
+ Lf->sf |= SELPTYINFO;
+ }
+ #endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
++ else if (Lf->ntype == N_REGLR && rest && *rest && Lf->nm &&
++ strcmp(Lf->nm, "pidfd") == 0) {
++ // https://github.com/lsof-org/lsof/issues/317
++ // pidfd since Linux 6.9 becomes a regular file:
++ // /proc/PID/fd/FD -> pidfd:[INODE]
++ (void)snpf(rest, sizeof(pbuf) - (rest - pbuf),
++ "[pidfd:%d]", fi.pid);
++ enter_nm(ctx, rest);
++ }
+
+ if (Lf->sf)
+ link_lfile(ctx);
+--
+2.45.2
+

base-commit: f5aff5b3972b9a3342b1ce807f7ed68289cce74d
--
2.46.0
Efraim Flashner wrote 5 months ago
(name . Ekaitz Zarraga)(address . ekaitz@elenq.tech)(address . 73733-done@debbugs.gnu.org)
Zwfp02NUJJihwBjX@3900XT
Thanks for the patch. I added a line to gnu/local.mk.

--
Efraim Flashner <efraim@flashner.co.il> רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmcH6dMACgkQQarn3Mo9
g1HLyBAAr2JUsFmJi084t0zksZmTnq/XvrZBY4zlsB7sgQJnYPp4ac7Q1sLWin+S
W33dnahEnM+RTm0HZEl9M0In+GJqebqDHBObxnWAqdrLGQSNNLj2F79XRsFc94/k
rltmoradEzoVfwU6w06TB+GI6w4jvcjenbmrDktu8H+WTzxVIIx9N7R9oJViPh5w
Xv38kE9QTRtk8K+6uvO8jwlJyR2/qittjbWPaIQLRkZgrjr5uO00yoqt0OnC+dMo
3lsDjKVcQhd9hnvQha12auakxWusHc3aQIfmAiqH4FWUmwv0WUzdGSquRxiu0bdp
tmypiEidLfLoL30t27vFdSdqHv5C9Buj4Ue8W0PQ8It2ND+Zabpj3PbWPVHQsYUf
io0NuQt1EyWTzYeP47uvoElwMZS53STHY31eZu8QfizWlsdSXgsu24aRqaFGbSpk
esIbkuhe1gp88VJwLCeGJ9tMoE05jwSOHb4dA2KWGv+KcRmTbJr6M+rGOdLIiLng
VpnsLC7wNCj9/+Sun+DcrCqvcfIfda+UGPX8YwPwwO1Rp7G15bgS8NaABTpKpZHm
5zihEviBJ8zfCXrE5oJF+Bf/kFwbBA2mHy63fT03nwUCMwVm5Sf10NEx4bz/LcNf
PsBQdT2B2NnosfkTETZjs4m7mj6Gx/A5eL7giw/oPjzzNCdzA1Q=
=N03D
-----END PGP SIGNATURE-----


Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 73733@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 73733
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help