示例#1
0
文件: devroot.c 项目: 0intro/vx32
static int
rootgen(Chan *c, char *name, Dirtab *dt, int i, int s, Dir *dp)
{
	int t;
	Dirtab *d;
	Dirlist *l;

	switch((int)c->qid.path){
	case Qdir:
		if(s == DEVDOTDOT){
			devdir(c, (Qid){Qdir, 0, QTDIR}, "#/", 0, eve, 0555, dp);
			return 1;
		}
		return devgen(c, name, rootlist.dir, rootlist.ndir, s, dp);
	case Qboot:
		if(s == DEVDOTDOT){
			devdir(c, (Qid){Qdir, 0, QTDIR}, "#/", 0, eve, 0555, dp);
			return 1;
		}
		return devgen(c, name, bootlist.dir, bootlist.ndir, s, dp);
	default:
		if(s == DEVDOTDOT){
			if((int)c->qid.path < Qboot)
				devdir(c, (Qid){Qdir, 0, QTDIR}, "#/", 0, eve, 0555, dp);
			else
				devdir(c, (Qid){Qboot, 0, QTDIR}, "#/", 0, eve, 0555, dp);
			return 1;
		}
		if(s != 0)
			return -1;
		if((int)c->qid.path < Qboot){
			t = c->qid.path-1;
			l = &rootlist;
		}else{
			t = c->qid.path - Qboot - 1;
			l = &bootlist;
		}
		if(t >= l->ndir)
			return -1;
if(t < 0){
print("rootgen %llud %d %d\n", c->qid.path, s, t);
panic("whoops");
}
		d = &l->dir[t];
		devdir(c, d->qid, d->name, d->length, eve, d->perm, dp);
		return 1;
	}
}
示例#2
0
static int
vcongen(Chan *c, char *d, Dirtab* dir, int i, int s, Dir *dp)
{
	Proc *up = externup();
	Qid q;
	int t = TYPE(c->qid);
	int vdidx = DEV(c->qid);
	if(vdidx >= nvcon)
		error(Ebadarg);
	switch(t){
	case Qtopdir:
		if(s == DEVDOTDOT){
			q = (Qid){QID(0, Qtopdir), 0, QTDIR};
			snprint(up->genbuf, sizeof up->genbuf, "#%C", vcondevtab.dc);
			devdir(c, q, up->genbuf, 0, eve, DMDIR|0555, dp);
			return 1;
		}
		return devgen(c, nil, topdir, nelem(topdir), s, dp);
	case Qvirtcon:
		if(s == DEVDOTDOT){
			q = (Qid){QID(0, Qtopdir), 0, QTDIR};
			snprint(up->genbuf, sizeof up->genbuf, "#%C", vcondevtab.dc);
			devdir(c, q, up->genbuf, 0, eve, DMDIR|0555, dp);
			return 1;
		}
		if(s >= nvcon)
			return -1;
		snprint(up->genbuf, sizeof up->genbuf, vcons[s]->devname);
		q = (Qid) {QID(s, Qvcpipe), 0, 0};
		devdir(c, q, up->genbuf, 0, eve, 0666, dp);
		return 1;
	}
	return -1;
}
示例#3
0
static int
corebootdevgen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp)
{
	int rc;

	rc = devgen(c, name, tab, ntab, i, dp);
	return rc;
}
示例#4
0
文件: devpmc.c 项目: qioixiy/harvey
int
pmcgen(Chan *c, char *name, Dirtab* dir, int j, int s, Dir *dp)
{
	int t, i, n;
	Dirtab *l, *d;

	if(s == DEVDOTDOT){
		devdir(c, (Qid){Qdir, 0, QTDIR}, "#ε", 0, eve, 0555, dp);
		c->aux = nil;
		return 1;
	}
	/* first, for directories, generate children */
	switch((int)PMCTYPE(c->qid.path)){
	case Qdir:
		return devgen(c, name, toptab, ntoptab, s, dp);
	case Qctr:
		return devgen(c, name, pmctab, npmctab, s, dp);
	case Qcore:
		c->aux = (void *)PMCID(c->qid.path);		/* core no */
		return devgen(c, name, pmctab, npmctab, s, dp);
	default:
		if(s != 0)
			return -1;

		t = PMCTYPE(c->qid.path);
		if(t < Qctr){
			i = t;
			l = toptab;
			n = ntoptab;
		}else{
			i = PMCID(t);
			if (t == Qctl)
				i += (npmctab - 1)/2;
			l = pmctab;
			n = npmctab;
		}
		if(i >=n)
			return -1;

		d = &l[i];

		devdir(c, d->qid, d->name, d->length, eve, d->perm, dp);
		return 1;
	}
}
示例#5
0
文件: devmouse.c 项目: 0intro/vx32
static int
mousedevgen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp)
{
	int rc;

	rc = devgen(c, name, tab, ntab, i, dp);
	if(rc != -1)
		dp->atime = mousetime;
	return rc;
}