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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
*** wmmon.c.orig Sun May 4 21:15:27 2003
--- wmmon.c Sun May 4 21:16:48 2003
***************
*** 93,99 ****
--- 93,104 ----
#include <limits.h>
#include <osreldate.h>
#include <sys/conf.h>
+ #if __FreeBSD_version < 500101
#include <sys/dkstat.h>
+ #endif
+ #if __FreeBSD_version >= 500106
+ #include <sys/resource.h>
+ #endif
#if __FreeBSD_version >= 300000
#include <devstat.h>
#endif
***************
*** 190,196 ****
void wmmon_routine(int, char **);
! void main(int argc, char *argv[]) {
int i;
--- 195,201 ----
void wmmon_routine(int, char **);
! int main(int argc, char *argv[]) {
int i;
***************
*** 230,236 ****
--- 235,245 ----
}
}
+ #if __FreeBSD_version >= 500106
+ if( devstat_checkversion(NULL) < 0 )
+ #else
if( checkversion() < 0 )
+ #endif
{
fprintf( stderr, devstat_errbuf );
exit(1);
***************
*** 338,345 ****
if( nlp->n_type == 0 )
fprintf (stderr, "kvm_nlist: Symbol '%s' not found\n", nlp->n_name);
}
!
! #if __FreeBSD_version >= 300000
ndrives = getnumdevs();
#else
if (nl[0].n_type != 0) {
--- 347,356 ----
if( nlp->n_type == 0 )
fprintf (stderr, "kvm_nlist: Symbol '%s' not found\n", nlp->n_name);
}
!
! #if __FreeBSD_version >= 500106
! ndrives = devstat_getnumdevs(NULL);
! #elif __FreeBSD_version >= 300000
ndrives = getnumdevs();
#else
if (nl[0].n_type != 0) {
***************
*** 936,942 ****
--- 947,957 ----
static int initted = 0;
static struct statinfo last;
static struct statinfo cur;
+ #if __FreeBSD_version >= 500106
+ int ndevs = devstat_getnumdevs(NULL);
+ #else
int ndevs = getnumdevs();
+ #endif
int gotdevs = 0;
long generation;
int num_devices_specified = 0;
***************
*** 986,995 ****
--- 1001,1018 ----
memcpy( &last, &cur, sizeof(cur) );
cur.dinfo = tmp;
+ #if __FreeBSD_version >= 500106
+ last.snap_time = cur.snap_time;
+ #else
last.busy_time = cur.busy_time;
+ #endif
}
+ #if __FreeBSD_version >= 500106
+ if( !gotdevs && ( devstat_getdevs( NULL, &cur ) >= 0 ) )
+ #else
if( !gotdevs && ( getdevs( &cur ) >= 0 ) )
+ #endif
gotdevs = 1;
if( gotdevs )
***************
*** 999,1005 ****
--- 1022,1032 ----
if( !initted )
{
+ #if __FreeBSD_version >= 500106
+ devstat_selectdevs( &dev_select, &num_selected, &num_selections,
+ #else
selectdevs( &dev_select, &num_selected, &num_selections,
+ #endif
&select_generation, generation, cur.dinfo->devices,
ndevs, matches, num_matches, specified_devices,
num_devices_specified, DS_SELECT_ONLY, maxshowdevs,
***************
*** 1010,1019 ****
--- 1037,1054 ----
struct devinfo *tmpinfo;
long tmp;
+ #if __FreeBSD_version >= 500106
+ switch( devstat_getdevs( NULL, &cur ) )
+ #else
switch( getdevs( &cur ) )
+ #endif
{
case 1:
+ #if __FreeBSD_version >= 500106
+ devstat_selectdevs( &dev_select, &num_selected,
+ #else
selectdevs( &dev_select, &num_selected,
+ #endif
&num_selections, &select_generation,
generation, cur.dinfo->devices,
ndevs, matches, num_matches,
***************
*** 1041,1053 ****
--- 1076,1096 ----
memcpy( &last, &cur, sizeof(cur) );
cur.dinfo = tmpinfo;
+ #if __FreeBSD_version >= 500106
+ last.snap_time = cur.snap_time;
+ #else
last.busy_time = cur.busy_time;
+ #endif
break;
default:
break;
}
+ #if __FreeBSD_version >= 500106
+ devstat_selectdevs( &dev_select, &num_selected, &num_selections,
+ #else
selectdevs( &dev_select, &num_selected, &num_selections,
+ #endif
&select_generation, generation, cur.dinfo->devices,
ndevs, matches, num_matches, specified_devices,
num_devices_specified, DS_SELECT_ONLY, maxshowdevs,
***************
*** 1068,1074 ****
--- 1111,1121 ----
long double busy_seconds;
long double blocks_per_second, ms_per_transaction;
+ #if __FreeBSD_version >= 500106
+ busy_seconds = cur.snap_time - last.snap_time;
+ #else
busy_seconds = compute_etime( cur.busy_time, last.busy_time );
+ #endif
for( dn = 0; dn < ndevs; dn++ )
{
|