Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Aug 2001 16:23:56 +0100 (BST)
From:      Joe Karthauser <joe@tao.org.uk>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/29682: /proc/pid/status broken for irqN processes.
Message-ID:  <20010812152356.5D3C337C@tao.org.uk>

next in thread | raw e-mail | index | archive | help

>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 <fs/procfs/procfs.h>
 
+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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010812152356.5D3C337C>