shithub: drawterm

Download patch

ref: c6e961742048ed15b07d7a8aa78df590852cdc7f
parent: cfda4c39d69c6653c16520276b7209cfcdf031cb
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Dec 23 10:58:36 EST 2020

kern: remove per-process information from devcons

Devcons has no business poking at the process state.

The following files are being removed:

#c/cputime
#c/pgrpid
#c/pid
#c/ppid
#c/user

--- a/kern/dat.h
+++ b/kern/dat.h
@@ -162,7 +162,6 @@
 	Mnt*	mux;			/* Mnt for clients using me for messages */
 	union {
 		void*	aux;
-		Qid	pgrpid;		/* for #p/notepg */
 		ulong	mid;		/* for ns in devproc */
 	};
 	Chan*	mchan;			/* channel to mounted server */
@@ -293,7 +292,6 @@
 {
 	Ref ref;				/* also used as a lock when mounting */
 	int	noattach;
-	ulong	pgrpid;
 	QLock	debug;			/* single access via devproc.c */
 	RWlock	ns;			/* Namespace n read/one write lock */
 	Mhead	*mnthash[MNTHASH];
@@ -355,7 +353,6 @@
 	uint	mach;
 
 	ulong	pid;
-	ulong	parentpid;
 
 	Pgrp	*pgrp;		/* Process group for namespace */
 	Fgrp	*fgrp;		/* File descriptor group */
--- a/kern/devcons.c
+++ b/kern/devcons.c
@@ -331,7 +331,6 @@
 	Qbintime,
 	Qcons,
 	Qconsctl,
-	Qcputime,
 	Qdrivers,
 	Qkmesg,
 	Qkprint,
@@ -339,9 +338,6 @@
 	Qhostowner,
 	Qnull,
 	Qosversion,
-	Qpgrpid,
-	Qpid,
-	Qppid,
 	Qrandom,
 	Qreboot,
 	Qshowfile,
@@ -349,7 +345,6 @@
 	Qsysname,
 	Qsysstat,
 	Qtime,
-	Quser,
 	Qzero,
 };
 
@@ -363,7 +358,6 @@
 	"bintime",	{Qbintime},	24,		0664,
 	"cons",		{Qcons},	0,		0660,
 	"consctl",	{Qconsctl},	0,		0220,
-	"cputime",	{Qcputime},	6*NUMSIZE,	0444,
 	"drivers",	{Qdrivers},	0,		0444,
 	"hostdomain",	{Qhostdomain},	DOMLEN,		0664,
 	"hostowner",	{Qhostowner},	0,	0664,
@@ -371,9 +365,6 @@
 	"kprint",	{Qkprint, 0, QTEXCL},	0,	DMEXCL|0440,
 	"null",		{Qnull},	0,		0666,
 	"osversion",	{Qosversion},	0,		0444,
-	"pgrpid",	{Qpgrpid},	NUMSIZE,	0444,
-	"pid",		{Qpid},		NUMSIZE,	0444,
-	"ppid",		{Qppid},	NUMSIZE,	0444,
 	"random",	{Qrandom},	0,		0444,
 	"reboot",	{Qreboot},	0,		0664,
 	"showfile",	{Qshowfile},	0,	0220,
@@ -381,7 +372,6 @@
 	"sysname",	{Qsysname},	0,		0664,
 	"sysstat",	{Qsysstat},	0,		0666,
 	"time",		{Qtime},	NUMSIZE+3*VLNUMSIZE,	0664,
-	"user",		{Quser},	0,	0666,
 	"zero",		{Qzero},	0,		0444,
 };
 
@@ -588,9 +578,6 @@
 		poperror();
 		return n;
 
-	case Qcputime:
-		return 0;
-
 	case Qkmesg:
 		/*
 		 * This is unlocked to avoid tying up a process
@@ -610,15 +597,6 @@
 	case Qkprint:
 		return qread(kprintoq, buf, n);
 
-	case Qpgrpid:
-		return readnum((ulong)offset, buf, n, up->pgrp->pgrpid, NUMSIZE);
-
-	case Qpid:
-		return readnum((ulong)offset, buf, n, up->pid, NUMSIZE);
-
-	case Qppid:
-		return readnum((ulong)offset, buf, n, up->parentpid, NUMSIZE);
-
 	case Qtime:
 		return readtime((ulong)offset, buf, n);
 
@@ -631,9 +609,6 @@
 	case Qhostdomain:
 		return readstr((ulong)offset, buf, n, hostdomain);
 
-	case Quser:
-		return readstr((ulong)offset, buf, n, up->user);
-
 	case Qnull:
 		return 0;
 
@@ -760,9 +735,6 @@
 
 	case Qhostdomain:
 		return hostdomainwrite(a, n);
-
-	case Quser:
-		return userwrite(a, n);
 
 	case Qnull:
 		break;
--- a/kern/fns.h
+++ b/kern/fns.h
@@ -204,7 +204,6 @@
 Block*		trimblock(Block*, int, int);
 long		unionread(Chan*, void*, long);
 void		unlock(Lock*);
-long		userwrite(char*, int);
 #define	validaddr(a, b, c)
 void		validname(char*, int);
 char*		validnamedup(char*, int);
--- a/kern/pgrp.c
+++ b/kern/pgrp.c
@@ -4,7 +4,6 @@
 #include	"fns.h"
 #include	"error.h"
 
-static Ref pgrpid;
 static Ref mountid;
 
 Pgrp*
@@ -14,7 +13,6 @@
 
 	p = smalloc(sizeof(Pgrp));
 	p->ref.ref = 1;
-	p->pgrpid = incref(&pgrpid);
 	return p;
 }
 
--- a/kern/stub.c
+++ b/kern/stub.c
@@ -28,13 +28,6 @@
 	return 0;
 }
 
-int
-userwrite(char *a, int n)
-{
-	error(Eperm);
-	return 0;
-}
-
 long
 hostdomainwrite(char *a, int n)
 {
--- a/kern/sysfile.c
+++ b/kern/sysfile.c
@@ -1259,3 +1259,9 @@
 	enderror();
 	return n;
 }
+
+int
+sysgetpid(void)
+{
+	return up->pid;
+}
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -35,7 +35,6 @@
 	fprint.$O\
 	getenv.$O\
 	getfields.$O\
-	getpid.$O\
 	lock.$O\
 	mallocz.$O\
 	nan64.$O\
--- a/libc/getpid.c
+++ /dev/null
@@ -1,17 +1,0 @@
-#include	<u.h>
-#include	<libc.h>
-
-int
-getpid(void)
-{
-	char b[20];
-	int f;
-
-	memset(b, 0, sizeof(b));
-	f = open("#c/pid", 0);
-	if(f >= 0) {
-		read(f, b, sizeof(b));
-		close(f);
-	}
-	return atol(b);
-}