Skip to content

Commit cd5bb9b

Browse files
authored
Merge pull request #319 from lsof-org/fix-pidfs-display-linux-6.9
Fix pidfs display linux 6.9
2 parents 0a979c5 + c1678e3 commit cd5bb9b

4 files changed

Lines changed: 18 additions & 2 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);

lib/dialects/linux/tests/case-20-inet6-ffffffff-handling.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ expectation="n[${v6addr}]:$port"
3030
result=1
3131
if "${lsof}" -p "${pid}" -a -d fd -P -n -F n \
3232
| tee -a "${report}" \
33-
| fgrep -q "$expectation"; then
33+
| grep -Fq "$expectation"; then
3434
result=0
3535
fi
3636

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $TARGET | (
1111
exit 77
1212
fi
1313
line=$($lsof -p $pid -a -d $fd -F pfn| tr '\n' ' ')
14-
if ! fgrep -q "p${pid} f${fd} n[pidfd:$pid]" <<<"$line"; then
14+
if ! grep -Fq "p${pid} f${fd} n[pidfd:$pid]" <<<"$line"; then
1515
$lsof -p $pid -a -d $fd -F pfn
1616
echo
1717
echo $line

0 commit comments

Comments
 (0)