~kris/9p

9hist

3c0b3bdb4a1f132a6752ede8395a307b711da228 — David du Colombier 34 years ago 7f6fc7e
Plan 9 from Bell Labs 1992-01-14
M gnot/devduart.c => gnot/devduart.c +1 -1
@@ 700,7 700,7 @@ duartopen(Chan *c, int omode)
	}

	if(dp && dp->nostream)
		errors("in use");
		error(Einuse);

	if((c->qid.path & CHDIR) == 0)
		streamopen(c, &duartinfo);

M pc/devfloppy.c => pc/devfloppy.c +9 -9
@@ 314,9 314,9 @@ static void
islegal(Chan *c, long n, Drive *dp)
{
	if(c->offset % dp->t->bytes)
		errors("bad offset");
		error(Ebadarg);
	if(n % dp->t->bytes)
		errors("bad len");
		error(Ebadarg);
}

/*


@@ 341,7 341,7 @@ changed(Chan *c, Drive *dp)
	old = c->qid.vers;
	c->qid.vers = dp->vers;
	if(old && old!=dp->vers)
		errors("disk changed");
		error(Eio);
}

long


@@ 393,7 393,7 @@ floppyread(Chan *c, void *a, long n)
				if(i != nn){
					if(i == 0)
						break;
					errors("floppy read err");
					error(Eio);
				}
				dp->ccyl = cyl;
				dp->chead = head;


@@ 796,7 796,7 @@ floppyxfer(Drive *dp, int cmd, void *a, long off, long n)
	 */
	dp->len = n;
	if(floppyseek(dp, off) < 0)
		errors("seeking floppy");
		error(Eio);

/*print("tcyl %d, thead %d, tsec %d, addr %lux, n %d\n",
	dp->tcyl, dp->thead, dp->tsec, a, dp->len);/**/


@@ 823,7 823,7 @@ floppyxfer(Drive *dp, int cmd, void *a, long off, long n)
	if(floppycmd() < 0){
		spllo();
		print("xfer cmd failed\n");
		errors("floppy command failed");
		error(Eio);
	}

	/*


@@ 838,14 838,14 @@ floppyxfer(Drive *dp, int cmd, void *a, long off, long n)
	if(fl.nstat < 7){
		print("xfer result failed %lux\n", inb(Pmsr));
		fl.confused = 1;
		errors("floppy result failed");
		error(Eio);
	}
	if((fl.stat[0] & Codemask)!=0 || fl.stat[1] || fl.stat[2]){
		print("xfer failed %lux %lux %lux\n", fl.stat[0],
			fl.stat[1], fl.stat[2]);
		print("offset %lud len %d\n", off, dp->len);
		dp->confused = 1;
		errors("floppy drive lost");
		error(Eio);
	}

	/*


@@ 856,7 856,7 @@ floppyxfer(Drive *dp, int cmd, void *a, long off, long n)
	offset = offset * c2b[fl.stat[6]];
	if(offset != off+dp->len){
		dp->confused = 1;
		errors("floppy drive lost");
		error(Eio);
	}

	dp->lasttouched = m->ticks;

M pc/devhard.c => pc/devhard.c +6 -6
@@ 239,7 239,7 @@ hardattach(char *spec)
				break;
			default:
				print("unknown hard disk type\n");
				errors("unknown hard disk type");
				error(Egreg);
			}
			dp->bytes = 512;
			dp->cap = dp->bytes * dp->cyl * dp->heads * dp->sectors;


@@ 349,7 349,7 @@ hardwrite(Chan *c, void *a, long n)
	Controller *cp;

	if(c->qid.path == CHDIR)
		errors("can't write directory");
		error(Eisdir);

	dp = &hard[DRIVE(c->qid.path)];
	pp = &dp->p[PART(c->qid.path)];


@@ 432,7 432,7 @@ cmdreadywait(Controller *cp)
	while((inb(cp->pbase+Pstatus) & (Sready|Sbusy)) != Sready)
		if(TK2MS(m->ticks - start) > 1){
print("cmdreadywait failed\n");
			errors("disk not responding");
			error(Eio);
		}
}



@@ 450,7 450,7 @@ hardxfer(Drive *dp, Partition *pp, int cmd, long start, long len)
	int loop;

	if(dp->online == 0)
		errors("disk offline");
		error(Eio);

	/*
	 *  cut transfer size down to disk buffer size


@@ 510,7 510,7 @@ print("\tnsecs %d, sofar %d\n", cp->nsecs, cp->sofar);/**/
print("hd%d err: status %lux, err %lux\n", dp-hard, cp->status, cp->error);
print("\ttcyl %d, tsec %d, thead %d\n", cp->tcyl, cp->tsec, cp->thead);
print("\tnsecs %d, sofar %d\n", cp->nsecs, cp->sofar);
		errors("disk I/O error");
		error(Eio);
	}

	return cp->nsecs*dp->bytes;


@@ 569,7 569,7 @@ hardident(Drive *dp)
	sleep(&cp->r, cmddone, cp);
	if(cp->status & Serr){
		print("bad disk ident status\n");
		errors("disk I/O error");
		error(Eio);
	}
	memmove(&dp->id, cp->buf, dp->bytes);


M pc/devlpt.c => pc/devlpt.c +1 -1
@@ 88,7 88,7 @@ lptattach(char *spec)
	int i  = (spec && *spec) ? strtol(spec, 0, 0) : 1;

	if(i < 1 || i > NDEV)
		errors("spec out of range");
		error(Ebadarg);
	c = devattach('L', spec);
	c->dev = i-1;
	return c;

M pc/devuart.c => pc/devuart.c +1 -1
@@ 655,7 655,7 @@ uartopen(Chan *c, int omode)
	}

	if(up && up->nostream)
		errors("in use");
		error(Einuse);

	if((c->qid.path & CHDIR) == 0)
		streamopen(c, &uartinfo);

M port/devarp.c => port/devarp.c +1 -1
@@ 244,7 244,7 @@ arpwrite(Chan *c, char *a, long n, ulong offset)
				error(Ebadarg);

			if(arpdelete(field[1]) < 0)
				error(Ebadaddr);
				error(Enetaddr);
		}
	case arpdataqid:
		if(n != sizeof(Arpentry))

M port/devcons.c => port/devcons.c +1 -1
@@ 818,7 818,7 @@ conswrite(Chan *c, void *va, long n, ulong offset)
			error(Ebadarg);
		decrypt(evekey, a, n);
		if(memcmp(u->p->pgrp->crypt->chal, a, 8) != 0)
			error(Eauth);
			error(Eperm);
		strncpy(u->p->user, a+8, NAMELEN);
		u->p->user[NAMELEN-1] = '\0';
		memmove(u->p->pgrp->crypt->key, a+NAMELEN+DESKEYLEN, DESKEYLEN);

M port/deviproute.c => port/deviproute.c +2 -2
@@ 97,7 97,7 @@ ipaddroute(ulong dst, ulong mask, ulong gate)
	 *  filter out impossible requests
	 */
	if((dst&mask) != dst)
		error(Ebadaddr);
		error(Enetaddr);

	/*
	 *  see if we already have a route for


@@ 118,7 118,7 @@ ipaddroute(ulong dst, ulong mask, ulong gate)
	}
	if(free == 0){
		unlock(&iprtab);
		error(Enoroute);
		exhausted("routes");
	}

	/*

M port/devmnt.c => port/devmnt.c +1 -1
@@ 143,7 143,7 @@ mntattach(char *muxattach)
	lock(&mntalloc);
	if(mntalloc.mntfree == 0) {
		unlock(&mntalloc);
		error(Enomntdev);
		exhausted("mount devices");
	}
	m = mntalloc.mntfree;
	mntalloc.mntfree = m->list;	

M port/devmux.c => port/devmux.c +2 -2
@@ 275,7 275,7 @@ muxcreate(Chan *c, char *name, int omode, ulong perm)
	}

	if(m == e)
		error(Enomux);
		exhausted("multiplexers");

	strncpy(m->name, name, NAMELEN);
	strncpy(m->user, u->p->user, NAMELEN);


@@ 610,7 610,7 @@ muxreadq(Mux *m, Dtq *q, char *va, ulong n)
	while(!havedata(q)) {
		sleep(&q->r, havedata, q);
		if(m->headopen == 0)
			errors(Emuxshutdown);
			error(Emuxshutdown);
	}

	nread = 0;

M port/devpipe.c => port/devpipe.c +1 -1
@@ 79,7 79,7 @@ pipeattach(char *spec)
	if(pipealloc.free == 0){
		unlock(&pipealloc);
		close(c);
		error(Enopipe);
		exhausted("pipes");
	}
	p = pipealloc.free;
	pipealloc.free = p->next;

M port/devproc.c => port/devproc.c +11 -11
@@ 174,7 174,7 @@ procopen(Chan *c, int omode)
		c->pgrpid.vers = pg->pgrpid;
		break;
	default:
		pprint("unknown qid in devopen\n");
		pprint("procopen %lux\n", c->qid);
		error(Egreg);
	}



@@ 349,7 349,7 @@ procread(Chan *c, void *va, long n, ulong offset)
		if(offset+n > j)
			n = j-offset;
		if(n == 0 && offset == 0)
			errors("no segments");
			exhausted("segments");
		memmove(a, &statbuf[offset], n);
		return n;
	}


@@ 392,7 392,7 @@ procwrite(Chan *c, void *va, long n, ulong offset)
	switch(QID(c->qid)){
	case Qmem:
		if(p->state != Stopped)
			errors("not stopped");
			error(Ebadctl);

		if(offset >= USERADDR && offset <= USERADDR+BY2PG-1) {
			pg = p->upage;


@@ 411,7 411,7 @@ procwrite(Chan *c, void *va, long n, ulong offset)
			ur = pxu->dbgreg;
			if(offset < (ulong)ur || hi > (ulong)ur+sizeof(Ureg)) {
				kunmap(k);
				errors("bad u-area address");
				error(Ebadarg);
			}
			ur = (Ureg*)(b+((ulong)ur-USERADDR));
			setregisters(ur, b+(offset-USERADDR), a, n);


@@ 427,7 427,7 @@ procwrite(Chan *c, void *va, long n, ulong offset)

	case Qnote:
		if(p->kp)
			errors("can't note kproc");
			error(Eperm);
		k = kmap(p->upage);
		up = (User*)VA(k);
		if(up->p != p){


@@ 441,7 441,7 @@ procwrite(Chan *c, void *va, long n, ulong offset)
		memmove(buf, va, n);
		buf[n] = 0;
		if(!postnote(p, 0, buf, NUser))
			error(Enonote);
			exhausted("notes");
		break;

	default:


@@ 462,7 462,7 @@ proctext(Chan *c, Proc *p)

	s = p->seg[TSEG];
	if(s == 0)
		errors("no text segment");
		error(Enonexist);
	if(p->state==Dead)
		error(Eprocdied);



@@ 524,7 524,7 @@ procstopwait(Proc *p, int ctl)
	int pid;

	if(p->pdbg)
		errors("debugged already");
		error(Einuse);
	if(procstopped(p))
		return;



@@ 573,14 573,14 @@ procctlreq(Proc *p, char *va, int n)
		procstopwait(p, 0);
	else if(strncmp(buf, "startstop", 9) == 0) {
		if(p->state != Stopped)
			errors("not stopped");
			error(Ebadctl);
		p->procctl = Proc_traceme;
		ready(p);
		procstopwait(p, Proc_traceme);
	}
	else if(strncmp(buf, "start", 5) == 0) {
		if(p->state != Stopped)
			errors("not stopped");
			error(Ebadctl);
		ready(p);
	}
	else


@@ 607,7 607,7 @@ procctlmemio(Proc *p, ulong offset, int n, void *va, int read)
	for(;;) {
		s = seg(p, offset, 1);
		if(s == 0)
			errors("not in address space");
			error(Ebadarg);

		if(offset+n >= s->top)
			n = s->top-offset;

M port/devscc.c => port/devscc.c +3 -3
@@ 149,7 149,7 @@ sccsetbaud(SCC *sp, int rate)
	int brconst;

	if(rate == 0)
		errors("bad baud rate");
		error(Ebadctl);

	brconst = (sp->freq+16*rate-1)/(2*16*rate) - 2;



@@ 631,7 631,7 @@ sccopen(Chan *c, int omode)
	if(c->qid.path != CHDIR){
		sp = scc[STREAMID(c->qid.path)];
		if(sp->nostream)
			errors("in use");
			error(Einuse);
		streamopen(c, &sccinfo);
	}
	return devopen(c, omode, sccdir, 2*nscc, devgen);


@@ 667,7 667,7 @@ sccread(Chan *c, void *buf, long n, ulong offset)
		sprint(b, "%d", STREAMID(c->qid.path));
		return stringread(buf, n, b, offset);
	}
	errors("bad qid");
	error(Egreg);
}

long

M port/devsrv.c => port/devsrv.c +1 -1
@@ 124,7 124,7 @@ srvcreate(Chan *c, char *name, int omode, ulong perm)
			error(Einuse);
	}
	if(j == -1)
		error(Enosrv);
		exhausted("server slots");
	sp = &srv[j];
	sp->chan = c;
	unlock(&srvlk);

M port/devwren.c => port/devwren.c +4 -4
@@ 55,12 55,12 @@ wrendev(char *p)
	if(p == 0 || p[0] == '\0')
		return 0;
	if(p[0] < '0' || p[0] > '7')
		errors("bad scsi drive specifier");
		error(Ebadarg);
	drive = p[0] - '0';
	unit = 0;
	if(p[1]){
		if(p[1] != '.' || p[2] < '0' || p[2] > '7' || p[3] != '\0')
			errors("bad scsi unit specifier");
			error(Ebadarg);
		unit = p[2] - '0';
	}
	return (drive << 3) | unit;


@@ 197,8 197,8 @@ wrenio(Chan *c, int write, char *a, ulong len, ulong offset)
	ulong block, n, max, x;

	d = &wren[DRIVE(c->qid.path)];
	if(d->npart == 0)
		errors("drive repartitioned");
	if(d->npart == 0)			/* drive repartitioned */
		error(Eio);
	p = &d->p[PART(c->qid.path)];

	block = offset / d->bytes + p->start;

M port/error.h => port/error.h +9 -33
@@ 4,7 4,6 @@ extern char Eunmount[];		/* not mounted */
extern char Eunion[];		/* not in union */
extern char Emountrpc[];	/* mount rpc error */
extern char Eshutdown[];	/* mounted device shut down */
extern char Enomntdev[];	/* no free mount devices */
extern char Enocreate[];	/* mounted directory forbids creation */
extern char Enonexist[];	/* file does not exist */
extern char Ebadsharp[];	/* unknown device in # filename */


@@ 25,13 24,11 @@ extern char Enobitmap[];	/* out of bitmap descriptors */
extern char Enobitstore[];	/* out of bitmap storage */
extern char Ebadfont[];		/* unallocated font */
extern char Enofont[];		/* no free font descriptors */
extern char Eauth[];		/* authentication failure */
extern char Ebadaddr[];		/* bad network address */
extern char Enetaddr[];		/* bad network address */
extern char Emsgsize[];		/* message is too big for protocol */
extern char Enetbusy[];		/* network device is busy or allocated */
extern char Enoproto[];		/* network protocol not supported */
extern char Enoport[];		/* network port not available */
extern char Enoroute[];		/* no free routes */
extern char Enoifc[];		/* bad interface or no free interface slots */
extern char Enolisten[];	/* not announced */
extern char Ehungup[];		/* write to hungup stream */


@@ 40,38 37,17 @@ extern char Enodev[];		/* no free devices */
extern char Enoenv[];		/* no free environment resources */
extern char Emuxshutdown[];	/* mux server shut down */
extern char Emuxbusy[];		/* all mux channels busy */
extern char Enomux[];		/* no free multiplexers */
extern char Emuxmsg[];		/* bad mux message format or mismatch */
extern char Enopipe[];		/* no free pipes */

extern char Enofd[];		/* no free file descriptors */
extern char Ebadfd[];		/* fd out of range or not open */
extern char Ebadexec[];		/* a.out header invalid */
extern char Eioload[];		/* i/o error in demand load */
extern char Enochild[];		/* no living children */
extern char Enoseg[];		/* no free segments */
extern char Ebadmount[];	/* inconsistent mount */
extern char Ebaddirread[];	/* directory read not quantized */
extern char Esegaddr[];		/* illegal segment addresses or size */
extern char Eprocdied[];	/* process exited */
extern char Enosrv[];		/* no free server slots */
extern char Enoqueue[];		/* no free stream queues */
extern char Ebadld[];		/* illegal line discipline */
extern char Enostream[];	/* no free stream heads */
extern char Ebadnet[];		/* illegal network address */
extern char Enonote[];		/* note overflow */
extern char Eintr[];		/* interrupted */
extern char Edestbusy[];	/* datakit destination busy */
extern char Edestotl[];		/* datakit destination out to lunch */
extern char Enetotl[];		/* datakit controller out to lunch */
extern char Erejected[];	/* datakit destination rejected call */
extern char Ebadcnt[];		/* read count greater than requested */
extern char Enochild[];		/* no living children */
extern char Eioload[];		/* i/o error in demand load */
extern char Enovmem[];		/* virtual memory allocation failed */
extern char Enoasync[];		/* out of async stream modules */
extern char Enetunreach[];	/* network unreachable */
extern char Ebadld[];		/* illegal line discipline */
extern char Ebadfd[];		/* fd out of range or not open */
extern char Eisstream[];	/* seek on a stream */
extern char Ebadexec[];		/* a.out header invalid */
extern char Etimedout[];	/* connection timed out */
extern char Econrefused[];	/* connection refused */
extern char Eprotonosup[];	/* operation not supported by network protocol */
extern char Eisstream[];	/* seek on a stream */
extern char Enofilsys[];	/* out of filsys resources */
extern char Enetunreach[];	/* network unreachable */
extern char Eintr[];		/* interrupted */
extern char Egreg[];		/* it's a thermal problem */

M port/fault.c => port/fault.c +5 -5
@@ 8,7 8,7 @@

#define DPRINT

void	faultexit(char*);
void	faulterror(char*);

int
fault(ulong addr, int read)


@@ 190,7 190,7 @@ pio(Segment *s, ulong addr, ulong soff, Page **p)
			qunlock(&c->rdl);
			kunmap(k);
			putpage(new);
			faultexit("sys: demand load I/O error");
			faulterror("sys: demand load I/O error");
		}

		ask = s->flen-soff;


@@ 224,7 224,7 @@ pio(Segment *s, ulong addr, ulong soff, Page **p)
			putpage(new);
			qlock(&s->lk);
			qunlock(&s->lk);
			faultexit("sys: page in I/O error");
			faulterror("sys: page in I/O error");
		}

		n = (*devtab[c->type].read)(c, kaddr, BY2PG, daddr);


@@ 248,11 248,11 @@ pio(Segment *s, ulong addr, ulong soff, Page **p)
}

void
faultexit(char *s)
faulterror(char *s)
{
	if(u->nerrlab) {
		postnote(u->p, 1, s, NDebug);
		errors(s);
		error(s);
	}
	pexit(s, 0);
}

M port/portfns.h => port/portfns.h +2 -2
@@ 59,9 59,9 @@ void	envpgclose(Env*);
void	envpgcopy(Env*, Env*);
int	eqchan(Chan*, Chan*, long);
int	eqqid(Qid, Qid);
void	error(char []);
void	errors(char*);
void	error(char*);
long	execregs(ulong, ulong, ulong);
void	exhausted(char*);
void	exit(void);
Block*	expandb(Block *, int);
int	fault(ulong, int);

M port/proc.c => port/proc.c +8 -6
@@ 390,7 390,7 @@ postnote(Proc *p, int dolock, char *n, int flag)
	if(p->upage == 0){
		if(dolock)
			qunlock(&p->debug);
		errors("noted process disappeared");
		error(Eprocdied);
	}

	SET(k);


@@ 771,16 771,18 @@ error(char err[])
}

void
errors(char *err)
nexterror(void)
{
	strncpy(u->error, err, ERRLEN);
	nexterror();
	gotolabel(&u->errlab[--u->nerrlab]);
}

void
nexterror(void)
exhausted(char *resource)
{
	gotolabel(&u->errlab[--u->nerrlab]);
	char buf[ERRLEN];

	sprint(buf, "no free %s", resource);
	error(buf);
}

Waitq *

M port/segment.c => port/segment.c +10 -10
@@ 57,7 57,7 @@ newseg(int type, ulong base, ulong size)
	Segment *s;

	if(size > (SEGMAPSIZE*PTEPERTAB))
		errors("segment too large");
		error(Enovmem);

	for(;;) {
		lock(&segalloc);


@@ 335,7 335,7 @@ ibrk(ulong addr, int seg)

	s = u->p->seg[seg];
	if(s == 0)
		errors("no segment");
		error(Ebadarg);

	if(addr == 0)
		return s->base;


@@ 346,7 346,7 @@ ibrk(ulong addr, int seg)
		/* We may start with the bss overlapping the data */
		if(seg != BSEG || u->p->seg[DSEG] == 0 || addr < u->p->seg[DSEG]->base) {
			qunlock(&s->lk);
			errors("addr below segment");
			error(Enovmem);
		}
		addr = s->base;
	}


@@ 371,7 371,7 @@ ibrk(ulong addr, int seg)
		if(newtop >= ns->base && newtop < ns->top) {
			qunlock(&s->lk);
			pprint("segments overlap\n");
			error(Esegaddr);
			error(Enovmem);
		}
	}



@@ 424,7 424,7 @@ segattach(Proc *p, ulong attr, char *name, ulong va, ulong len)

	USED(p);
	if(va&KZERO)					/* BUG: Only ok for now */
		errors("bad virtual address");
		error(Ebadarg);

	validaddr((ulong)name, 1, 0);
	vmemchr(name, 0, ~0);


@@ 434,7 434,7 @@ segattach(Proc *p, ulong attr, char *name, ulong va, ulong len)
			break;

	if(sno == NSEG)
		errors("no per process segments");
		error(Enovmem);

	va = va&~(BY2PG-1);
	len = PGROUND(len);


@@ 445,17 445,17 @@ segattach(Proc *p, ulong attr, char *name, ulong va, ulong len)
			continue;	
		if((newtop > ns->base && newtop <= ns->top) ||
		   (va >= ns->base && va < ns->top))
			errors("segments overlap");
			error(Enovmem);
	}

	for(ps = physseg; ps->name; ps++)
		if(strcmp(name, ps->name) == 0)
			goto found;

	errors("bad segment name");
	error(Ebadarg);
found:
	if(len > ps->size)
		errors("segment too long");
		error(Enovmem);

	attr &= ~SG_TYPE;			/* Turn off what we are not allowed */
	attr |= ps->attr;			/* Copy in defaults */


@@ 480,7 480,7 @@ syssegflush(ulong *arg)

	s = seg(u->p, arg[0], 1);
	if(s == 0)
		errors("bad segment address");
		error(Ebadarg);

	s->flushme = 1;


M port/stasync.c => port/stasync.c +1 -1
@@ 113,7 113,7 @@ asyncopen(Queue *q, Stream *s)
		qunlock(ap);
	}
	if(ap == &async[conf.nasync])
		error(Enoasync);
		exhausted("async stream modules");
	q->ptr = q->other->ptr = ap;

	ap->inuse = 1;

M port/stnoether.c => port/stnoether.c +2 -2
@@ 265,7 265,7 @@ etherparse(uchar *to, char *from)
	if(strchr(from, '.')) {
		ip = ipparse(from);
		if(ip == 0)
			error(Ebadnet);
			error(Enetaddr);

		hnputl(nip, ip);			
		if(arp_lookup(nip, to))


@@ 274,7 274,7 @@ etherparse(uchar *to, char *from)
#endif

	if(strlen(from) != 12)
		error(Ebadnet);
		error(Enetaddr);

	for(i = 0; i < 6; i++){
		fdig = (*from++)&0x7f;

M port/stream.c => port/stream.c +5 -5
@@ 296,7 296,7 @@ allocq(Qinfo *qi)

	if(q == &qlist[conf.nqueue]){
		print("no more queues\n");
		error(Enoqueue);
		exhausted("queues");
	}

	q->flag = QINUSE;


@@ 820,7 820,7 @@ streamnew(ushort type, ushort dev, ushort id, Qinfo *qi, int noopen)
	}
	if(s == &slist[conf.nstream]){
		print("no more streams\n");
		error(Enostream);
		exhausted("streams");
	}
	if(waserror()){
		qunlock(s);


@@ 1159,7 1159,7 @@ streamread(Chan *c, void *vbuf, long n)
		if(bp == 0){
			if(q->flag & QHUNGUP){
				if(s->err)
					errors((char*)s->err->rptr);
					error((char*)s->err->rptr);
				else if(s->hread++<3)
					break;
				else


@@ 1217,7 1217,7 @@ qlook(Stream *s, char *name)
		if(q == s->devq->other)
			break;
	}
	errors("not found");
	error(Ebadarg);
}

/*


@@ 1322,7 1322,7 @@ streamwrite(Chan *c, void *a, long n, int docopy)
	q = s->procq;
	if(q->other->flag & QHUNGUP){
		if(s->err)
			errors((char*)(s->err->rptr));
			error((char*)(s->err->rptr));
		else
			error(Ehungup);
	}

M port/sturp.c => port/sturp.c +1 -1
@@ 167,7 167,7 @@ urpopen(Queue *q, Stream *s)
	if(up == &urp[conf.nurp]){
		q->ptr = 0;
		WR(q)->ptr = 0;
		errors("out of urp structures");
		exhausted("urp structures");
	}

	q->ptr = q->other->ptr = up;

M port/swap.c => port/swap.c +1 -1
@@ 330,7 330,7 @@ setswapchan(Chan *c)
{
	if(swapimage.c) {
		if(swapalloc.free != conf.nswap)
			errors("swap channel busy");
			error(Einuse);
		close(swapimage.c);
	}
	incref(c);

M port/sysfile.c => port/sysfile.c +5 -5
@@ 26,7 26,7 @@ newfd(Chan *c)
			return i;
		}
	unlock(f);
	error(Enofd);
	exhausted("file descriptors");
}

Chan*


@@ 38,7 38,7 @@ fdtochan(int fd, int mode, int chkmnt)
	if(fd<0 || NFD<=fd || (c = u->p->fgrp->fd[fd])==0)
		error(Ebadfd);
	if(chkmnt && (c->flag&CMSG))
		errors("channel is mounted");
		error(Ebadusefd);
	if(mode<0 || c->mode==ORDWR)
		return c;
	if((mode&OTRUNC) && c->mode==OREAD)


@@ 262,7 262,7 @@ sysread(ulong *arg)
	if(c->qid.path & CHDIR){
		n -= n%DIRLEN;
		if(c->offset%DIRLEN || n==0)
			error(Ebaddirread);
			error(Etoosmall);
	}
	if((c->qid.path&CHDIR) && c->mnt)
		n = unionread(c, (void*)arg[1], n);


@@ 426,9 426,9 @@ bindmount(ulong *arg, int ismount)
		nexterror();
	}
	if((c0->qid.path^c1->qid.path) & CHDIR)
		error(Ebadmount);
		error(Emount);
	if(flag && !(c0->qid.path&CHDIR))
		error(Ebadmount);
		error(Emount);
	ret = mount(c0, c1, flag);
	poperror();
	close(c1);

M port/sysproc.c => port/sysproc.c +7 -7
@@ 259,7 259,7 @@ sysexec(ulong *arg)
	 * Build the stack segment, putting it in kernel virtual for the moment
	 */
	if(spage > TSTKSIZ)
		errors("too many arguments");
		error(Enovmem);

	 
	p->seg[ESEG] = newseg(SG_STACK, TSTKTOP-USTKSIZE, USTKSIZE/BY2PG);


@@ 528,14 528,14 @@ syssegbrk(ulong *arg)
				switch(s->type&SG_TYPE) {
				case SG_TEXT:
				case SG_DATA:
					errors("bad segment type");
					error(Ebadarg);
				default:
					return ibrk(arg[1], i);
				}
			}
		}

	errors("not in address space");
	error(Ebadarg);
}

long


@@ 560,12 560,12 @@ syssegdetach(ulong *arg)
			qunlock(&s->lk);
		}

	errors("not in address space");
	error(Ebadarg);

found:
	if((ulong)arg >= s->base && (ulong)arg < s->top) {
		qunlock(&s->lk);
		errors("illegal address");
		error(Ebadarg);
	}
	u->p->seg[i] = 0;
	qunlock(&s->lk);


@@ 585,13 585,13 @@ syssegfree(ulong *arg)
	from = PGROUND(arg[0]);
	s = seg(u->p, from, 1);
	if(s == 0)
		errors("not in address space");
		error(Ebadarg);

	pages = (arg[1]+BY2PG-1)/BY2PG;

	if(from+pages*BY2PG > s->top) {
		qunlock(&s->lk);
		errors("segment too short");
		error(Ebadarg);
	}

	mfreeseg(s, from, pages);

M power/devduart.c => power/devduart.c +5 -5
@@ 232,7 232,7 @@ duartbaud(Duartport *dp, int b)
		x = BD300;
		break;
	default:
		errors("bad baud rate");
		error(Ebadarg);
	}
	if(x & 0x0100)
		dp->duart->ipc_acr = duartacr |= 0x80;


@@ 770,7 770,7 @@ duartopen(Chan *c, int omode)
	}

	if(dp && dp->nostream)
		errors("in use");
		error(Einuse);

	if((c->qid.path & CHDIR) == 0)
		streamopen(c, &duartinfo);


@@ 814,7 814,7 @@ duartread(Chan *c, void *buf, long n, ulong offset)
		return 1;
	}

	errors("no such duart type");
	error(Egreg);
}

long


@@ 827,14 827,14 @@ void
duartremove(Chan *c)
{
	USED(c);
	errors("can't remove a duart");
	error(Eperm);
}

void
duartwstat(Chan *c, char *dp)
{
	USED(c);
	errors("can't write a duart");
	error(Eperm);
}

int