From owner-freebsd-ports Wed May 21 08:40:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id IAA16692 for ports-outgoing; Wed, 21 May 1997 08:40:04 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id IAA16682; Wed, 21 May 1997 08:40:01 -0700 (PDT) Resent-Date: Wed, 21 May 1997 08:40:01 -0700 (PDT) Resent-Message-Id: <199705211540.IAA16682@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-ports Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, itojun@itojun.org Received: from coconut.itojun.org (coconut.itojun.org [133.138.201.163]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id IAA16359 for ; Wed, 21 May 1997 08:30:44 -0700 (PDT) Received: (from root@localhost) by coconut.itojun.org (8.8.5/3.5Wpl7) id XAA00544; Wed, 21 May 1997 23:58:09 +0900 (JST) Message-Id: <199705211458.XAA00544@coconut.itojun.org> Date: Wed, 21 May 1997 23:58:09 +0900 (JST) From: itojun@itojun.org Reply-To: itojun@itojun.org To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: ports/3653: ports/net/ucd-snmp does not compile on 2.2.1-RELEASE Sender: owner-ports@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 3653 >Category: ports >Synopsis: ports/net/ucd-snmp does not compile on 2.2.1-RELEASE >Confidential: yes >Severity: serious >Priority: low >Responsible: freebsd-ports >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed May 21 08:40:01 PDT 1997 >Last-Modified: >Originator: Jun-ichiro ITOH >Organization: itojun@itojun.org >Release: FreeBSD 2.2.1-RELEASE i386 >Environment: FreeBSD coconut.itojun.org 2.2.1-RELEASE FreeBSD 2.2.1-RELEASE #3: Sun Apr 20 14:28:44 JST 1997 root@coconut.itojun.org:/usr/src/sys/compile/COCONUT i386 >Description: ports/net/ucd-snmp does not compile on 2.2.1-RELEASE. due to the changes in pathname /usr/include/vm? >How-To-Repeat: cd /usr/ports/net/ucd-snmp; make >Fix: diff -urN ucd-snmp-/patches/patch-aa ucd-snmp/patches/patch-aa --- ucd-snmp-/patches/patch-aa Fri Mar 7 20:34:00 1997 +++ ucd-snmp/patches/patch-aa Wed May 21 23:50:17 1997 @@ -73,508 +73,3 @@ if ((ifnet.if_lastchange.tv_sec == 0 ) && (ifnet.if_lastchange.tv_usec == 0)) long_return = 0; -Index: agent/extensible/extensible.c -=================================================================== -RCS file: /home/pcvs/ports/ucd-snmp/agent/extensible/extensible.c,v -retrieving revision 1.1.1.1 -diff -u -r1.1.1.1 extensible.c ---- extensible.c 1997/03/07 09:06:12 1.1.1.1 -+++ extensible.c 1997/03/07 11:07:46 -@@ -75,6 +75,10 @@ - #if STDC_HEADERS - #include - #endif -+#ifdef freebsd2 -+#include -+#include -+#endif - - #include "mibincl.h" - #include "mibdefs.h" -@@ -101,7 +105,8 @@ - static int exceptions[] = SECURITYEXCEPTIONS; - #endif - --int checkmib(vp,name,length,exact,var_len,write_method,newname,max) -+int -+checkmib(vp, name, length, exact, var_len, write_method, newname, max) - register struct variable *vp; - register oid *name; - register int *length; -@@ -133,8 +138,7 @@ - memmove(newname, vp->name, (int)vp->namelen * sizeof (oid)); - newname[vp->namelen] = 1; - *length = vp->namelen+1; -- } -- else { -+ } else { - *length = vp->namelen+1; - memmove(newname, name, (*length) * sizeof(oid)); - if (!exact) -@@ -171,6 +175,33 @@ - } - - #define pagetok(size) ((size) << pageshift) -+#define KNLookup(nl_which, buf, s) (klookup((int) nl[nl_which].n_value, buf, s)) -+ -+#ifdef freebsd2 -+ -+/* -+ * FreeBSD 2.x uses sysctl() for most of it's work, so we only need to -+ * find kernel objects for the swap statistics. -+ */ -+ -+static struct nlist nl[] = { -+#define NL_SWAPLIST 0 -+ { "_swaplist" }, -+#define NL_SWDEVT 1 -+ { "_swdevt" }, -+#define NL_NSWAP 2 -+ { "_nswap" }, -+#define NL_NSWDEV 3 -+ { "_nswdev" }, -+#define NL_DMMAX 4 -+ { "_dmmax" }, -+#define NL_MAXMEM 5 -+ { "_Maxmem"}, -+ { 0 }, -+}; -+ -+#else /* freebsd2 */ -+ - #define NL_AVENRUN 0 - #define NL_TOTAL 1 - #define NL_SWDEVT 2 -@@ -178,8 +209,6 @@ - #define NL_NSWAPFS 4 - #define NL_NSWAPDEV 5 - #define NL_PHYSMEM 6 --#define KNLookup(nl_which, buf, s) (klookup((int) nl[nl_which].n_value, buf, s)) -- - static struct nlist nl[] = { - #if !defined(hpux) && !defined(solaris2) - { "_avenrun"}, -@@ -201,6 +230,8 @@ - { 0 } - }; - -+#endif /* freebsd2 */ -+ - #define SWAPGETLEFT 0 - #define SWAPGETTOTAL 1 - -@@ -209,7 +240,144 @@ - - #ifdef USEMEMMIB - --int getswap(rettype) -+#ifdef freebsd2 -+/* -+ * getswap is based on a program called swapinfo written -+ * by Kevin Lahey . -+ */ -+ -+#define KGET(idx, var) \ -+ KGET1(idx, &var, sizeof(var)) -+ -+#define KGET1(idx, p, s) \ -+ KGET2(nl[idx].n_value, p, s) -+ -+#define KGET2(addr, p, s) \ -+ if (klookup((int) (addr), p, s) == NULL) \ -+ return(NULL); -+ -+int -+getswap(rettype) -+ int rettype; -+{ -+ char *header; -+ int hlen, nswap, nswdev, dmmax; -+ int i, div, avail, nfree, npfree, used; -+ struct swdevt *sw; -+ long blocksize, *perdev; -+ struct rlist head; -+ u_long ptr; -+#if __FreeBSD_version >= 220000 -+ struct rlisthdr swaplist; -+ struct rlist *swapptr; -+#else -+ struct rlist *swaplist; -+#endif -+ -+ KGET(NL_NSWAP, nswap); -+ KGET(NL_NSWDEV, nswdev); -+ KGET(NL_DMMAX, dmmax); -+ KGET(NL_SWAPLIST, swaplist); -+ if ((sw = malloc(nswdev * sizeof(*sw))) == NULL || -+ (perdev = malloc(nswdev * sizeof(*perdev))) == NULL) -+ err(1, "malloc"); -+ KGET1(NL_SWDEVT, &ptr, sizeof ptr); -+ KGET2(ptr, sw, nswdev * sizeof(*sw)); -+ -+ /* Count up swap space. */ -+ nfree = 0; -+ memset(perdev, 0, nswdev * sizeof(*perdev)); -+ -+#if __FreeBSD_version >= 220000 -+ swapptr = swaplist.rlh_list; -+ while (swapptr) { -+#else -+ while (swaplist) { -+#endif -+ int top, bottom, next_block; -+ -+#if __FreeBSD_version >= 220000 -+ KGET2(swapptr, &head, sizeof(struct rlist)); -+#else -+ KGET2(swaplist, &head, sizeof(struct rlist)); -+#endif -+ -+ top = head.rl_end; -+ bottom = head.rl_start; -+ -+ nfree += top - bottom + 1; -+ -+ /* -+ * Swap space is split up among the configured disks. -+ * -+ * For interleaved swap devices, the first dmmax blocks -+ * of swap space some from the first disk, the next dmmax -+ * blocks from the next, and so on up to nswap blocks. -+ * -+ * The list of free space joins adjacent free blocks, -+ * ignoring device boundries. If we want to keep track -+ * of this information per device, we'll just have to -+ * extract it ourselves. -+ */ -+ while (top / dmmax != bottom / dmmax) { -+ next_block = ((bottom + dmmax) / dmmax); -+ perdev[(bottom / dmmax) % nswdev] += -+ next_block * dmmax - bottom; -+ bottom = next_block * dmmax; -+ } -+ perdev[(bottom / dmmax) % nswdev] += -+ top - bottom + 1; -+ -+#if __FreeBSD_version >= 220000 -+ swapptr = head.rl_next; -+#else -+ swaplist = head.rl_next; -+#endif -+ } -+ -+ header = getbsize(&hlen, &blocksize); -+ div = blocksize / 512; -+ avail = npfree = 0; -+ for (i = 0; i < nswdev; i++) { -+ int xsize, xfree; -+ -+ /* -+ * Don't report statistics for partitions which have not -+ * yet been activated via swapon(8). -+ */ -+ if (!(sw[i].sw_flags & SW_FREED)) -+ continue; -+ -+ /* The first dmmax is never allocated to avoid trashing of -+ * disklabels -+ */ -+ xsize = sw[i].sw_nblks - dmmax; -+ xfree = perdev[i]; -+ used = xsize - xfree; -+ npfree++; -+ avail += xsize; -+ } -+ -+ /* -+ * If only one partition has been set up via swapon(8), we don't -+ * need to bother with totals. -+ */ -+ used = avail - nfree; -+ -+ free(sw); free(perdev); -+ -+ switch (rettype) { -+ case SWAPGETLEFT: -+ return(nfree / div); -+ case SWAPGETTOTAL: -+ return(avail / div); -+ } -+} -+ -+#else /* freebsd2 */ -+ -+int -+getswap(rettype) - int rettype; - { - int spaceleft=0, spacetotal=0, i, fd; -@@ -230,15 +398,18 @@ - if (KNLookup(NL_SWDEVT,(int *) swdevt, sizeof(struct swdevt)*nswapdev) - == NULL) - return(0); -+ - for (i=0; i < nswapdev; i++) { - if (swdevt[i].sw_enable) { - spacetotal += swdevt[i].sw_nblks; - spaceleft += (swdevt[i].sw_nfpgs * 4); - } - } -+ - if (KNLookup(NL_FSWDEVT,(int *) fswdevt, sizeof(struct fswdevt)*nswapfs) - == NULL) - return(0); -+ - for (i=0; i < nswapfs; i++) { - if (fswdevt[i].fsw_enable) { - spacetotal += (fswdevt[i].fsw_limit * 2048); /* 2048=bytes per page? */ -@@ -247,6 +418,7 @@ - /* 37 = calculated value I know it makes no sense, nor is it accurate */ - } - } -+ - /* this is a real hack. I need to get the hold info from swapinfo, but - I can't figure out how to read it out of the kernel directly - -- Wes */ -@@ -271,20 +443,16 @@ - return(spacetotal); - } - } -+#endif /* freebsd2 */ - --unsigned char *var_extensible_mem(vp, name, length, exact, var_len, write_method) -- register struct variable *vp; --/* IN - pointer to variable entry that points here */ -- register oid *name; --/* IN/OUT - input name requested, output name found */ -- register int *length; --/* IN/OUT - length of input and output oid's */ -- int exact; --/* IN - TRUE if an exact match was requested. */ -- int *var_len; --/* OUT - length of variable or 0 if function returned. */ -- int (**write_method)(); --/* OUT - pointer to function to set variable, otherwise 0 */ -+unsigned char * -+var_extensible_mem(vp, name, length, exact, var_len, write_method) -+ register struct variable *vp; /* IN - pointer to variable entry that points here */ -+ register oid *name; /* IN/OUT - input name requested, output name found */ -+ register int *length; /* IN/OUT - length of input and output oid's */ -+ int exact; /* IN - TRUE if an exact match was requested. */ -+ int *var_len; /* OUT - length of variable or 0 if function returned. */ -+ int (**write_method)(); /* OUT - pointer to function to set variable, otherwise 0 */ - { - - oid newname[30]; -@@ -298,11 +466,15 @@ - - if (!checkmib(vp,name,length,exact,var_len,write_method,newname,1)) - return(NULL); --#ifdef bsdi2 -+#if defined(bsdi2) || defined(freebsd2) - /* sum memory statistics */ - { - size_t size = sizeof(total); -+#ifdef freebsd2 -+ static int mib[] = { CTL_VM, VM_METER }; -+#else - static int mib[] = { CTL_VM, VM_TOTAL }; -+#endif - if (sysctl(mib, 2, &total, &size, NULL, 0) < 0) return (0); - } - #else -@@ -328,7 +500,7 @@ - long_ret = minimumswap; - return((u_char *) (&long_ret)); - case MEMTOTALREAL: --#ifdef bsdi2 -+#if defined (bsdi2) || defined (freebsd2) - { - size_t size = sizeof(long_ret); - static int mib[] = { CTL_HW, HW_PHYSMEM }; -@@ -345,8 +517,15 @@ - case MEMUSEDREAL: - long_ret = pagetok((int) total.t_arm); - return((u_char *) (&long_ret)); -+#ifdef freebsd2 - case MEMTOTALSWAPTXT: --#ifndef bsdi2 -+ case MEMUSEDSWAPTXT: -+ case MEMTOTALREALTXT: -+ case MEMUSEDREALTXT: -+ return(NULL); -+#else -+ case MEMTOTALSWAPTXT: -+#ifndef bsdi2 - long_ret = pagetok(total.t_vmtxt); - #endif - return((u_char *) (&long_ret)); -@@ -365,6 +544,7 @@ - long_ret = pagetok(total.t_armtxt); - #endif - return((u_char *) (&long_ret)); -+#endif /* freebsd2 */ - case MEMTOTALFREE: - long_ret = pagetok(total.t_free); - return((u_char *) (&long_ret)); -@@ -382,15 +562,15 @@ - return((u_char *) (errmsg)); - } - } -- --#endif -+#endif /* USEMEMMIB */ - - static int numdisks; - struct diskpart disks[MAXDISKS]; - - #if defined(USEDISKMIB) - --unsigned char *var_extensible_disk(vp, name, length, exact, var_len, write_method) -+unsigned char * -+var_extensible_disk(vp, name, length, exact, var_len, write_method) - register struct variable *vp; - /* IN - pointer to variable entry that points here */ - register oid *name; -@@ -415,16 +595,16 @@ - - #if defined(HAVE_STATVFS) || defined(HAVE_STATFS) - struct statvfs vfs; --#else --#if HAVE_FSTAB_H -+#elif HAVE_SYS_MOUNT_H -+ struct statfs vfs; -+#elif HAVE_FSTAB_H - int file; - union { - struct fs iu_fs; - char dummy[SBSIZE]; - } sb; - #define filesys sb.iu_fs --#endif --#endif -+#endif /* HAVE_SYS_STATVFS_H */ - - if (!checkmib(vp,name,length,exact,var_len,write_method,newname,numdisks)) - return(NULL); -@@ -481,8 +661,7 @@ - *var_len = strlen(errmsg); - return((u_char *) (errmsg)); - } --#else --#if HAVE_FSTAB_H -+#elif HAVE_FSTAB_H - /* read the disk information */ - if ((file = open(disks[disknum].device,0)) < 0) { - fprintf(stderr,"Couldn't open device %s\n",disks[disknum].device); -@@ -536,14 +715,15 @@ - } - - /*#endif*/ --#endif -+/*#endif*/ - - #define NOERR 0 - #define LOCKDBROKE 1 - #define OPENERR 2 - - /* --static int locktimeouttest; -+static int -+locktimeouttest; - - int lockd_timeout() - { -@@ -552,7 +732,8 @@ - */ - - #ifdef USELOCKDMIB --long lockd_test(msg) -+long -+lockd_test(msg) - char *msg; - { - -@@ -590,7 +771,8 @@ - } - - --unsigned char *var_extensible_lockd_test(vp, name, length, exact, var_len, write_method) -+unsigned char * -+var_extensible_lockd_test(vp, name, length, exact, var_len, write_method) - register struct variable *vp; - /* IN - pointer to variable entry that points here */ - register oid *name; -@@ -636,19 +818,14 @@ - #endif - #ifdef USELOADAVEMIB - --unsigned char *var_extensible_loadave(vp, name, length, exact, var_len, write_method) -- register struct variable *vp; --/* IN - pointer to variable entry that points here */ -- register oid *name; --/* IN/OUT - input name requested, output name found */ -- register int *length; --/* IN/OUT - length of input and output oid's */ -- int exact; --/* IN - TRUE if an exact match was requested. */ -- int *var_len; --/* OUT - length of variable or 0 if function returned. */ -- int (**write_method)(); --/* OUT - pointer to function to set variable, otherwise 0 */ -+unsigned char * -+var_extensible_loadave(vp, name, length, exact, var_len, write_method) -+ register struct variable *vp; /* IN - pointer to variable entry that points here */ -+ register oid *name; /* IN/OUT - input name requested, output name found */ -+ register int *length; /* IN/OUT - length of input and output oid's */ -+ int exact; /* IN - TRUE if an exact match was requested. */ -+ int *var_len; /* OUT - length of variable or 0 if function returned. */ -+ int (**write_method)(); /* OUT - pointer to function to set variable, otherwise 0 */ - { - - oid newname[30]; -@@ -755,7 +932,8 @@ - - #ifdef USEERRORMIB - --unsigned char *var_extensible_errors(vp, name, length, exact, var_len, write_method) -+unsigned char * -+var_extensible_errors(vp, name, length, exact, var_len, write_method) - register struct variable *vp; - /* IN - pointer to variable entry that points here */ - register oid *name; -@@ -885,7 +1063,8 @@ - return compare((*ap)->miboid,(*ap)->miblen,(*bp)->miboid,(*bp)->miblen); - } - --RETSIGTYPE update_config(a) -+RETSIGTYPE -+update_config(a) - int a; - { - extern struct subtree *subtrees; -@@ -1013,7 +1192,7 @@ - } - - #ifdef USEMEMMIB --#ifndef bsdi2 -+#if !defined(bsdi2) && !defined(freebsd2) - if (KNLookup(NL_NSWAPDEV,(int *) &nswapdev, sizeof(nswapdev)) - == NULL) - return; -@@ -1021,7 +1200,15 @@ - == NULL) - return; - #endif -+#ifdef freebsd2 -+#ifdef PAGE_SHIFT -+ pagesize = 1 << PAGE_SHIFT; -+#else - pagesize = 1 << PGSHIFT; -+#endif -+#else -+ pagesize = 1 << PGSHIFT; -+#endif - pageshift = 0; - while (pagesize > 1) { - pageshift++; diff -urN ucd-snmp-/patches/patch-ae ucd-snmp/patches/patch-ae --- ucd-snmp-/patches/patch-ae Thu Jan 1 09:00:00 1970 +++ ucd-snmp/patches/patch-ae Wed May 21 23:50:11 1997 @@ -0,0 +1,686 @@ +*** agent/extensible/extensible.c.orig Thu Feb 6 01:10:34 1997 +--- agent/extensible/extensible.c Wed May 21 23:49:35 1997 +*************** +*** 17,22 **** +--- 17,23 ---- + #if HAVE_SYS_VMMETER_H + #ifndef bsdi2 + #include ++ #include + #endif + #endif + #if HAVE_SYS_CONF_H +*************** +*** 75,80 **** +--- 76,85 ---- + #if STDC_HEADERS + #include + #endif ++ #ifdef freebsd2 ++ #include ++ #include ++ #endif + + #include "mibincl.h" + #include "mibdefs.h" +*************** +*** 101,107 **** + static int exceptions[] = SECURITYEXCEPTIONS; + #endif + +! int checkmib(vp,name,length,exact,var_len,write_method,newname,max) + register struct variable *vp; + register oid *name; + register int *length; +--- 106,113 ---- + static int exceptions[] = SECURITYEXCEPTIONS; + #endif + +! int +! checkmib(vp, name, length, exact, var_len, write_method, newname, max) + register struct variable *vp; + register oid *name; + register int *length; +*************** +*** 133,140 **** + memmove(newname, vp->name, (int)vp->namelen * sizeof (oid)); + newname[vp->namelen] = 1; + *length = vp->namelen+1; +! } +! else { + *length = vp->namelen+1; + memmove(newname, name, (*length) * sizeof(oid)); + if (!exact) +--- 139,145 ---- + memmove(newname, vp->name, (int)vp->namelen * sizeof (oid)); + newname[vp->namelen] = 1; + *length = vp->namelen+1; +! } else { + *length = vp->namelen+1; + memmove(newname, name, (*length) * sizeof(oid)); + if (!exact) +*************** +*** 171,176 **** +--- 176,208 ---- + } + + #define pagetok(size) ((size) << pageshift) ++ #define KNLookup(nl_which, buf, s) (klookup((int) nl[nl_which].n_value, buf, s)) ++ ++ #ifdef freebsd2 ++ ++ /* ++ * FreeBSD 2.x uses sysctl() for most of it's work, so we only need to ++ * find kernel objects for the swap statistics. ++ */ ++ ++ static struct nlist nl[] = { ++ #define NL_SWAPLIST 0 ++ { "_swaplist" }, ++ #define NL_SWDEVT 1 ++ { "_swdevt" }, ++ #define NL_NSWAP 2 ++ { "_nswap" }, ++ #define NL_NSWDEV 3 ++ { "_nswdev" }, ++ #define NL_DMMAX 4 ++ { "_dmmax" }, ++ #define NL_MAXMEM 5 ++ { "_Maxmem"}, ++ { 0 }, ++ }; ++ ++ #else /* freebsd2 */ ++ + #define NL_AVENRUN 0 + #define NL_TOTAL 1 + #define NL_SWDEVT 2 +*************** +*** 178,185 **** + #define NL_NSWAPFS 4 + #define NL_NSWAPDEV 5 + #define NL_PHYSMEM 6 +- #define KNLookup(nl_which, buf, s) (klookup((int) nl[nl_which].n_value, buf, s)) +- + static struct nlist nl[] = { + #if !defined(hpux) && !defined(solaris2) + { "_avenrun"}, +--- 210,215 ---- +*************** +*** 201,206 **** +--- 231,238 ---- + { 0 } + }; + ++ #endif /* freebsd2 */ ++ + #define SWAPGETLEFT 0 + #define SWAPGETTOTAL 1 + +*************** +*** 209,215 **** + + #ifdef USEMEMMIB + +! int getswap(rettype) + int rettype; + { + int spaceleft=0, spacetotal=0, i, fd; +--- 241,384 ---- + + #ifdef USEMEMMIB + +! #ifdef freebsd2 +! /* +! * getswap is based on a program called swapinfo written +! * by Kevin Lahey . +! */ +! +! #define KGET(idx, var) \ +! KGET1(idx, &var, sizeof(var)) +! +! #define KGET1(idx, p, s) \ +! KGET2(nl[idx].n_value, p, s) +! +! #define KGET2(addr, p, s) \ +! if (klookup((int) (addr), p, s) == NULL) \ +! return(NULL); +! +! int +! getswap(rettype) +! int rettype; +! { +! char *header; +! int hlen, nswap, nswdev, dmmax; +! int i, div, avail, nfree, npfree, used; +! struct swdevt *sw; +! long blocksize, *perdev; +! struct rlist head; +! u_long ptr; +! #if __FreeBSD_version >= 220000 +! struct rlisthdr swaplist; +! struct rlist *swapptr; +! #else +! struct rlist *swaplist; +! #endif +! +! KGET(NL_NSWAP, nswap); +! KGET(NL_NSWDEV, nswdev); +! KGET(NL_DMMAX, dmmax); +! KGET(NL_SWAPLIST, swaplist); +! if ((sw = malloc(nswdev * sizeof(*sw))) == NULL || +! (perdev = malloc(nswdev * sizeof(*perdev))) == NULL) +! err(1, "malloc"); +! KGET1(NL_SWDEVT, &ptr, sizeof ptr); +! KGET2(ptr, sw, nswdev * sizeof(*sw)); +! +! /* Count up swap space. */ +! nfree = 0; +! memset(perdev, 0, nswdev * sizeof(*perdev)); +! +! #if __FreeBSD_version >= 220000 +! swapptr = swaplist.rlh_list; +! while (swapptr) { +! #else +! while (swaplist) { +! #endif +! int top, bottom, next_block; +! +! #if __FreeBSD_version >= 220000 +! KGET2(swapptr, &head, sizeof(struct rlist)); +! #else +! KGET2(swaplist, &head, sizeof(struct rlist)); +! #endif +! +! top = head.rl_end; +! bottom = head.rl_start; +! +! nfree += top - bottom + 1; +! +! /* +! * Swap space is split up among the configured disks. +! * +! * For interleaved swap devices, the first dmmax blocks +! * of swap space some from the first disk, the next dmmax +! * blocks from the next, and so on up to nswap blocks. +! * +! * The list of free space joins adjacent free blocks, +! * ignoring device boundries. If we want to keep track +! * of this information per device, we'll just have to +! * extract it ourselves. +! */ +! while (top / dmmax != bottom / dmmax) { +! next_block = ((bottom + dmmax) / dmmax); +! perdev[(bottom / dmmax) % nswdev] += +! next_block * dmmax - bottom; +! bottom = next_block * dmmax; +! } +! perdev[(bottom / dmmax) % nswdev] += +! top - bottom + 1; +! +! #if __FreeBSD_version >= 220000 +! swapptr = head.rl_next; +! #else +! swaplist = head.rl_next; +! #endif +! } +! +! header = getbsize(&hlen, &blocksize); +! div = blocksize / 512; +! avail = npfree = 0; +! for (i = 0; i < nswdev; i++) { +! int xsize, xfree; +! +! /* +! * Don't report statistics for partitions which have not +! * yet been activated via swapon(8). +! */ +! if (!(sw[i].sw_flags & SW_FREED)) +! continue; +! +! /* The first dmmax is never allocated to avoid trashing of +! * disklabels +! */ +! xsize = sw[i].sw_nblks - dmmax; +! xfree = perdev[i]; +! used = xsize - xfree; +! npfree++; +! avail += xsize; +! } +! +! /* +! * If only one partition has been set up via swapon(8), we don't +! * need to bother with totals. +! */ +! used = avail - nfree; +! +! free(sw); free(perdev); +! +! switch (rettype) { +! case SWAPGETLEFT: +! return(nfree / div); +! case SWAPGETTOTAL: +! return(avail / div); +! } +! } +! +! #else /* freebsd2 */ +! +! int +! getswap(rettype) + int rettype; + { + int spaceleft=0, spacetotal=0, i, fd; +*************** +*** 230,244 **** +--- 399,416 ---- + if (KNLookup(NL_SWDEVT,(int *) swdevt, sizeof(struct swdevt)*nswapdev) + == NULL) + return(0); ++ + for (i=0; i < nswapdev; i++) { + if (swdevt[i].sw_enable) { + spacetotal += swdevt[i].sw_nblks; + spaceleft += (swdevt[i].sw_nfpgs * 4); + } + } ++ + if (KNLookup(NL_FSWDEVT,(int *) fswdevt, sizeof(struct fswdevt)*nswapfs) + == NULL) + return(0); ++ + for (i=0; i < nswapfs; i++) { + if (fswdevt[i].fsw_enable) { + spacetotal += (fswdevt[i].fsw_limit * 2048); /* 2048=bytes per page? */ +*************** +*** 247,252 **** +--- 419,425 ---- + /* 37 = calculated value I know it makes no sense, nor is it accurate */ + } + } ++ + /* this is a real hack. I need to get the hold info from swapinfo, but + I can't figure out how to read it out of the kernel directly + -- Wes */ +*************** +*** 271,290 **** + return(spacetotal); + } + } + +! unsigned char *var_extensible_mem(vp, name, length, exact, var_len, write_method) +! register struct variable *vp; +! /* IN - pointer to variable entry that points here */ +! register oid *name; +! /* IN/OUT - input name requested, output name found */ +! register int *length; +! /* IN/OUT - length of input and output oid's */ +! int exact; +! /* IN - TRUE if an exact match was requested. */ +! int *var_len; +! /* OUT - length of variable or 0 if function returned. */ +! int (**write_method)(); +! /* OUT - pointer to function to set variable, otherwise 0 */ + { + + oid newname[30]; +--- 444,459 ---- + return(spacetotal); + } + } ++ #endif /* freebsd2 */ + +! unsigned char * +! var_extensible_mem(vp, name, length, exact, var_len, write_method) +! register struct variable *vp; /* IN - pointer to variable entry that points here */ +! register oid *name; /* IN/OUT - input name requested, output name found */ +! register int *length; /* IN/OUT - length of input and output oid's */ +! int exact; /* IN - TRUE if an exact match was requested. */ +! int *var_len; /* OUT - length of variable or 0 if function returned. */ +! int (**write_method)(); /* OUT - pointer to function to set variable, otherwise 0 */ + { + + oid newname[30]; +*************** +*** 298,308 **** + + if (!checkmib(vp,name,length,exact,var_len,write_method,newname,1)) + return(NULL); +! #ifdef bsdi2 + /* sum memory statistics */ + { + size_t size = sizeof(total); + static int mib[] = { CTL_VM, VM_TOTAL }; + if (sysctl(mib, 2, &total, &size, NULL, 0) < 0) return (0); + } + #else +--- 467,481 ---- + + if (!checkmib(vp,name,length,exact,var_len,write_method,newname,1)) + return(NULL); +! #if defined(bsdi2) || defined(freebsd2) + /* sum memory statistics */ + { + size_t size = sizeof(total); ++ #ifdef freebsd2 ++ static int mib[] = { CTL_VM, VM_METER }; ++ #else + static int mib[] = { CTL_VM, VM_TOTAL }; ++ #endif + if (sysctl(mib, 2, &total, &size, NULL, 0) < 0) return (0); + } + #else +*************** +*** 328,334 **** + long_ret = minimumswap; + return((u_char *) (&long_ret)); + case MEMTOTALREAL: +! #ifdef bsdi2 + { + size_t size = sizeof(long_ret); + static int mib[] = { CTL_HW, HW_PHYSMEM }; +--- 501,507 ---- + long_ret = minimumswap; + return((u_char *) (&long_ret)); + case MEMTOTALREAL: +! #if defined (bsdi2) || defined (freebsd2) + { + size_t size = sizeof(long_ret); + static int mib[] = { CTL_HW, HW_PHYSMEM }; +*************** +*** 345,352 **** + case MEMUSEDREAL: + long_ret = pagetok((int) total.t_arm); + return((u_char *) (&long_ret)); + case MEMTOTALSWAPTXT: +! #ifndef bsdi2 + long_ret = pagetok(total.t_vmtxt); + #endif + return((u_char *) (&long_ret)); +--- 518,532 ---- + case MEMUSEDREAL: + long_ret = pagetok((int) total.t_arm); + return((u_char *) (&long_ret)); ++ #ifdef freebsd2 + case MEMTOTALSWAPTXT: +! case MEMUSEDSWAPTXT: +! case MEMTOTALREALTXT: +! case MEMUSEDREALTXT: +! return(NULL); +! #else +! case MEMTOTALSWAPTXT: +! #ifndef bsdi2 + long_ret = pagetok(total.t_vmtxt); + #endif + return((u_char *) (&long_ret)); +*************** +*** 365,370 **** +--- 545,551 ---- + long_ret = pagetok(total.t_armtxt); + #endif + return((u_char *) (&long_ret)); ++ #endif /* freebsd2 */ + case MEMTOTALFREE: + long_ret = pagetok(total.t_free); + return((u_char *) (&long_ret)); +*************** +*** 382,396 **** + return((u_char *) (errmsg)); + } + } +! +! #endif + + static int numdisks; + struct diskpart disks[MAXDISKS]; + + #if defined(USEDISKMIB) + +! unsigned char *var_extensible_disk(vp, name, length, exact, var_len, write_method) + register struct variable *vp; + /* IN - pointer to variable entry that points here */ + register oid *name; +--- 563,577 ---- + return((u_char *) (errmsg)); + } + } +! #endif /* USEMEMMIB */ + + static int numdisks; + struct diskpart disks[MAXDISKS]; + + #if defined(USEDISKMIB) + +! unsigned char * +! var_extensible_disk(vp, name, length, exact, var_len, write_method) + register struct variable *vp; + /* IN - pointer to variable entry that points here */ + register oid *name; +*************** +*** 415,430 **** + + #if defined(HAVE_STATVFS) || defined(HAVE_STATFS) + struct statvfs vfs; +! #else +! #if HAVE_FSTAB_H + int file; + union { + struct fs iu_fs; + char dummy[SBSIZE]; + } sb; + #define filesys sb.iu_fs +! #endif +! #endif + + if (!checkmib(vp,name,length,exact,var_len,write_method,newname,numdisks)) + return(NULL); +--- 596,611 ---- + + #if defined(HAVE_STATVFS) || defined(HAVE_STATFS) + struct statvfs vfs; +! #elif HAVE_SYS_MOUNT_H +! struct statfs vfs; +! #elif HAVE_FSTAB_H + int file; + union { + struct fs iu_fs; + char dummy[SBSIZE]; + } sb; + #define filesys sb.iu_fs +! #endif /* HAVE_SYS_STATVFS_H */ + + if (!checkmib(vp,name,length,exact,var_len,write_method,newname,numdisks)) + return(NULL); +*************** +*** 481,488 **** + *var_len = strlen(errmsg); + return((u_char *) (errmsg)); + } +! #else +! #if HAVE_FSTAB_H + /* read the disk information */ + if ((file = open(disks[disknum].device,0)) < 0) { + fprintf(stderr,"Couldn't open device %s\n",disks[disknum].device); +--- 662,668 ---- + *var_len = strlen(errmsg); + return((u_char *) (errmsg)); + } +! #elif HAVE_FSTAB_H + /* read the disk information */ + if ((file = open(disks[disknum].device,0)) < 0) { + fprintf(stderr,"Couldn't open device %s\n",disks[disknum].device); +*************** +*** 536,549 **** + } + + /*#endif*/ +! #endif + + #define NOERR 0 + #define LOCKDBROKE 1 + #define OPENERR 2 + + /* +! static int locktimeouttest; + + int lockd_timeout() + { +--- 716,730 ---- + } + + /*#endif*/ +! /*#endif*/ + + #define NOERR 0 + #define LOCKDBROKE 1 + #define OPENERR 2 + + /* +! static int +! locktimeouttest; + + int lockd_timeout() + { +*************** +*** 552,558 **** + */ + + #ifdef USELOCKDMIB +! long lockd_test(msg) + char *msg; + { + +--- 733,740 ---- + */ + + #ifdef USELOCKDMIB +! long +! lockd_test(msg) + char *msg; + { + +*************** +*** 590,596 **** + } + + +! unsigned char *var_extensible_lockd_test(vp, name, length, exact, var_len, write_method) + register struct variable *vp; + /* IN - pointer to variable entry that points here */ + register oid *name; +--- 772,779 ---- + } + + +! unsigned char * +! var_extensible_lockd_test(vp, name, length, exact, var_len, write_method) + register struct variable *vp; + /* IN - pointer to variable entry that points here */ + register oid *name; +*************** +*** 636,654 **** + #endif + #ifdef USELOADAVEMIB + +! unsigned char *var_extensible_loadave(vp, name, length, exact, var_len, write_method) +! register struct variable *vp; +! /* IN - pointer to variable entry that points here */ +! register oid *name; +! /* IN/OUT - input name requested, output name found */ +! register int *length; +! /* IN/OUT - length of input and output oid's */ +! int exact; +! /* IN - TRUE if an exact match was requested. */ +! int *var_len; +! /* OUT - length of variable or 0 if function returned. */ +! int (**write_method)(); +! /* OUT - pointer to function to set variable, otherwise 0 */ + { + + oid newname[30]; +--- 819,832 ---- + #endif + #ifdef USELOADAVEMIB + +! unsigned char * +! var_extensible_loadave(vp, name, length, exact, var_len, write_method) +! register struct variable *vp; /* IN - pointer to variable entry that points here */ +! register oid *name; /* IN/OUT - input name requested, output name found */ +! register int *length; /* IN/OUT - length of input and output oid's */ +! int exact; /* IN - TRUE if an exact match was requested. */ +! int *var_len; /* OUT - length of variable or 0 if function returned. */ +! int (**write_method)(); /* OUT - pointer to function to set variable, otherwise 0 */ + { + + oid newname[30]; +*************** +*** 755,761 **** + + #ifdef USEERRORMIB + +! unsigned char *var_extensible_errors(vp, name, length, exact, var_len, write_method) + register struct variable *vp; + /* IN - pointer to variable entry that points here */ + register oid *name; +--- 933,940 ---- + + #ifdef USEERRORMIB + +! unsigned char * +! var_extensible_errors(vp, name, length, exact, var_len, write_method) + register struct variable *vp; + /* IN - pointer to variable entry that points here */ + register oid *name; +*************** +*** 885,891 **** + return compare((*ap)->miboid,(*ap)->miblen,(*bp)->miboid,(*bp)->miblen); + } + +! RETSIGTYPE update_config(a) + int a; + { + extern struct subtree *subtrees; +--- 1064,1071 ---- + return compare((*ap)->miboid,(*ap)->miblen,(*bp)->miboid,(*bp)->miblen); + } + +! RETSIGTYPE +! update_config(a) + int a; + { + extern struct subtree *subtrees; +*************** +*** 1013,1019 **** + } + + #ifdef USEMEMMIB +! #ifndef bsdi2 + if (KNLookup(NL_NSWAPDEV,(int *) &nswapdev, sizeof(nswapdev)) + == NULL) + return; +--- 1193,1199 ---- + } + + #ifdef USEMEMMIB +! #if !defined(bsdi2) && !defined(freebsd2) + if (KNLookup(NL_NSWAPDEV,(int *) &nswapdev, sizeof(nswapdev)) + == NULL) + return; +*************** +*** 1021,1027 **** +--- 1201,1215 ---- + == NULL) + return; + #endif ++ #ifdef freebsd2 ++ #ifdef PAGE_SHIFT ++ pagesize = 1 << PAGE_SHIFT; ++ #else + pagesize = 1 << PGSHIFT; ++ #endif ++ #else ++ pagesize = 1 << PGSHIFT; ++ #endif + pageshift = 0; + while (pagesize > 1) { + pageshift++; >Audit-Trail: >Unformatted: