~kris/9p

9hist

14ae1c01ba0e6a59ac825000d4d4c6bfdee8493e — David du Colombier 25 years ago 6421d82
Plan 9 from Bell Labs 2001-03-20
1 files changed, 17 insertions(+), 9 deletions(-)

M port/devproc.c
M port/devproc.c => port/devproc.c +17 -9
@@ 285,6 285,21 @@ procwstat(Chan *c, char *db)
	qunlock(&p->debug);
}

static long
procoffset(long offset, char *va, int *np)
{
	if(offset > 0) {
		offset -= *np;
		if(offset < 0) {
			memmove(va, va+*np+offset, -offset);
			*np = -offset;
		}
		else
			*np = 0;
	}
	return offset;
}

static int
procfds(Proc *p, char *va, int count, long offset)
{


@@ 307,6 322,7 @@ procfds(Proc *p, char *va, int count, long offset)

	n = readstr(0, va, count, p->dot->name->s);
	n += snprint(va+n, count-n, "\n");
	offset = procoffset(offset, va, &n);
	for(i = 0; i <= f->maxfd; i++) {
		c = f->fd[i];
		if(c == nil)


@@ 319,15 335,7 @@ procfds(Proc *p, char *va, int count, long offset)
			c->offset);
		n += readstr(0, va+n, count-n, c->name->s);
		n += snprint(va+n, count-n, "\n");
		if(offset > 0) {
			offset -= n;
			if(offset < 0) {
				memmove(va, va+n+offset, -offset);
				n = -offset;
			}
			else
				n = 0;
		}
		offset = procoffset(offset, va, &n);
	}
	unlock(f);
	qunlock(&p->debug);