~mcf/drawterm

284fa7cf7e8667a67491a6e56c68accd92ccd2c9 — 5 months ago d28c5f3
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
8 files changed, 6 insertions(+), 59 deletions(-)

M kern/dat.h
M kern/devcons.c
M kern/fns.h
M kern/pgrp.c
M kern/stub.c
M kern/sysfile.c
M libc/Makefile
D libc/getpid.c
M kern/dat.h => kern/dat.h +0 -3
@@ 162,7 162,6 @@ struct Chan
	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 @@ struct Pgrp
{
	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 @@ struct Proc
	uint	mach;

	ulong	pid;
	ulong	parentpid;

	Pgrp	*pgrp;		/* Process group for namespace */
	Fgrp	*fgrp;		/* File descriptor group */

M kern/devcons.c => kern/devcons.c +0 -28
@@ 331,7 331,6 @@ enum{
	Qbintime,
	Qcons,
	Qconsctl,
	Qcputime,
	Qdrivers,
	Qkmesg,
	Qkprint,


@@ 339,9 338,6 @@ enum{
	Qhostowner,
	Qnull,
	Qosversion,
	Qpgrpid,
	Qpid,
	Qppid,
	Qrandom,
	Qreboot,
	Qshowfile,


@@ 349,7 345,6 @@ enum{
	Qsysname,
	Qsysstat,
	Qtime,
	Quser,
	Qzero,
};



@@ 363,7 358,6 @@ static Dirtab consdir[]={
	"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 @@ static Dirtab consdir[]={
	"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 @@ static Dirtab consdir[]={
	"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 @@ consread(Chan *c, void *buf, long n, vlong off)
		poperror();
		return n;

	case Qcputime:
		return 0;

	case Qkmesg:
		/*
		 * This is unlocked to avoid tying up a process


@@ 610,15 597,6 @@ consread(Chan *c, void *buf, long n, vlong off)
	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 @@ consread(Chan *c, void *buf, long n, vlong off)
	case Qhostdomain:
		return readstr((ulong)offset, buf, n, hostdomain);

	case Quser:
		return readstr((ulong)offset, buf, n, up->user);

	case Qnull:
		return 0;



@@ 761,9 736,6 @@ conswrite(Chan *c, void *va, long n, vlong off)
	case Qhostdomain:
		return hostdomainwrite(a, n);

	case Quser:
		return userwrite(a, n);

	case Qnull:
		break;


M kern/fns.h => kern/fns.h +0 -1
@@ 204,7 204,6 @@ void		splx(int);
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);

M kern/pgrp.c => kern/pgrp.c +0 -2
@@ 4,7 4,6 @@
#include	"fns.h"
#include	"error.h"

static Ref pgrpid;
static Ref mountid;

Pgrp*


@@ 14,7 13,6 @@ newpgrp(void)

	p = smalloc(sizeof(Pgrp));
	p->ref.ref = 1;
	p->pgrpid = incref(&pgrpid);
	return p;
}


M kern/stub.c => kern/stub.c +0 -7
@@ 28,13 28,6 @@ spllo(void)
	return 0;
}

int
userwrite(char *a, int n)
{
	error(Eperm);
	return 0;
}

long
hostdomainwrite(char *a, int n)
{

M kern/sysfile.c => kern/sysfile.c +6 -0
@@ 1259,3 1259,9 @@ sysrendezvous(void *tag, void *val)
	enderror();
	return n;
}

int
sysgetpid(void)
{
	return up->pid;
}

M libc/Makefile => libc/Makefile +0 -1
@@ 35,7 35,6 @@ OFILES=\
	fprint.$O\
	getenv.$O\
	getfields.$O\
	getpid.$O\
	lock.$O\
	mallocz.$O\
	nan64.$O\

D libc/getpid.c => libc/getpid.c +0 -17
@@ 1,17 0,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);
}