From owner-freebsd-bugs Thu May 10 11:10:27 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 7586B37B42C for ; Thu, 10 May 2001 11:10:03 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f4AIA3k35399; Thu, 10 May 2001 11:10:03 -0700 (PDT) (envelope-from gnats) Received: from mail.disney.com (mail.disney.com [204.128.192.15]) by hub.freebsd.org (Postfix) with ESMTP id 771AF37B422 for ; Thu, 10 May 2001 11:06:33 -0700 (PDT) (envelope-from Jim.Pirzyk@disney.com) Received: from pain10.corp.disney.com (root@pain10.corp.disney.com [153.7.110.100]) by mail.disney.com (Switch-2.0.1/Switch-2.0.1) with SMTP id f4AI5vA28423 for ; Thu, 10 May 2001 11:05:57 -0700 (PDT) Received: from louie.fa.disney.com by pain.corp.disney.com with ESMTP for FreeBSD-gnats-submit@freebsd.org; Thu, 10 May 2001 11:07:13 -0700 Received: from plio.fan.fa.disney.com (plio.fan.fa.disney.com [153.7.118.2]) by louie.fa.disney.com (8.9.2/8.9.2) with ESMTP id LAA02987 for ; Thu, 10 May 2001 11:06:25 -0700 (PDT) (envelope-from Jim.Pirzyk@fa.disney.com) Received: from snoopy.fan.fa.disney.com (snoopy.fan.fa.disney.com [153.7.117.170]) by plio.fan.fa.disney.com (8.9.2/8.9.2) with ESMTP id LAA05789 for ; Thu, 10 May 2001 11:06:25 -0700 (PDT) (envelope-from Jim.Pirzyk@fa.disney.com) Received: (from Jim.Pirzyk@localhost) by snoopy.fan.fa.disney.com (8.11.3/8.9.3) id f4AI6OM38175; Thu, 10 May 2001 11:06:24 -0700 (PDT) (envelope-from Jim.Pirzyk@fa.disney.com) Message-Id: <200105101806.f4AI6OM38175@snoopy.fan.fa.disney.com> Date: Thu, 10 May 2001 11:06:24 -0700 (PDT) From: Jim.Pirzyk@disney.com Reply-To: Jim.Pirzyk@disney.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: kern/27253: linprocfs does not have /proc/loadavg Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 27253 >Category: kern >Synopsis: linprocfs does not implement the loadavg file. >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu May 10 11:10:03 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Jim Pirzyk >Release: FreeBSD 4.3-RELEASE i386 >Organization: >Environment: System: FreeBSD snoopy.fan.fa.disney.com 4.3-RELEASE FreeBSD 4.3-RELEASE #4: Fri Apr 27 01:14:59 PDT 2001 root@snoopy.fan.fa.disney.com:/auto/roy/dist/pub/FreeBSD/4.3-RELEASE/sys/compile/UP_WORKSTATION i386 >Description: We have linux binaries that need to access /proc/loadavg to get status of the system so we need this file. >How-To-Repeat: mount -t linprocfs /compat/linux/proc ls -la /compat/linux/proc/loadavg >Fix: *** ./sys/i386/linux/linprocfs/linprocfs.h.orig Mon Oct 30 11:57:04 2000 --- ./sys/i386/linux/linprocfs/linprocfs.h Tue May 8 09:09:50 2001 *************** *** 57,62 **** --- 57,63 ---- Pstat, /* kernel/system statistics */ Puptime, /* system uptime */ Pversion, /* system version */ + Ploadavg, /* system load average */ } pfstype; /* *************** *** 132,137 **** --- 133,139 ---- int linprocfs_doversion __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); int linprocfs_doprocstat __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); int linprocfs_doprocstatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); + int linprocfs_doloadavg __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); /* functions to check whether or not files should be displayed */ int linprocfs_validfile __P((struct proc *)); *** ./sys/i386/linux/linprocfs/linprocfs_misc.c.orig Thu Dec 7 05:17:55 2000 --- ./sys/i386/linux/linprocfs/linprocfs_misc.c Tue May 8 16:09:17 2001 *************** *** 495,498 **** --- 495,531 ---- ps = psbuf + uio->uio_offset; xlen = imin(xlen, uio->uio_resid); return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio)); + } + + int + linprocfs_doloadavg(curp, p, pfs, uio) + struct proc *curp; + struct proc *p; + struct pfsnode *pfs; + struct uio *uio; + { + char *ps, psbuf[512]; + int xlen; + extern int nextpid; + + ps=psbuf; + + ps += sprintf(ps, + "%d.%02d %d.%02d %d.%02d %d/%d %d\n", + (int)(averunnable.ldavg[0] / averunnable.fscale), + (int)(averunnable.ldavg[0] * 100 / averunnable.fscale % 100), + (int)(averunnable.ldavg[1] / averunnable.fscale), + (int)(averunnable.ldavg[1] * 100 / averunnable.fscale % 100), + (int)(averunnable.ldavg[2] / averunnable.fscale), + (int)(averunnable.ldavg[2] * 100 / averunnable.fscale % 100), + 1, /* number of running tasks */ + -1, /* number of tasks */ + nextpid /* The last pid */ + ); + + xlen = ps - psbuf; + xlen -= uio->uio_offset; + ps = psbuf + uio->uio_offset; + xlen = imin(xlen, uio->uio_resid); + return (xlen <= 0 ? 0 : uiomove(ps, xlen, uio)); } *** ./sys/i386/linux/linprocfs/linprocfs_subr.c.orig Mon Oct 30 11:57:04 2000 --- ./sys/i386/linux/linprocfs/linprocfs_subr.c Tue May 8 09:13:20 2001 *************** *** 184,189 **** --- 184,190 ---- case Pstat: case Puptime: case Pversion: + case Ploadavg: pfs->pfs_mode = (VREAD) | (VREAD >> 3) | (VREAD >> 6); *************** *** 275,280 **** --- 276,284 ---- break; case Pversion: rtval = linprocfs_doversion(curp, p, pfs, uio); + break; + case Ploadavg: + rtval = linprocfs_doloadavg(curp, p, pfs, uio); break; default: rtval = EOPNOTSUPP; *** ./sys/i386/linux/linprocfs/linprocfs_vnops.c.orig Mon Oct 30 11:57:04 2000 --- ./sys/i386/linux/linprocfs/linprocfs_vnops.c Tue May 8 09:14:47 2001 *************** *** 529,534 **** --- 529,535 ---- case Pstat: case Puptime: case Pversion: + case Ploadavg: vap->va_bytes = vap->va_size = 0; vap->va_uid = 0; vap->va_gid = 0; *************** *** 706,711 **** --- 707,714 ---- return (linprocfs_allocvp(dvp->v_mount, vpp, 0, Puptime)); if (CNEQ(cnp, "version", 7)) return (linprocfs_allocvp(dvp->v_mount, vpp, 0, Pversion)); + if (CNEQ(cnp, "loadavg", 7)) + return (linprocfs_allocvp(dvp->v_mount, vpp, 0, Ploadavg)); pid = atopid(pname, cnp->cn_namelen); if (pid == NO_PID) *************** *** 901,906 **** --- 904,917 ---- bcopy("version", dp->d_name, 8); dp->d_type = DT_REG; break; + + case 8: + dp->d_fileno = PROCFS_FILENO(0, Ploadavg); + dp->d_namlen = 7; + bcopy("loadavg", dp->d_name, 8); + dp->d_type = DT_REG; + break; + default: while (pcnt < i) { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message