Skip to content

Commit c1678e3

Browse files
committed
[linux] Maintain original output for pidfd in linux 6.9
1 parent 3729186 commit c1678e3

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

00DIST

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5605,6 +5605,9 @@ Supplement Regenerated the 4.04 distribution to correct a non-
56055605

56065606
[linux] Do not embed kernel version in CFLAGS (#314)
56075607

5608+
[linux] Linux 6.9 changed the pidfs appearence in procfs. Try
5609+
to maintain original output in lsof (#317)
5610+
56085611

56095612
Vic Abell <abe@purdue.edu>
56105613
July 14, 2018

lib/dialects/linux/dproc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,10 @@ static int process_id(struct lsof_context *ctx, /* context */
12731273
#endif /* defined(HASEPTOPTS) */
12741274
if (rest && rest[0] == '[' && rest[1] == 'p')
12751275
fdinfo_mask |= FDINFO_PID;
1276+
else if (Lf->ntype == N_REGLR && rest && *rest && strcmp(pbuf, "pidfd") == 0) {
1277+
// https://github.com/lsof-org/lsof/issues/317
1278+
fdinfo_mask |= FDINFO_PID;
1279+
}
12761280

12771281
if ((av = get_fdinfo(ctx, pathi, fdinfo_mask, &fi)) &
12781282
FDINFO_POS) {
@@ -1338,6 +1342,15 @@ static int process_id(struct lsof_context *ctx, /* context */
13381342
Lf->sf |= SELPTYINFO;
13391343
}
13401344
#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
1345+
else if (Lf->ntype == N_REGLR && rest && *rest && Lf->nm &&
1346+
strcmp(Lf->nm, "pidfd") == 0) {
1347+
// https://github.com/lsof-org/lsof/issues/317
1348+
// pidfd since Linux 6.9 becomes a regular file:
1349+
// /proc/PID/fd/FD -> pidfd:[INODE]
1350+
(void)snpf(rest, sizeof(pbuf) - (rest - pbuf),
1351+
"[pidfd:%d]", fi.pid);
1352+
enter_nm(ctx, rest);
1353+
}
13411354

13421355
if (Lf->sf)
13431356
link_lfile(ctx);

0 commit comments

Comments
 (0)