本文整理汇总了C++中devdir函数的典型用法代码示例。如果您正苦于以下问题:C++ devdir函数的具体用法?C++ devdir怎么用?C++ devdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了devdir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dupgen
static int
dupgen(Chan *c, char *, Dirtab*, int, int s, Dir *dp)
{
Fgrp *fgrp = up->env->fgrp;
Chan *f;
static int perm[] = { 0400, 0200, 0600, 0 };
int p;
Qid q;
if(s == DEVDOTDOT){
devdir(c, c->qid, ".", 0, eve, DMDIR|0555, dp);
return 1;
}
if(s == 0)
return 0;
s--;
if(s/2 > fgrp->maxfd)
return -1;
if((f=fgrp->fd[s/2]) == nil)
return 0;
if(s & 1){
p = 0400;
sprint(up->genbuf, "%dctl", s/2);
}else{
p = perm[f->mode&3];
sprint(up->genbuf, "%d", s/2);
}
mkqid(&q, s+1, 0, QTFILE);
devdir(c, q, up->genbuf, 0, eve, p, dp);
return 1;
}
示例2: srvgen
static int
srvgen(Chan *c, char *name, Dirtab *tab, int ntab, int s, Dir *dp)
{
SrvFile *f;
USED(name);
USED(tab);
USED(ntab);
if(s == DEVDOTDOT){
devdir(c, c->qid, "#s", 0, eve, 0555, dp);
return 1;
}
f = c->aux;
if((c->qid.type & QTDIR) == 0){
if(s > 0)
return -1;
devdir(c, f->qid, f->name, f->length, f->user, f->perm, dp);
return 1;
}
for(f = f->entry; f != nil; f = f->entry){
if(s-- == 0)
break;
}
if(f == nil)
return -1;
devdir(c, f->qid, f->name, f->length, f->user, f->perm, dp);
return 1;
}
示例3: pipegen
static int
pipegen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp)
{
int id, len;
Qid qid;
Pipe *p;
USED(name);
if(i == DEVDOTDOT){
devdir(c, c->qid, "#|", 0, eve, 0555, dp);
return 1;
}
i++; /* skip . */
if(tab==0 || i>=ntab)
return -1;
tab += i;
p = c->aux;
switch(NETTYPE(tab->qid.path)){
case Qdata0:
len = qlen(p->q[0]);
break;
case Qdata1:
len = qlen(p->q[1]);
break;
default:
len = tab->length;
break;
}
id = NETID(c->qid.path);
qid.path = NETQID(id, tab->qid.path);
qid.vers = 0;
qid.type = QTFILE;
devdir(c, qid, tab->name, len, eve, tab->perm, dp);
return 1;
}
示例4: envgen
static int
envgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
{
Egrp *eg;
Evalue *e;
if(s == DEVDOTDOT){
devdir(c, c->qid, "#e", 0, eve, DMDIR|0775, dp);
return 1;
}
eg = envgrp(c);
rlock(eg);
if(name != nil)
e = envlookup(eg, name, -1);
else if(s < eg->nent)
e = &eg->ent[s];
else
e = nil;
if(e == nil || name != nil && (strlen(e->name) >= sizeof(up->genbuf))) {
runlock(eg);
return -1;
}
/* make sure name string continues to exist after we release lock */
kstrcpy(up->genbuf, e->name, sizeof up->genbuf);
devdir(c, e->qid, up->genbuf, e->len, eve, 0666, dp);
runlock(eg);
return 1;
}
示例5: pipestat
static int pipestat(struct chan *c, uint8_t * db, int n)
{
Pipe *p;
struct dir dir;
struct dirtab *tab;
int perm;
p = c->aux;
tab = p->pipedir;
switch (NETTYPE(c->qid.path)) {
case Qdir:
devdir(c, c->qid, ".", 0, eve, DMDIR | 0555, &dir);
break;
case Qdata0:
perm = tab[1].perm;
perm |= qreadable(p->q[0]) ? DMREADABLE : 0;
perm |= qwritable(p->q[0]) ? DMWRITABLE : 0;
devdir(c, c->qid, tab[1].name, qlen(p->q[0]), eve, perm, &dir);
break;
case Qdata1:
perm = tab[2].perm;
perm |= qreadable(p->q[1]) ? DMREADABLE : 0;
perm |= qwritable(p->q[1]) ? DMWRITABLE : 0;
devdir(c, c->qid, tab[2].name, qlen(p->q[1]), eve, perm, &dir);
break;
default:
panic("pipestat");
}
n = convD2M(&dir, db, n);
if (n < BIT16SZ)
error(ENODATA, ERROR_FIXME);
return n;
}
示例6: srvgen
static int
srvgen(Chan *c, char*, Dirtab*, int, int s, Dir *dp)
{
Srv *sp;
Qid q;
if(s == DEVDOTDOT){
devdir(c, c->qid, "#s", 0, eve, 0555, dp);
return 1;
}
qlock(&srvlk);
for(sp = srv; sp && s; sp = sp->link)
s--;
if(sp == 0) {
qunlock(&srvlk);
return -1;
}
mkqid(&q, sp->path, 0, QTFILE);
/* make sure name string continues to exist after we release lock */
kstrcpy(up->genbuf, sp->name, sizeof up->genbuf);
devdir(c, q, up->genbuf, 0, sp->owner, sp->perm, dp);
qunlock(&srvlk);
return 1;
}
示例7: envgen
static int
envgen(Chan *c, char *name, Dirtab *d, int nd, int s, Dir *dp)
{
Egrp *eg;
Evalue *e;
USED(name);
USED(d);
USED(nd);
if(s == DEVDOTDOT){
devdir(c, c->qid, "#e", 0, eve, DMDIR|0775, dp);
return 1;
}
eg = up->env->egrp;
qlock(&eg->l);
for(e = eg->entries; e != nil && s != 0; e = e->next)
s--;
if(e == nil) {
qunlock(&eg->l);
return -1;
}
/* make sure name string continues to exist after we release lock */
kstrcpy(up->genbuf, e->var, sizeof up->genbuf);
devdir(c, e->qid, up->genbuf, e->len, eve, 0666, dp);
qunlock(&eg->l);
return 1;
}
示例8: pipegen
static int
pipegen(Chan *c, char*, Dirtab *tab, int ntab, int i, Dir *dp)
{
Qid q;
int len;
Pipe *p;
if(i == DEVDOTDOT){
devdir(c, c->qid, "#|", 0, eve, DMDIR|0555, dp);
return 1;
}
i++; /* skip . */
if(tab==0 || i>=ntab)
return -1;
tab += i;
p = c->aux;
switch((ulong)tab->qid.path){
case Qdata0:
len = qlen(p->q[0]);
break;
case Qdata1:
len = qlen(p->q[1]);
break;
default:
len = tab->length;
break;
}
mkqid(&q, NETQID(NETID(c->qid.path), tab->qid.path), 0, QTFILE);
devdir(c, q, tab->name, len, eve, p->perm, dp);
return 1;
}
示例9: pipestat
static int
pipestat(Chan *c, uchar *db, int n)
{
Pipe *p;
Dir dir;
p = c->aux;
switch(NETTYPE(c->qid.path)){
case Qdir:
devdir(c, c->qid, ".", 0, eve, DMDIR|0555, &dir);
break;
case Qdata0:
devdir(c, c->qid, "data", qlen(p->q[0]), eve, p->perm, &dir);
break;
case Qdata1:
devdir(c, c->qid, "data1", qlen(p->q[1]), eve, p->perm, &dir);
break;
default:
panic("pipestat");
}
n = convD2M(&dir, db, n);
if(n < BIT16SZ)
error(Eshortstat);
return n;
}
示例10: envgen
static int
envgen(Chan *c, char *name, Dirtab* dir, int i, int s, Dir *dp)
{
Proc *up = externup();
Egrp *eg;
Evalue *e;
if(s == DEVDOTDOT){
devdir(c, c->qid, "#e", 0, eve, DMDIR|0775, dp);
return 1;
}
eg = envgrp(c);
rlock(&eg->rwl);
e = 0;
if(name)
e = envlookup(eg, name, -1);
else if(s < eg->nent)
e = eg->ent[s];
if(e == 0) {
runlock(&eg->rwl);
return -1;
}
/* make sure name string continues to exist after we release lock */
kstrcpy(up->genbuf, e->name, sizeof up->genbuf);
devdir(c, e->qid, up->genbuf, e->len, eve, 0666, dp);
runlock(&eg->rwl);
return 1;
}
示例11: flash2gen
static int
flash2gen(Chan *c, ulong p, Dir *dp)
{
Flashpart *fp;
Flash *f;
Qid q;
int mode;
f = flash.card[c->dev];
fp = &f->part[PART(p)];
if(fp->name == nil)
return 0;
mkqid(&q, p, 0, QTFILE);
switch(TYPE(p)){
case Qdata:
mode = 0660;
if(f->write == nil)
mode = 0440;
devdir(c, q, fp->name, fp->end-fp->start, eve, mode, dp);
return 1;
case Qctl:
snprint(up->genbuf, sizeof(up->genbuf), "%sctl", fp->name);
devdir(c, q, up->genbuf, 0, eve, 0660, dp);
return 1;
default:
return -1;
}
}
示例12: vcongen
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;
}
示例13: cmd3gen
static int
cmd3gen(Chan *c, int i, Dir *dp)
{
Qid q;
Conv *cv;
cv = cmd.conv[CONV(c->qid)];
switch(i){
default:
return -1;
case Qdata:
mkqid(&q, QID(CONV(c->qid), Qdata), 0, QTFILE);
devdir(c, q, "data", 0, cv->owner, cv->perm, dp);
return 1;
case Qstderr:
mkqid(&q, QID(CONV(c->qid), Qstderr), 0, QTFILE);
devdir(c, q, "stderr", 0, cv->owner, 0444, dp);
return 1;
case Qctl:
mkqid(&q, QID(CONV(c->qid), Qctl), 0, QTFILE);
devdir(c, q, "ctl", 0, cv->owner, cv->perm, dp);
return 1;
case Qstatus:
mkqid(&q, QID(CONV(c->qid), Qstatus), 0, QTFILE);
devdir(c, q, "status", 0, cv->owner, 0444, dp);
return 1;
case Qwait:
mkqid(&q, QID(CONV(c->qid), Qwait), 0, QTFILE);
devdir(c, q, "wait", 0, cv->owner, 0444, dp);
return 1;
}
}
示例14: sd2gen
static int
sd2gen(Chan* c, int i, Dir* dp)
{
Qid q;
uvlong l;
SDpart *pp;
SDperm *perm;
SDunit *unit;
SDev *sdev;
int rv;
sdev = sdgetdev(DEV(c->qid));
assert(sdev);
unit = sdev->unit[UNIT(c->qid)];
rv = -1;
switch(i){
case Qctl:
mkqid(&q, QID(DEV(c->qid), UNIT(c->qid), PART(c->qid), Qctl),
unit->vers, QTFILE);
perm = &unit->ctlperm;
if(emptystr(perm->user)){
kstrdup(&perm->user, eve);
perm->perm = 0644; /* nothing secret in ctl */
}
devdir(c, q, "ctl", 0, perm->user, perm->perm, dp);
rv = 1;
break;
case Qraw:
mkqid(&q, QID(DEV(c->qid), UNIT(c->qid), PART(c->qid), Qraw),
unit->vers, QTFILE);
perm = &unit->rawperm;
if(emptystr(perm->user)){
kstrdup(&perm->user, eve);
perm->perm = DMEXCL|0600;
}
devdir(c, q, "raw", 0, perm->user, perm->perm, dp);
rv = 1;
break;
case Qpart:
pp = &unit->part[PART(c->qid)];
l = (pp->end - pp->start) * unit->secsize;
mkqid(&q, QID(DEV(c->qid), UNIT(c->qid), PART(c->qid), Qpart),
unit->vers+pp->vers, QTFILE);
if(emptystr(pp->user))
kstrdup(&pp->user, eve);
devdir(c, q, pp->name, l, pp->user, pp->perm, dp);
rv = 1;
break;
}
decref(&sdev->r);
return rv;
}
示例15: rootgen
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;
}
}