83 lines
2.5 KiB
Diff
83 lines
2.5 KiB
Diff
From 7360d80e08abf18dcce61fe033de548ac2378f06 Mon Sep 17 00:00:00 2001
|
|
From: kangenbo <kangenbo@huawei.com>
|
|
Date: Wed, 17 Apr 2019 12:20:39 -0400
|
|
Subject: [PATCH 50/83] endpoint(pipe),fix: list the same fd in a different process
|
|
|
|
Description: backport patch from github, see following in details:
|
|
https://github.com/lsof-org/lsof-linux/commit/28f96d5875086d92b5f1cb3f3473ac1184cf155e
|
|
---
|
|
dialects/linux/dnode.c | 7 +++++--
|
|
proc.c | 4 ++--
|
|
proto.h | 2 +-
|
|
3 files changed, 8 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/dialects/linux/dnode.c b/dialects/linux/dnode.c
|
|
index 58288d6..ddd99cf 100644
|
|
--- a/dialects/linux/dnode.c
|
|
+++ b/dialects/linux/dnode.c
|
|
@@ -383,13 +383,15 @@ is_pty_ptmx(dev)
|
|
*/
|
|
|
|
pxinfo_t *
|
|
-find_pepti(lf, pp)
|
|
+find_pepti(pid, lf, pp)
|
|
+ int pid; /* pid of the process owning lf */
|
|
struct lfile *lf; /* pipe's lfile */
|
|
pxinfo_t *pp; /* previous pipe info (NULL == none) */
|
|
{
|
|
struct lfile *ef; /* pipe end local file structure */
|
|
int h; /* hash result */
|
|
pxinfo_t *pi; /* pipe info pointer */
|
|
+ struct lproc *ep;
|
|
|
|
if (Pinfo) {
|
|
if (pp)
|
|
@@ -401,7 +403,8 @@ find_pepti(lf, pp)
|
|
while (pi) {
|
|
if (pi->ino == lf->inode) {
|
|
ef = pi->lf;
|
|
- if (strcmp(lf->fd, ef->fd))
|
|
+ ep = &Lproc[pi->lpx];
|
|
+ if ((strcmp(lf->fd, ef->fd)) || (pid != ep->pid))
|
|
return(pi);
|
|
}
|
|
pi = pi->next;
|
|
diff --git a/proc.c b/proc.c
|
|
index 34cb4b8..e4c3591 100644
|
|
--- a/proc.c
|
|
+++ b/proc.c
|
|
@@ -992,7 +992,7 @@ process_pinfo(f)
|
|
* its being a pipe. Look up the pipe's endpoints.
|
|
*/
|
|
do {
|
|
- if ((pp = find_pepti(Lf, pp))) {
|
|
+ if ((pp = find_pepti(Lp->pid, Lf, pp))) {
|
|
|
|
/*
|
|
* This pipe endpoint is linked to the selected pipe
|
|
@@ -1033,7 +1033,7 @@ process_pinfo(f)
|
|
Lf->sf = Selflags;
|
|
Lp->pss |= PS_SEC;
|
|
do {
|
|
- if ((pp = find_pepti(Lf, pp))) {
|
|
+ if ((pp = find_pepti(Lp->pid, Lf, pp))) {
|
|
ep = &Lproc[pp->lpx];
|
|
ef = pp->lf;
|
|
for (i = 0; i < (FDLEN - 1); i++) {
|
|
diff --git a/proto.h b/proto.h
|
|
index 75c74a1..7f65d67 100644
|
|
--- a/proto.h
|
|
+++ b/proto.h
|
|
@@ -112,7 +112,7 @@ _PROTOTYPE(extern void find_ch_ino,(void));
|
|
|
|
# if defined(HASEPTOPTS)
|
|
_PROTOTYPE(extern void clear_pinfo,(void));
|
|
-_PROTOTYPE(extern pxinfo_t *find_pepti,(struct lfile *lf, pxinfo_t *pp));
|
|
+_PROTOTYPE(extern pxinfo_t *find_pepti,(int pid, struct lfile *lf, pxinfo_t *pp));
|
|
_PROTOTYPE(extern void process_pinfo,(int f));
|
|
# if defined(HASUXSOCKEPT)
|
|
_PROTOTYPE(extern void clear_uxsinfo,(void));
|
|
--
|
|
1.8.3.1
|
|
|