Patches to make wmmon work under 5-current

Scott Long scott_long at btc.adaptec.com
Sat Apr 19 01:24:32 PDT 2003


Hi,

Attached are patches to make wmmon work under 5-CURRENT.  I added
appropriate #if __FreeBSD_version lines near the top of the file,
but got lazy and gave up as I went on.  Just about every single
change needs to be bracketed with #if __FreeBSD_version >= 500106 ...
#else ... #endif.  The patch is relative to the patched version of
wmmon.c that is generated from the 'make patch' stage.

Scott
-------------- next part --------------
--- wmmon.c.orig	Sat Apr 19 01:51:32 2003
+++ wmmon.c	Sat Apr 19 02:19:37 2003
@@ -93,7 +93,12 @@
 #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,7 +195,7 @@
 
 void wmmon_routine(int, char **);
 
-void main(int argc, char *argv[]) {
+int main(int argc, char *argv[]) {
 
 	int		i;
 	
@@ -230,7 +235,7 @@
 		}
 	}
 
-	if( checkversion() < 0 )
+	if( devstat_checkversion(NULL) < 0 )
 	{
 		fprintf( stderr, devstat_errbuf );
 		exit(1);
@@ -340,7 +345,7 @@
 			}
 		
 #if __FreeBSD_version >= 300000
-			ndrives = getnumdevs();
+			ndrives = devstat_getnumdevs(NULL);
 #else
 			if (nl[0].n_type != 0) {
 				(void) kvm_read(kvmd, nl[N_DK_NDRIVE].n_value, (char *)&ndrives, sizeof(ndrives));
@@ -936,7 +941,7 @@
 		static int                initted = 0;
 		static struct statinfo    last;
 		static struct statinfo    cur;
-		int                       ndevs = getnumdevs();
+		int                       ndevs = devstat_getnumdevs(NULL);
 		int                       gotdevs = 0;
 		long                      generation;
 		int                       num_devices_specified = 0;
@@ -986,10 +991,10 @@
 			memcpy( &last, &cur, sizeof(cur) );
 			cur.dinfo = tmp;
 
-			last.busy_time = cur.busy_time;
+			last.snap_time = cur.snap_time;
 		}
 
-		if( !gotdevs && ( getdevs( &cur ) >= 0 ) )
+		if( !gotdevs && ( devstat_getdevs( NULL, &cur ) >= 0 ) )
 			gotdevs = 1;
 
 		if( gotdevs )
@@ -999,7 +1004,7 @@
 
 			if( !initted )
 			{
-				selectdevs( &dev_select, &num_selected, &num_selections,
+				devstat_selectdevs( &dev_select, &num_selected, &num_selections,
 					    &select_generation, generation, cur.dinfo->devices,
 					    ndevs, matches, num_matches, specified_devices,
 					    num_devices_specified, DS_SELECT_ONLY, maxshowdevs,
@@ -1010,10 +1015,10 @@
 				struct devinfo *tmpinfo;
 				long tmp;
 
-				switch( getdevs( &cur ) )
+				switch( devstat_getdevs( NULL, &cur ) )
 				{
 					case 1:
-						selectdevs( &dev_select, &num_selected,
+						devstat_selectdevs( &dev_select, &num_selected,
 							    &num_selections, &select_generation,
 							    generation, cur.dinfo->devices,
 							    ndevs, matches, num_matches,
@@ -1041,13 +1046,13 @@
 						memcpy( &last, &cur, sizeof(cur) );
 						cur.dinfo = tmpinfo;
 
-						last.busy_time = cur.busy_time;
+						last.snap_time = cur.snap_time;
 						break;
 					default:
 						break;
 				}
 
-				selectdevs( &dev_select, &num_selected, &num_selections,
+				devstat_selectdevs( &dev_select, &num_selected, &num_selections,
 					    &select_generation, generation, cur.dinfo->devices,
 					    ndevs, matches, num_matches, specified_devices,
 					    num_devices_specified, DS_SELECT_ONLY, maxshowdevs,
@@ -1068,7 +1073,7 @@
 					long double busy_seconds;
 					long double blocks_per_second, ms_per_transaction;
 
-					busy_seconds = compute_etime( cur.busy_time, last.busy_time );
+					busy_seconds = cur.snap_time - last.snap_time;
 
 					for( dn = 0; dn < ndevs; dn++ )
 					{


More information about the freebsd-ports mailing list