sysutils/lsof: unbreak after base r354895.

- fix vm_map related breakage
- remove #define/#undef _KERNEL for tmpfs (dougm had the header fixed)

patch courtesy of dougm@

PR:		242620
Reported by:	ish@amail.plala.or.jp
Obtained from:	dougm
This commit is contained in:
Larry Rosenman 2019-12-21 02:01:52 +00:00
parent b0889ee3fa
commit 0fa5f05446
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=520539
3 changed files with 70 additions and 1 deletions

View File

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

View File

@ -0,0 +1,12 @@
--- dialects/freebsd/dnode.c.orig 2019-12-19 21:29:42 UTC
+++ dialects/freebsd/dnode.c
@@ -58,9 +58,7 @@ _PROTOTYPE(static int lkup_dev_tty,(dev_t *dr, INODETY
#if defined(HAS_TMPFS)
-#define _KERNEL
#include <fs/tmpfs/tmpfs.h>
-#undef _KERNEL
#endif /* defined(HAS_TMPFS) */
_PROTOTYPE(static void get_lock_state,(KA_T f));

View File

@ -0,0 +1,57 @@
--- dialects/freebsd/dproc.c.orig 2019-05-08 07:32:25 UTC
+++ dialects/freebsd/dproc.c
@@ -655,7 +655,29 @@ kread(addr, buf, len)
return((br == len) ? 0 : 1);
}
+static int
+vm_map_reader(void *token, vm_map_entry_t addr, vm_map_entry_t dest)
+{
+ return (kread((KA_T)addr, (char *)dest, sizeof(*dest)));
+}
+#if __FreeBSD_version < 1300060
+typedef int vm_map_entry_reader(void *token, vm_map_entry_t addr,
+ vm_map_entry_t dest);
+
+static inline vm_map_entry_t
+vm_map_entry_read_succ(void *token, struct vm_map_entry *const clone,
+ vm_map_entry_reader reader)
+{
+ vm_map_entry_t next;
+
+ next = clone->next;
+ if (!reader(token, next, clone))
+ return (NULL);
+ return (next);
+}
+#endif /* __FreeBSD_version < 1300060 */
+
/*
* process_text() - process text information
*/
@@ -682,20 +704,15 @@ process_text(vm)
/*
* Read the vm_map structure. Search its vm_map_entry structure list.
*/
+ vmme = vmsp.vm_map.header;
+ e = &vmme;
for (i = 0; i < vmsp.vm_map.nentries; i++) {
/*
* Read the next vm_map_entry.
*/
- if (i == 0)
- e = &vmsp.vm_map.header;
- else {
- if (!(ka = (KA_T)e->next))
- return;
- e = &vmme;
- if (kread(ka, (char *)e, sizeof(vmme)))
- return;
- }
+ if (!vm_map_entry_read_succ(NULL, e, vm_map_reader))
+ return;
#if defined(MAP_ENTRY_IS_A_MAP)
if (e->eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))