Skip to content

Commit 63c2646

Browse files
authored
Merge pull request #345 from x-lugoo/master
Treat NFS ESTALE fds as unlinked for +L selection
2 parents d1702af + f844b13 commit 63c2646

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/dialects/linux/dproc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,8 @@ static int process_id(struct lsof_context *ctx, /* context */
917917
static int pathil = 0;
918918
char *rest;
919919
int txts = 0;
920+
int enss_fd = 0;
921+
int enls_fd = 0;
920922

921923
#if defined(HASSELINUX)
922924
cntxlist_t *cntxp;
@@ -1206,13 +1208,15 @@ static int process_id(struct lsof_context *ctx, /* context */
12061208
} else {
12071209
if (HasNFS) {
12081210
if (lstatsafely(ctx, path, &lsb)) {
1211+
enls_fd = errno;
12091212
(void)statEx(ctx, pbuf, &lsb, &ls);
12101213
enls = errno;
12111214
} else {
12121215
enls = 0;
12131216
ls = SB_ALL;
12141217
}
12151218
if (statsafely(ctx, path, &sb)) {
1219+
enss_fd = errno;
12161220
(void)statEx(ctx, pbuf, &sb, &ss);
12171221
enss = errno;
12181222
} else {
@@ -1353,6 +1357,12 @@ static int process_id(struct lsof_context *ctx, /* context */
13531357
enter_nm(ctx, rest);
13541358
}
13551359

1360+
if ((Selflags & SELNLINK) &&
1361+
(enss_fd == ESTALE || enls_fd == ESTALE)) {
1362+
Lf->sf |= SELNLINK;
1363+
(void)add_nma(ctx, " (STALE)", 8);
1364+
}
1365+
13561366
if (Lf->sf)
13571367
link_lfile(ctx);
13581368
}

0 commit comments

Comments
 (0)