1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
$NetBSD: patch-ah,v 1.3 2008/05/17 23:53:29 christos Exp $
--- dialects/n+obsd/dproc.c.orig 2005-05-11 08:54:00.000000000 -0400
+++ dialects/n+obsd/dproc.c 2008-05-17 19:35:00.000000000 -0400
@@ -37,6 +37,11 @@
#include "lsof.h"
+#if __NetBSD_Version__ < 499006200
+#define FILESTRUCT struct file
+#else
+#define FILESTRUCT struct fdfile
+#endif
_PROTOTYPE(static void enter_vn_text,(KA_T va, int *n));
_PROTOTYPE(static void get_kernel_access,(void));
@@ -152,7 +157,7 @@
struct filedesc fd;
int i, nf;
MALLOC_S nb;
- static struct file **ofb = NULL;
+ static FILESTRUCT **ofb = NULL;
static int ofbb = 0;
short pss, sf;
int px;
@@ -280,12 +285,12 @@
*/
if (!fd.fd_ofiles || (nf = fd.fd_nfiles) <= 0)
continue;
- nb = (MALLOC_S)(sizeof(struct file *) * nf);
+ nb = (MALLOC_S)(sizeof(FILESTRUCT *) * nf);
if (nb > ofbb) {
if (!ofb)
- ofb = (struct file **)malloc(nb);
+ ofb = (FILESTRUCT **)malloc(nb);
else
- ofb = (struct file **)realloc((MALLOC_P *)ofb, nb);
+ ofb = (FILESTRUCT **)realloc((MALLOC_P *)ofb, nb);
if (!ofb) {
(void) fprintf(stderr, "%s: PID %d, no file * space\n",
Pn, p->P_PID);
@@ -311,8 +316,10 @@
}
pofb = nb;
}
+#if __NetBSD_Version__ < 499006200
if (!fd.fd_ofileflags || kread((KA_T)fd.fd_ofileflags, pof, nb))
zeromem(pof, nb);
+#endif
}
#endif /* defined(HASFSTRUCT) */
@@ -321,8 +328,20 @@
*/
for (i = 0; i < nf; i++) {
if (ofb[i]) {
+#if __NetBSD_Version__ >= 499006200
+ struct fdfile fdf;
+ if (kread((KA_T)ofb[i], (char *)&fdf, sizeof(fdf)))
+ continue;
+ Cfp = fdf.ff_file;
+ if (Cfp == NULL)
+ continue;
+ if (pof)
+ pof[i] = fdf.ff_exclose;
+#else
+ Cfp = ofb[i];
+#endif
alloc_lfile(NULL, i);
- process_file((KA_T)(Cfp = ofb[i]));
+ process_file((KA_T)Cfp);
if (Lf->sf) {
#if defined(HASFSTRUCT)
|