1 Star 0 Fork 21

yangshx/lsof

forked from src-openEuler/lsof 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0050-endpoint-pipe-fix-list-the-same-fd-in-a-different-pr.patch 2.48 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 11:02 . Package init
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yangshaoxing1001/lsof.git
git@gitee.com:yangshaoxing1001/lsof.git
yangshaoxing1001
lsof
lsof
master

搜索帮助