sysutils/lsof: fix compile on 13-CURRENT

Submitted by:	mjg
This commit is contained in:
Larry Rosenman 2020-03-08 02:55:04 +00:00
parent 1e376d13d2
commit 38c1af28b0
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=527995
2 changed files with 95 additions and 3 deletions

View File

@ -6,7 +6,7 @@
PORTNAME= lsof
DISTVERSION= 4.93.2
PORTREVISION= 9
PORTREVISION= 10
PORTEPOCH= 8
CATEGORIES= sysutils

View File

@ -1,6 +1,98 @@
--- dialects/freebsd/dproc.c.orig 2019-05-08 07:32:25 UTC
+++ dialects/freebsd/dproc.c
@@ -655,7 +655,29 @@ kread(addr, buf, len)
@@ -37,6 +37,14 @@ static char *rcsid = "$Id: dproc.c,v 1.20 2018/02/14 1
#include "lsof.h"
+/*
+ * This is not an exact version but it should not matter. At worst there
+ * is a small version window where this lsof does not compile on older
+ * -CURRENT.
+ */
+#if __FreeBSD_version >= 1300081
+#define HAS_PWD
+#endif
_PROTOTYPE(static void enter_vn_text,(KA_T va, int *n));
_PROTOTYPE(static void get_kernel_access,(void));
@@ -132,6 +140,15 @@ gather_proc_info()
KA_T fa;
#endif /* defined(HAS_FDESCENTTBL) */
+#if defined(HAS_PWD)
+ struct pwd pwd;
+ KA_T pwd_addr;
+#endif /* defined(HAS_FDESCENTTBL) */
+
+ struct vnode *cdir;
+ struct vnode *rdir;
+ struct vnode *jdir;
+
static ofb_t *ofb = NULL;
static int ofbb = 0;
int pgid, pid;
@@ -312,6 +329,22 @@ gather_proc_info()
continue;
#endif /* defined(HAS_FDESCENTTBL) */
+#if defined(HAS_PWD)
+ cdir = rdir = jdir = NULL;
+ pwd_addr = (KA_T)FILEDESC_KVM_LOAD_PWD(&fd);
+ if (pwd_addr != 0) {
+ if (!kread(pwd_addr, (char *)&pwd, sizeof(pwd))) {
+ cdir = pwd.pwd_cdir;
+ rdir = pwd.pwd_rdir;
+ jdir = pwd.pwd_jdir;
+ }
+ }
+#else
+ cdir = fd.fd_cdir;
+ rdir = fd.fd_rdir;
+ jdir = fd.fd_jdir;
+#endif
+
/*
* Allocate a local process structure.
*/
@@ -347,20 +380,20 @@ gather_proc_info()
/*
* Save current working directory information.
*/
- if (!ckscko && fd.fd_cdir) {
+ if (!ckscko && cdir) {
alloc_lfile(CWD, -1);
Cfp = (struct file *)NULL;
- process_node((KA_T)fd.fd_cdir);
+ process_node((KA_T)cdir);
if (Lf->sf)
link_lfile();
}
/*
* Save root directory information.
*/
- if (!ckscko && fd.fd_rdir) {
+ if (!ckscko && rdir) {
alloc_lfile(RTD, -1);
Cfp = (struct file *)NULL;
- process_node((KA_T)fd.fd_rdir);
+ process_node((KA_T)rdir);
if (Lf->sf)
link_lfile();
}
@@ -369,10 +402,10 @@ gather_proc_info()
/*
* Save jail directory information.
*/
- if (!ckscko && fd.fd_jdir) {
+ if (!ckscko && jdir) {
alloc_lfile("jld", -1);
Cfp = (struct file *)NULL;
- process_node((KA_T)fd.fd_jdir);
+ process_node((KA_T)jdir);
if (Lf->sf)
link_lfile();
}
@@ -655,7 +688,29 @@ kread(addr, buf, len)
return((br == len) ? 0 : 1);
}
@ -30,7 +122,7 @@
/*
* process_text() - process text information
*/
@@ -682,20 +704,15 @@ process_text(vm)
@@ -682,20 +737,15 @@ process_text(vm)
/*
* Read the vm_map structure. Search its vm_map_entry structure list.
*/