From owner-freebsd-bugs Mon Aug 13 14: 0:21 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 AE06237B40C for ; Mon, 13 Aug 2001 14:00:05 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f7DL05N69604; Mon, 13 Aug 2001 14:00:05 -0700 (PDT) (envelope-from gnats) Received: from tao.org.uk (xwing.creative.net.au [203.56.168.36]) by hub.freebsd.org (Postfix) with ESMTP id DD5D237B408 for ; Mon, 13 Aug 2001 13:52:05 -0700 (PDT) (envelope-from joe@tao.org.uk) Received: by tao.org.uk (Postfix, from userid 100) id 5D3C337C; Sun, 12 Aug 2001 16:23:56 +0100 (BST) Message-Id: <20010812152356.5D3C337C@tao.org.uk> Date: Sun, 12 Aug 2001 16:23:56 +0100 (BST) From: Joe Karthauser Reply-To: Joe Karthauser To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: kern/29682: /proc/pid/status broken for irqN processes. Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 29682 >Category: kern >Synopsis: /proc/pid/status broken for irqN processes. >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Aug 13 14:00:05 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Joe Karthauser >Release: FreeBSD 5.0-CURRENT i386 >Organization: Tao Research >Environment: System: FreeBSD genius.tao.org.uk 5.0-CURRENT FreeBSD 5.0-CURRENT #12: Sun Aug 12 14:13:44 BST 2001 root@:/usr/obj/usr/src/sys/GENIUS i386 >Description: Processes that use procfs, like wmtop, are broken under -current. This is because the /proc/pid/status file is a space separated list of entries, but irq threads in -current contain spaces in their names. This makes it impossible to parse the status file correctly. genius# cat /proc/15/status swi5: task queue 15 0 0 0 -1,-1 noflags 997626444,23 0,0 0,0 nochan 0 0 0,0 - The field 'swi5: task queue' should is a single field, but contains spaces. >How-To-Repeat: >Fix: I've fixed it locally by replacing spaces with underscores whilst constructing the status file in sys/fs/procfs/procfs_status.c. The following patch illustrates the idea, but please note that it's a hack[tm], not a recommendation: Index: procfs_status.c =================================================================== RCS file: /home/ncvs/src/sys/fs/procfs/procfs_status.c,v retrieving revision 1.32 diff -u -r1.32 procfs_status.c --- procfs_status.c 2001/07/05 17:10:43 1.32 +++ procfs_status.c 2001/08/12 15:03:10 @@ -58,6 +58,8 @@ #include +void jbcopy(const char *src0, char *dst0, register size_t length); + #define DOCHECK() do { if (ps >= psbuf+sizeof(psbuf)) goto bailout; } while (0) int procfs_dostatus(curp, p, pfs, uio) @@ -95,7 +97,7 @@ ("Too short buffer for new MAXCOMLEN")); ps = psbuf; - bcopy(p->p_comm, ps, MAXCOMLEN); + jbcopy(p->p_comm, ps, MAXCOMLEN); ps[MAXCOMLEN] = '\0'; ps += strlen(ps); DOCHECK(); @@ -188,6 +190,34 @@ bailout: return (ENOMEM); +} + + + +void +jbcopy(src0, dst0, length) + const char *src0; + char *dst0; + register size_t length; +{ + int i; + + for (i = 0 ; i < length ; ++i) { + *dst0 = *src0; + if (*dst0 == ' ') { + *dst0 = '_'; + } + if (!*src0) { + break; + } + + ++dst0; + ++src0; + } + + if (i == length) { + *dst0 = '\0'; + } } int >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message