From owner-freebsd-questions Tue Jul 23 11:16:50 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id LAA01461 for questions-outgoing; Tue, 23 Jul 1996 11:16:50 -0700 (PDT) Received: from relay-5.mail.demon.net (relay-5.mail.demon.net [158.152.1.48]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id LAA01452; Tue, 23 Jul 1996 11:16:47 -0700 (PDT) Received: from post.demon.co.uk by relay-5.mail.demon.net id ar19232; 23 Jul 96 19:09 +0100 Received: from jraynard.demon.co.uk ([158.152.42.77]) by relay-3.mail.demon.net id aa10431; 23 Jul 96 18:02 +0100 Received: (from fqueries@localhost) by jraynard.demon.co.uk (8.7.5/8.6.12) id NAA17597; Tue, 23 Jul 1996 13:54:40 GMT From: James Raynard Message-Id: <199607231354.NAA17597@jraynard.demon.co.uk> Subject: Re: gmake 3.74 port setgid kmem To: Gary Palmer Date: Tue, 23 Jul 1996 13:54:40 +0000 () Cc: freebsd-questions@freebsd.org In-Reply-To: <10843.838092883@orion.webspan.net> from "Gary Palmer" at Jul 22, 96 11:34:43 pm X-Mailer: ELM [version 2.4 PL24 ME8a] Content-Type: text Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > Nate Williams wrote in message ID > <199607221939.NAA21664@rocky.mt.sri.com>: > > One of the 'features' of gmake is the ability to 'stop compiling' until > > the load average of the machine goes down to an acceptable level, so it > > needs permissions to read /dev/mem to determine the load average. > > > I consider it's setgid-ness along with the 'load average' bit to be a > > mis-feature. Very much so. > It most definately is, considering you can read the load ave stuff > with sysctl, and not go ANYWHERE NEAR /dev/mem... since it's a port, > it shouldn't be TOO difficult to do this. Writing code to do this is easy, hacking configure so that the code actually gets called instead of getloadavg() is a little harder... --- getloadavg.c.orig Tue Jul 23 12:36:11 1996 +++ getloadavg.c Tue Jul 23 13:20:54 1996 @@ -52,6 +52,7 @@ __linux__ Linux: assumes /proc filesystem mounted. Support from Michael K. Johnson. __NetBSD__ NetBSD: assumes /kern filesystem mounted. + __FreeBSD__ In addition, to avoid nesting many #ifdefs, we internally set LDAV_DONE to indicate that the load average has been computed. @@ -504,6 +505,33 @@ errno = 0; elem = -1; #endif + +#if !defined (LDAV_DONE) && defined (__FreeBSD__) +#define LDAV_DONE +#undef LOAD_AVE_TYPE + +#include +#include +#include +#include + + struct loadavg load_ave; + int mib[2]; + size_t len; + + mib[0] = CTL_VM; + mib[1] = VM_LOADAVG; + len = sizeof(load_ave); + + if (sysctl(mib, 2, &load_ave, &len, NULL, 0) < 0) + return -1; + + for (elem = 0; elem < nelem; elem++) + loadavg[elem] = (double)load_ave.ldavg[elem]/(double)load_ave.fscale; + + return elem; + +#endif /* __FreeBSD__ */ #if !defined (LDAV_DONE) && defined (__linux__) #define LDAV_DONE Script started on Tue Jul 23 13:22:21 1996 # make check-loadavg The system uptime program believes the load average to be: uptime 1:22PM up 4:35, 4 users, load averages: 0.02, 0.12, 0.12 The GNU load average checking code believes: ./loadavg 1-minute: 0.020020 5-minute: 0.120605 15-minute: 0.119141 # ^D Script done on Tue Jul 23 13:22:32 1996