这篇教程C++ waserror函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中waserror函数的典型用法代码示例。如果您正苦于以下问题:C++ waserror函数的具体用法?C++ waserror怎么用?C++ waserror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了waserror函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: pexitvoidpexit(char *exitstr, int freemem){ Mach *m = machp(); Proc *p; Segment **s, **es; int32_t utime, stime; Waitq *wq, *f, *next; Fgrp *fgrp; Egrp *egrp; Rgrp *rgrp; Pgrp *pgrp; Chan *dot; if(0 && m->externup->nfullq > 0) iprint(" %s=%d", m->externup->text, m->externup->nfullq); if(0 && m->externup->nicc > 0) iprint(" [%s nicc %ud tctime %ulld actime %ulld]/n", m->externup->text, m->externup->nicc, m->externup->tctime, m->externup->actime); if(m->externup->syscalltrace != nil) free(m->externup->syscalltrace); m->externup->syscalltrace = nil; m->externup->alarm = 0; if (m->externup->tt) timerdel(m->externup); if(m->externup->trace) proctrace(m->externup, SDead, 0); /* nil out all the resources under lock (free later) */ qlock(&m->externup->debug); fgrp = m->externup->fgrp; m->externup->fgrp = nil; egrp = m->externup->egrp; m->externup->egrp = nil; rgrp = m->externup->rgrp; m->externup->rgrp = nil; pgrp = m->externup->pgrp; m->externup->pgrp = nil; dot = m->externup->dot; m->externup->dot = nil; qunlock(&m->externup->debug); if(fgrp) closefgrp(fgrp); if(egrp) closeegrp(egrp); if(rgrp) closergrp(rgrp); if(dot) cclose(dot); if(pgrp) closepgrp(pgrp); /* * if not a kernel process and have a parent, * do some housekeeping. */ if(m->externup->kp == 0) { p = m->externup->parent; if(p == 0) { if(exitstr == 0) exitstr = "unknown"; //die("bootprocessdeath"); panic("boot process died: %s", exitstr); } while(waserror()) ; wq = smalloc(sizeof(Waitq)); poperror(); wq->w.pid = m->externup->pid; utime = m->externup->time[TUser] + m->externup->time[TCUser]; stime = m->externup->time[TSys] + m->externup->time[TCSys]; wq->w.time[TUser] = tk2ms(utime); wq->w.time[TSys] = tk2ms(stime); wq->w.time[TReal] = tk2ms(sys->machptr[0]->ticks - m->externup->time[TReal]); if(exitstr && exitstr[0]) snprint(wq->w.msg, sizeof(wq->w.msg), "%s %d: %s", m->externup->text, m->externup->pid, exitstr); else wq->w.msg[0] = '/0'; lock(&p->exl); /* * Check that parent is still alive. */ if(p->pid == m->externup->parentpid && p->state != Broken) { p->nchild--; p->time[TCUser] += utime; p->time[TCSys] += stime; /* * If there would be more than 128 wait records * processes for my parent, then don't leave a wait * record behind. This helps prevent badly written * daemon processes from accumulating lots of wait * records.//.........这里部分代码省略.........
开发者ID:npe9,项目名称:harvey,代码行数:101,
示例2: conswritestatic int32_tconswrite(Chan *c, void *va, int32_t n, int64_t off){ Proc *up = externup(); char buf[256]; int32_t l, bp; char *a; Mach *mp; int i; uint32_t offset; Cmdbuf *cb; Cmdtab *ct; a = va; offset = off; extern int printallsyscalls; switch((uint32_t)c->qid.path){ case Qcons: /* * Can't page fault in putstrn, so copy the data locally. */ l = n; while(l > 0){ bp = l; if(bp > sizeof buf) bp = sizeof buf; memmove(buf, a, bp); putstrn0(buf, bp, 1); a += bp; l -= bp; } break; case Qconsctl: print("consctl/n"); if(n >= sizeof(buf)) n = sizeof(buf)-1; strncpy(buf, a, n); buf[n] = 0; for(a = buf; a;){ if(strncmp(a, "sys", 3) == 0) { printallsyscalls = ! printallsyscalls; print("%sracing syscalls/n", printallsyscalls ? "T" : "Not t"); } if(a = strchr(a, ' ')) a++; } break; case Qtime: if(!iseve()) error(Eperm); return writetime(a, n); case Qbintime: if(!iseve()) error(Eperm); return writebintime(a, n); case Qhostowner: return hostownerwrite(a, n); case Qhostdomain: return hostdomainwrite(a, n); case Quser: return userwrite(a, n); case Qnull: break; case Qreboot: if(!iseve()) error(Eperm); cb = parsecmd(a, n); if(waserror()) { free(cb); nexterror(); } ct = lookupcmd(cb, rebootmsg, nelem(rebootmsg)); switch(ct->index) { case CMhalt: reboot(nil, 0, 0); break; case CMreboot: rebootcmd(cb->nf-1, cb->f+1); break; case CMpanic: *(volatile uint32_t*)0=0; panic("/dev/reboot"); } poperror(); free(cb); break; case Qsysstat: for(i = 0; i < MACHMAX; i++) if((mp = sys->machptr[i]) != nil && mp->online){ mp = sys->machptr[i];//.........这里部分代码省略.........
开发者ID:Requaos,项目名称:harvey,代码行数:101,
示例3: netifwrite/* * the devxxx.c that calls us handles writing data, it knows best */int32_tnetifwrite(Netif *nif, Chan *c, void *a, int32_t n){ Mach *m = machp(); Netfile *f; int type, mtu; char *p, buf[64]; uint8_t binaddr[Nmaxaddr]; if(NETTYPE(c->qid.path) != Nctlqid) error(Eperm); if(n >= sizeof(buf)) n = sizeof(buf)-1; memmove(buf, a, n); buf[n] = 0; if(waserror()){ qunlock(nif); nexterror(); } qlock(nif); f = nif->f[NETID(c->qid.path)]; if((p = matchtoken(buf, "connect")) != 0){ qclose(f->iq); type = atoi(p); if(typeinuse(nif, type)) error(Einuse); f->type = type; if(f->type < 0) nif->all++; qreopen(f->iq); } else if(matchtoken(buf, "promiscuous")){ if(f->prom == 0){ if(nif->prom == 0 && nif->promiscuous != nil) nif->promiscuous(nif->arg, 1); f->prom = 1; nif->prom++; } } else if((p = matchtoken(buf, "scanbs")) != 0){ /* scan for base stations */ if(f->scan == 0){ type = atoi(p); if(type < 5) type = 5; if(nif->scanbs != nil) nif->scanbs(nif->arg, type); f->scan = type; nif->_scan++; } } else if((p = matchtoken(buf, "mtu")) != 0){ /* poor planning. */ if(!iseve()) error(Eperm); mtu = atoi(p); /* zero resets default. */ if(mtu != 0) if(mtu < nif->minmtu || mtu > nif->maxmtu) error(Ebadarg); if(nif->hwmtu) nif->mtu = nif->hwmtu(nif->arg, mtu); else nif->mtu = mtu; } else if(matchtoken(buf, "l2bridge")){ f->bridge |= 2; } else if(matchtoken(buf, "bridge")){ f->bridge |= 1; } else if(matchtoken(buf, "headersonly")){ f->headersonly = 1; } else if((p = matchtoken(buf, "addmulti")) != 0){ if(parseaddr(binaddr, p, nif->alen) < 0) error("bad address"); p = netmulti(nif, f, binaddr, 1); if(p) error(p); } else if((p = matchtoken(buf, "remmulti")) != 0){ if(parseaddr(binaddr, p, nif->alen) < 0) error("bad address"); p = netmulti(nif, f, binaddr, 0); if(p) error(p); } else n = -1; qunlock(nif); poperror(); return n;}
开发者ID:ezhangle,项目名称:harvey,代码行数:91,
示例4: netifwrite/* * the devxxx.c that calls us handles writing data, it knows best */long netifwrite(struct ether *nif, struct chan *c, void *a, long n){ ERRSTACK(1); struct netfile *f; int type; char *p, buf[64]; uint8_t binaddr[Nmaxaddr]; if (NETTYPE(c->qid.path) != Nctlqid) error(Eperm); if (n >= sizeof(buf)) n = sizeof(buf) - 1; memmove(buf, a, n); buf[n] = 0; if (waserror()) { qunlock(&nif->qlock); nexterror(); } qlock(&nif->qlock); f = nif->f[NETID(c->qid.path)]; if ((p = matchtoken(buf, "connect")) != 0) { type = strtol(p, 0, 0); /* allows any base, though usually hex */ if (typeinuse(nif, type)) error(Einuse); f->type = type; if (f->type < 0) nif->all++; } else if (matchtoken(buf, "promiscuous")) { if (f->prom == 0) { if (nif->prom == 0 && nif->promiscuous != NULL) nif->promiscuous(nif->arg, 1); f->prom = 1; nif->prom++; } } else if ((p = matchtoken(buf, "scanbs")) != 0) { /* scan for base stations */ if (f->scan == 0) { type = strtol(p, 0, 0); /* allows any base, though usually hex */ if (type < 5) type = 5; if (nif->scanbs != NULL) nif->scanbs(nif->arg, type); f->scan = type; nif->scan++; } } else if (matchtoken(buf, "bridge")) { f->bridge = 1; } else if (matchtoken(buf, "headersonly")) { f->headersonly = 1; } else if ((p = matchtoken(buf, "addmulti")) != 0) { if (parseaddr(binaddr, p, nif->alen) < 0) error("bad address"); p = netmulti(nif, f, binaddr, 1); if (p) error(p); } else if ((p = matchtoken(buf, "remmulti")) != 0) { if (parseaddr(binaddr, p, nif->alen) < 0) error("bad address"); p = netmulti(nif, f, binaddr, 0); if (p) error(p); } else n = -1; qunlock(&nif->qlock); poperror(); return n;}
开发者ID:goovdl,项目名称:akaros,代码行数:73,
示例5: conswritestatic longconswrite(Chan *c, void *va, long n, vlong offset){ char buf[128], *a, ch; int x; if(c->qid.type & QTDIR) error(Eperm); switch((ulong)c->qid.path) { default: error(Egreg); case Qcons: if(canrlock(&kprintq.l)){ if(kprintq.q != nil){ if(waserror()){ runlock(&kprintq.l); nexterror(); } qwrite(kprintq.q, va, n); poperror(); runlock(&kprintq.l); return n; } runlock(&kprintq.l); } return write(1, va, n); case Qsysctl: return sysconwrite(va, n); case Qconsctl: if(n >= sizeof(buf)) n = sizeof(buf)-1; strncpy(buf, va, n); buf[n] = 0; for(a = buf; a;){ if(strncmp(a, "rawon", 5) == 0){ kbd.raw = 1; /* clumsy hack - wake up reader */ ch = 0; qwrite(kbdq, &ch, 1); } else if(strncmp(buf, "rawoff", 6) == 0){ kbd.raw = 0; } if((a = strchr(a, ' ')) != nil) a++; } break; case Qkeyboard: for(x=0; x<n; ) { Rune r; x += chartorune(&r, &((char*)va)[x]); gkbdputc(gkbdq, r); } break; case Qnull: break; case Qtime: if(n >= sizeof(buf)) n = sizeof(buf)-1; strncpy(buf, va, n); buf[n] = '/0'; timeoffset = strtoll(buf, 0, 0)-osusectime(); break; case Qhostowner: if(!iseve()) error(Eperm); if(offset != 0 || n >= sizeof(buf)) error(Ebadarg); memmove(buf, va, n); buf[n] = '/0'; if(n > 0 && buf[n-1] == '/n') buf[--n] = '/0'; if(n == 0) error(Ebadarg); /* renameuser(eve, buf); */ /* renameproguser(eve, buf); */ kstrdup(&eve, buf); kstrdup(&up->env->user, buf); break; case Quser: if(!iseve()) error(Eperm); if(offset != 0) error(Ebadarg); if(n <= 0 || n >= sizeof(buf)) error(Ebadarg); strncpy(buf, va, n); buf[n] = '/0'; if(n > 0 && buf[n-1] == '/n') buf[--n] = '/0'; if(n == 0) error(Ebadarg);//.........这里部分代码省略.........
开发者ID:Mekapaedia,项目名称:inferno-rpi,代码行数:101,
示例6: trap//.........这里部分代码省略......... cycles(&m->externup->kentry); } clockintr = 0; //_pmcupdate(m); if(ctl = vctl[vno]){ if(ctl->isintr){ m->intr++; if(vno >= VectorPIC && vno != VectorSYSCALL) m->lastintr = ctl->irq; }else if(m->externup) m->externup->nqtrap++; if(ctl->isr) ctl->isr(vno); for(v = ctl; v != nil; v = v->next){ if(v->f) v->f(ureg, v->a); } if(ctl->eoi) ctl->eoi(vno); intrtime(vno); if(ctl->isintr){ if(ctl->irq == IrqCLOCK || ctl->irq == IrqTIMER) clockintr = 1; if(m->externup && !clockintr) preempted(); } } else if(vno < nelem(excname) && user){ spllo(); snprint(buf, sizeof buf, "sys: trap: %s", excname[vno]); postnote(m->externup, 1, buf, NDebug); } else if(vno >= VectorPIC && vno != VectorSYSCALL){ /* * An unknown interrupt. * Check for a default IRQ7. This can happen when * the IRQ input goes away before the acknowledge. * In this case, a 'default IRQ7' is generated, but * the corresponding bit in the ISR isn't set. * In fact, just ignore all such interrupts. */ /* clear the interrupt */ i8259isr(vno); iprint("cpu%d: spurious interrupt %d, last %d/n", m->machno, vno, m->lastintr); intrtime(vno); if(user) kexit(ureg); return; } else{ if(vno == VectorNMI){ nmienable(); if(m->machno != 0){ iprint("cpu%d: PC %#llux/n", m->machno, ureg->ip); for(;;); } } dumpregs(ureg); if(!user){ ureg->sp = PTR2UINT(&ureg->sp); dumpstackwithureg(ureg); } if(vno < nelem(excname)) panic("%s", excname[vno]); panic("unknown trap/intr: %d/n", vno); } splhi(); /* delaysched set because we held a lock or because our quantum ended */ if(m->externup && m->externup->delaysched && clockintr){ if(0) if(user && m->externup->ac == nil && m->externup->nqtrap == 0 && m->externup->nqsyscall == 0){ if(!waserror()){ m->externup->ac = getac(m->externup, -1); poperror(); runacore(); return; } } sched(); splhi(); } if(user){ if(m->externup && m->externup->procctl || m->externup->nnote) notify(ureg); kexit(ureg); }}
开发者ID:npe9,项目名称:harvey,代码行数:101,
示例7: loopbackwritestatic longloopbackwrite(Chan *c, void *va, long n, vlong off){ Loop *lb; Link *link; Cmdbuf *volatile cb; Block *volatile bp; vlong d0, d0ns; long dn, dnns; switch(TYPE(c->qid.path)){ case Qdata: bp = allocb(n); if(waserror()){ freeb(bp); nexterror(); } memmove(bp->wp, va, n); poperror(); bp->wp += n; return loopbackbwrite(c, bp, off); case Qctl: lb = c->aux; link = &lb->link[ID(c->qid.path)]; cb = parsecmd(va, n); if(waserror()){ free(cb); nexterror(); } if(cb->nf < 1) error("short control request"); if(strcmp(cb->f[0], "delay") == 0){ if(cb->nf != 3) error("usage: delay latency bytedelay"); d0ns = strtoll(cb->f[1], nil, 10); dnns = strtol(cb->f[2], nil, 10); /* * it takes about 20000 cycles on a pentium ii * to run pushlink; perhaps this should be accounted. */ ilock(link); link->delay0ns = d0ns; link->delaynns = dnns; iunlock(link); }else if(strcmp(cb->f[0], "indrop") == 0){ if(cb->nf != 2) error("usage: indrop [01]"); ilock(link); link->indrop = strtol(cb->f[1], nil, 0) != 0; iunlock(link); }else if(strcmp(cb->f[0], "droprate") == 0){ if(cb->nf != 2) error("usage: droprate ofn"); ilock(link); link->droprate = strtol(cb->f[1], nil, 0); iunlock(link); }else if(strcmp(cb->f[0], "limit") == 0){ if(cb->nf != 2) error("usage: limit maxqsize"); ilock(link); link->limit = strtol(cb->f[1], nil, 0); qsetlimit(link->oq, link->limit); qsetlimit(link->iq, link->limit); iunlock(link); }else if(strcmp(cb->f[0], "reset") == 0){ if(cb->nf != 1) error("usage: reset"); ilock(link); link->packets = 0; link->bytes = 0; link->indrop = 0; link->soverflows = 0; link->drops = 0; iunlock(link); }else error("unknown control request"); poperror(); free(cb); break; default: error(Eperm); } return n;}
开发者ID:Nurb432,项目名称:plan9front,代码行数:87,
示例8: bindmountlongbindmount(int ismount, int fd, int afd, char* arg0, char* arg1, ulong flag, char* spec){ int ret; Chan *c0, *c1, *ac, *bc; struct{ Chan *chan; Chan *authchan; char *spec; int flags; }bogus; if((flag&~MMASK) || (flag&MORDER)==(MBEFORE|MAFTER)) error(Ebadarg); if(ismount){ validaddr((ulong)spec, 1, 0); spec = validnamedup(spec, 1); if(waserror()){ free(spec); nexterror(); } if(up->pgrp->noattach) error(Enoattach); ac = nil; bc = fdtochan(fd, ORDWR, 0, 1); if(waserror()) { if(ac) cclose(ac); cclose(bc); nexterror(); } if(afd >= 0) ac = fdtochan(afd, ORDWR, 0, 1); bogus.flags = flag & MCACHE; bogus.chan = bc; bogus.authchan = ac; bogus.spec = spec; ret = devno('M', 0); c0 = devtab[ret]->attach((char*)&bogus); poperror(); /* ac bc */ if(ac) cclose(ac); cclose(bc); }else{ spec = 0; validaddr((ulong)arg0, 1, 0); c0 = namec(arg0, Abind, 0, 0); } if(waserror()){ cclose(c0); nexterror(); } validaddr((ulong)arg1, 1, 0); c1 = namec(arg1, Amount, 0, 0); if(waserror()){ cclose(c1); nexterror(); } ret = cmount(&c0, c1, flag, spec); poperror(); cclose(c1); poperror(); cclose(c0); if(ismount){ fdclose(fd, 0); poperror(); free(spec); } return ret;}
开发者ID:Akheon23,项目名称:nix-os,代码行数:79,
示例9: bindmount/* if dc is non-zero, it means we're doing a mount and dc is the mount device to use. */static intbindmount(int dc, int fd, int afd, char* arg0, char* arg1, int flag, char* spec){ Proc *up = externup(); int i; Dev *dev; Chan *c0, *c1, *ac, *bc; struct{ Chan *chan; Chan *authchan; char *spec; int flags; }bogus; if((flag&~MMASK) || (flag&MORDER)==(MBEFORE|MAFTER)) error(Ebadarg); bogus.flags = flag & MCACHE; if(dc){ if (! checkdc(dc)) error(Ebadarg); if(up->pgrp->noattach) error(Enoattach); ac = nil; bc = fdtochan(fd, ORDWR, 0, 1); if(waserror()) { if(ac) cclose(ac); cclose(bc); nexterror(); } if(afd >= 0) ac = fdtochan(afd, ORDWR, 0, 1); bogus.chan = bc; bogus.authchan = ac; bogus.spec = validaddr(spec, 1, 0); if(waserror()) error(Ebadspec); spec = validnamedup(spec, 1); poperror(); if(waserror()){ free(spec); nexterror(); } dev = devtabget(dc, 0); //XDYNX if(waserror()){ //devtabdecr(dev); nexterror(); } c0 = dev->attach((char*)&bogus); poperror(); //devtabdecr(dev); poperror(); /* spec */ free(spec); poperror(); /* ac bc */ if(ac) cclose(ac); cclose(bc); }else{ bogus.spec = nil; c0 = namec(validaddr(arg0, 1, 0), Abind, 0, 0); } if(waserror()){ cclose(c0); nexterror(); } c1 = namec(validaddr(arg1, 1, 0), Amount, 0, 0); if(waserror()){ cclose(c1); nexterror(); } i = cmount(&c0, c1, flag, bogus.spec); poperror(); cclose(c1); poperror(); cclose(c0); if(dc) fdclose(fd, 0); return i;}
开发者ID:Shamar,项目名称:harvey,代码行数:95,
示例10: readstatic longread(ulong *arg, vlong *offp){ long n, nn, nnn; uchar *p; Chan *c; vlong off; n = arg[2]; validaddr(arg[1], n, 1); p = (void*)arg[1]; c = fdtochan(arg[0], OREAD, 1, 1); if(waserror()){ cclose(c); nexterror(); } /* * The offset is passed through on directories, normally. * Sysseek complains, but pread is used by servers like exportfs, * that shouldn't need to worry about this issue. * * Notice that c->devoffset is the offset that c's dev is seeing. * The number of bytes read on this fd (c->offset) may be different * due to rewritings in rockfix. */ if(offp == nil) /* use and maintain channel's offset */ off = c->offset; else off = *offp; if(off < 0) error(Enegoff); if(off == 0){ /* rewind to the beginning of the directory */ if(offp == nil){ c->offset = 0; c->devoffset = 0; } mountrewind(c); unionrewind(c); } if(c->qid.type & QTDIR){ if(mountrockread(c, p, n, &nn)){ /* do nothing: mountrockread filled buffer */ }else if(c->umh) nn = unionread(c, p, n); else{ if(off != c->offset) error(Edirseek); nn = devtab[c->type]->read(c, p, n, c->devoffset); } nnn = mountfix(c, p, nn, n); }else nnn = nn = devtab[c->type]->read(c, p, n, off); lock(c); c->devoffset += nn; c->offset += nnn; unlock(c); poperror(); cclose(c); return nnn;}
开发者ID:Akheon23,项目名称:nix-os,代码行数:67,
示例11: sseekstatic voidsseek(ulong *arg){ Chan *c; uchar buf[sizeof(Dir)+100]; Dir dir; int n; vlong off; union { vlong v; ulong u[2]; } o; c = fdtochan(arg[1], -1, 1, 1); if(waserror()){ cclose(c); nexterror(); } if(devtab[c->type]->dc == '|') error(Eisstream); off = 0; o.u[0] = arg[2]; o.u[1] = arg[3]; switch(arg[4]){ case 0: off = o.v; if((c->qid.type & QTDIR) && off != 0) error(Eisdir); if(off < 0) error(Enegoff); c->offset = off; break; case 1: if(c->qid.type & QTDIR) error(Eisdir); lock(c); /* lock for read/write update */ off = o.v + c->offset; if(off < 0){ unlock(c); error(Enegoff); } c->offset = off; unlock(c); break; case 2: if(c->qid.type & QTDIR) error(Eisdir); n = devtab[c->type]->stat(c, buf, sizeof buf); if(convM2D(buf, n, &dir, nil) == 0) error("internal error: stat error in seek"); off = dir.length + o.v; if(off < 0) error(Enegoff); c->offset = off; break; default: error(Ebadarg); } *(vlong*)arg[0] = off; c->uri = 0; c->dri = 0; cclose(c); poperror();}
开发者ID:Akheon23,项目名称:nix-os,代码行数:68,
示例12: mountfix/* * Rewrite the results of a directory read to reflect current * name space bindings and mounts. Specifically, replace * directory entries for bind and mount points with the results * of statting what is mounted there. Except leave the old names. */static longmountfix(Chan *c, uchar *op, long n, long maxn){ char *name; int nbuf, nname; Chan *nc; Mhead *mh; Mount *m; uchar *p; int dirlen, rest; long l; uchar *buf, *e; Dir d; p = op; buf = nil; nbuf = 0; for(e=&p[n]; p+BIT16SZ<e; p+=dirlen){ dirlen = dirfixed(p, e, &d); if(dirlen < 0) break; nc = nil; mh = nil; if(findmount(&nc, &mh, d.type, d.dev, d.qid)){ /* * If it's a union directory and the original is * in the union, don't rewrite anything. */ for(m=mh->mount; m; m=m->next) if(eqchantdqid(m->to, d.type, d.dev, d.qid, 1)) goto Norewrite; name = dirname(p, &nname); /* * Do the stat but fix the name. If it fails, leave old entry. * BUG: If it fails because there isn't room for the entry, * what can we do? Nothing, really. Might as well skip it. */ if(buf == nil){ buf = smalloc(4096); nbuf = 4096; } if(waserror()) goto Norewrite; l = devtab[nc->type]->stat(nc, buf, nbuf); l = dirsetname(name, nname, buf, l, nbuf); if(l == BIT16SZ) error("dirsetname"); poperror(); /* * Shift data in buffer to accomodate new entry, * possibly overflowing into rock. */ rest = e - (p+dirlen); if(l > dirlen){ while(p+l+rest > op+maxn){ mountrock(c, p, &e); if(e == p){ dirlen = 0; goto Norewrite; } rest = e - (p+dirlen); } } if(l != dirlen){ memmove(p+l, p+dirlen, rest); dirlen = l; e = p+dirlen+rest; } /* * Rewrite directory entry. */ memmove(p, buf, l); Norewrite: cclose(nc); putmhead(mh); } } if(buf) free(buf); if(p != e) error("oops in rockfix"); return e-op;}
开发者ID:Akheon23,项目名称:nix-os,代码行数:95,
示例13: runacore/* * Move the current process to an application core. * This is performed at the end of execac(), and * we pretend to be returning to user-space, but instead we * dispatch the process to another core. * 1. We do the final bookkeeping that syscall() would do after * a return from sysexec(), because we are not returning. * 2. We dispatch the process to an AC using an ICC. * * This function won't return unless the process is reclaimed back * to the time-sharing core, and is the handler for the process * to deal with traps and system calls until the process dies. * * Remember that this function is the "line" between user and kernel * space, it's not expected to raise|handle any error. * * We install a safety error label, just in case we raise errors, * which we shouldn't. (noerrorsleft knows that for exotic processes * there is an error label pushed by us). */voidrunacore(void){ Proc *up = externup(); Ureg *ureg; void (*fn)(void); int rc, flush, s; char *n; uint64_t t1; if(waserror()) panic("runacore: error: %s/n", up->errstr); ureg = up->dbgreg; fakeretfromsyscall(ureg); fpusysrfork(ureg); procpriority(up, PriKproc, 1); rc = runac(up->ac, actouser, 1, nil, 0); procpriority(up, PriNormal, 0); for(;;){ t1 = fastticks(nil); flush = 0; fn = nil; switch(rc){ case ICCTRAP: s = splhi(); machp()->MMU.cr2 = up->ac->MMU.cr2; DBG("runacore: trap %llu cr2 %#llx ureg %#p/n", ureg->type, machp()->MMU.cr2, ureg); switch(ureg->type){ case IdtIPI: if(up->procctl || up->nnote) notify(up->dbgreg); if(up->ac == nil) goto ToTC; kexit(up->dbgreg); break; case IdtNM: case IdtMF: case IdtXF: /* these are handled in the AC; * If we get here, they left in m->NIX.icc->data * a note to be posted to the process. * Post it, and make the vector a NOP. */ n = up->ac->NIX.icc->note; if(n != nil) postnote(up, 1, n, NDebug); ureg->type = IdtIPI; /* NOP */ break; default: cr3put(machp()->MMU.pml4->pa); if(0 && ureg->type == IdtPF){ print("before PF:/n"); print("AC:/n"); dumpptepg(4, up->ac->MMU.pml4->pa); print("/n%s:/n", rolename[NIXTC]); dumpptepg(4, machp()->MMU.pml4->pa); } trap(ureg); } splx(s); flush = 1; fn = actrapret; break; case ICCSYSCALL: DBG("runacore: syscall ax %#llx ureg %#p/n", ureg->ax, ureg); cr3put(machp()->MMU.pml4->pa); //syscall(ureg->ax, ureg); flush = 1; fn = acsysret; if(0) if(up->nqtrap > 2 || up->nsyscall > 1) goto ToTC; if(up->ac == nil) goto ToTC; break; default: panic("runacore: unexpected rc = %d", rc);//.........这里部分代码省略.........
开发者ID:Harvey-OS,项目名称:harvey,代码行数:101,
示例14: trapvoidtrap(Ureg *ureg){ int rem, itype, t; if(up != nil) rem = ((char*)ureg)-up->kstack; else rem = ((char*)ureg)-(char*)m->stack; if(ureg->type != PsrMfiq && rem < 256) { dumpregs(ureg); panic("trap %d stack bytes remaining (%s), " "up=#%8.8lux ureg=#%8.8lux pc=#%8.8ux" ,rem, up?up->text:"", up, ureg, ureg->pc); for(;;); } itype = ureg->type; /* All interrupts/exceptions should be resumed at ureg->pc-4, except for Data Abort which resumes at ureg->pc-8. */ if(itype == PsrMabt+1) ureg->pc -= 8; else ureg->pc -= 4; if(up){ up->pc = ureg->pc; up->dbgreg = ureg; } switch(itype) { case PsrMirq: t = m->ticks; /* CPU time per proc */ up = nil; /* no process at interrupt level */ irq(ureg); up = m->proc; preemption(m->ticks - t); m->intr++; break; case PsrMund: if(*(ulong*)ureg->pc == BREAK && breakhandler) { int s; Proc *p; p = up; s = breakhandler(ureg, p); if(s == BrkSched) { p->preempted = 0; sched(); } else if(s == BrkNoSched) { /* stop it being preempted until next instruction */ p->preempted = 1; if(up) up->dbgreg = 0; return; } break; } if(up == nil) goto faultpanic; spllo(); if(waserror()) { if(waslo(ureg->psr) && up->type == Interp) disfault(ureg, up->env->errstr); setpanic(); dumpregs(ureg); panic("%s", up->env->errstr); } if(!fpiarm(ureg)) { dumpregs(ureg); sys_trap_error(ureg->type); } poperror(); break; case PsrMsvc: /* Jump through 0 or SWI */ if(waslo(ureg->psr) && up && up->type == Interp) { spllo(); dumpregs(ureg); sys_trap_error(ureg->type); } setpanic(); dumpregs(ureg); panic("SVC/SWI exception"); break; case PsrMabt: /* Prefetch abort */ if(catchdbg && catchdbg(ureg, 0)) break; /* FALL THROUGH */ case PsrMabt+1: /* Data abort */ if(waslo(ureg->psr) && up && up->type == Interp) { spllo(); faultarm(ureg); } print("Data Abort/n"); /* FALL THROUGH */ default:faultpanic: setpanic();//.........这里部分代码省略.........
开发者ID:bestm80eva,项目名称:inferno-rpi,代码行数:101,
示例15: putstrn0/* * Print a string on the console. Convert /n to /r/n for serial * line consoles. Locking of the queues is left up to the screen * or uart code. Multi-line messages to serial consoles may get * interspersed with other messages. */static voidputstrn0(char *str, int n, int usewrite){ int m; char *t; char buf[PRINTSIZE+2]; /* * if kprint is open, put the message there, otherwise * if there's an attached bit mapped display, * put the message there. */ m = consoleprint; if(canrlock(&kprintq)){ if(kprintq.q != nil){ if(waserror()){ runlock(&kprintq); nexterror(); } if(usewrite) qwrite(kprintq.q, str, n); else qiwrite(kprintq.q, str, n); poperror(); m = 0; } runlock(&kprintq); } if(m && screenputs != nil) screenputs(str, n); /* * if there's a serial line being used as a console, * put the message there. */ if(serwrite != nil) { serwrite(str, n); return; } if(printq == 0) return; while(n > 0) { t = memchr(str, '/n', n); if(t && !kbd.raw) { m = t - str; if(m > sizeof(buf)-2) m = sizeof(buf)-2; memmove(buf, str, m); buf[m] = '/r'; buf[m+1] = '/n'; if(usewrite) qwrite(printq, buf, m+2); else qiwrite(printq, buf, m+2); str = t + 1; n -= m + 1; } else { if(usewrite) qwrite(printq, str, n); else qiwrite(printq, str, n); break; } }}
开发者ID:8l,项目名称:inferno,代码行数:73,
示例16: mountfix/* * Rewrite the results of a directory read to reflect current * name space bindings and mounts. Specifically, replace * directory entries for bind and mount points with the results * of statting what is mounted there. Except leave the old names. */static int32_tmountfix(Chan *c, uint8_t *op, int32_t n, int32_t maxn){ Proc *up = externup(); char *name; int nbuf; Chan *nc; Mhead *mh; Mount *mount; usize dirlen, nname, r, rest; int32_t l; uint8_t *buf, *e, *p; Dir d; p = op; buf = nil; nbuf = 0; for(e=&p[n]; p+BIT16SZ<e; p+=dirlen){ dirlen = dirfixed(p, e, &d); if(dirlen == 0) break; nc = nil; mh = nil; if(findmount(&nc, &mh, d.type, d.dev, d.qid)){ /* * If it's a union directory and the original is * in the union, don't rewrite anything. */ for(mount=mh->mount; mount; mount=mount->next) if(eqchanddq(mount->to, d.type, d.dev, d.qid, 1)) goto Norewrite; name = dirname(p, &nname); /* * Do the stat but fix the name. If it fails, * leave old entry. * BUG: If it fails because there isn't room for * the entry, what can we do? Nothing, really. * Might as well skip it. */ if(buf == nil){ buf = smalloc(4096); nbuf = 4096; } if(waserror()) goto Norewrite; l = nc->dev->stat(nc, buf, nbuf); r = dirsetname(name, nname, buf, l, nbuf); if(r == BIT16SZ) error("dirsetname"); poperror(); /* * Shift data in buffer to accomodate new entry, * possibly overflowing into rock. */ rest = e - (p+dirlen); if(r > dirlen){ while(p+r+rest > op+maxn){ mountrock(c, p, &e); if(e == p){ dirlen = 0; goto Norewrite; } rest = e - (p+dirlen); } } if(r != dirlen){ memmove(p+r, p+dirlen, rest); dirlen = r; e = p+dirlen+rest; } /* * Rewrite directory entry. */ memmove(p, buf, r); Norewrite: cclose(nc); putmhead(mh); } } if(buf) free(buf); if(p != e) error("oops in mountfix"); return e-op;}
开发者ID:Shamar,项目名称:harvey,代码行数:97,
示例17: consreadstatic longconsread(Chan *c, void *buf, long n, vlong offset){ int l; Osenv *o; int ch, eol, i; char *p, tmp[128]; char *cbuf = buf; if(n <= 0) return n; o = up->env; switch((ulong)c->qid.path){ case Qdir: return devdirread(c, buf, n, consdir, nelem(consdir), devgen); case Qsysctl: return readstr(offset, buf, n, VERSION); case Qcons: case Qkeyboard: qlock(&kbd); if(waserror()) { qunlock(&kbd); nexterror(); } if(kbd.raw || kbd.kbdr) { if(qcanread(lineq)) n = qread(lineq, buf, n); else { /* read as much as possible */ do { i = qread(kbdq, cbuf, n); cbuf += i; n -= i; } while(n>0 && qcanread(kbdq)); n = cbuf - (char*)buf; } } else { while(!qcanread(lineq)) { qread(kbdq, &kbd.line[kbd.x], 1); ch = kbd.line[kbd.x]; eol = 0; switch(ch){ case '/b': if(kbd.x) kbd.x--; break; case 0x15: kbd.x = 0; break; case '/n': case 0x04: eol = 1; default: kbd.line[kbd.x++] = ch; break; } if(kbd.x == sizeof(kbd.line) || eol) { if(ch == 0x04) kbd.x--; qwrite(lineq, kbd.line, kbd.x); kbd.x = 0; } } n = qread(lineq, buf, n); } qunlock(&kbd); poperror(); return n; case Qscancode: if(offset == 0) return readstr(0, buf, n, kscanid); else return qread(kscanq, buf, n); case Qtime: snprint(tmp, sizeof(tmp), "%.lld", (vlong)mseconds()*1000); return readstr(offset, buf, n, tmp); case Qhostowner: return readstr(offset, buf, n, eve); case Quser: return readstr(offset, buf, n, o->user); case Qjit: snprint(tmp, sizeof(tmp), "%d", cflag); return readstr(offset, buf, n, tmp); case Qnull: return 0; case Qmsec: return readnum(offset, buf, n, TK2MS(MACHP(0)->ticks), NUMSIZE); case Qsysname: if(sysname == nil) return 0; return readstr(offset, buf, n, sysname);//.........这里部分代码省略.........
开发者ID:8l,项目名称:inferno,代码行数:101,
示例18: readstatic int32_tread(int ispread, int fd, void *p, int32_t n, int64_t off){ Proc *up = externup(); int32_t nn, nnn; Chan *c; p = validaddr(p, n, 1); c = fdtochan(fd, OREAD, 1, 1); if(waserror()){ cclose(c); nexterror(); } /* * The offset is passed through on directories, normally. * Sysseek complains, but pread is used by servers like exportfs, * that shouldn't need to worry about this issue. * * Notice that c->devoffset is the offset that c's dev is seeing. * The number of bytes read on this fd (c->offset) may be different * due to rewritings in mountfix. */ if(ispread){ if(off == ~0LL){ /* use and maintain channel's offset */ off = c->offset; ispread = 0; } } else off = c->offset; if(c->qid.type & QTDIR){ /* * Directory read: * rewind to the beginning of the file if necessary; * try to fill the buffer via mountrockread; * clear ispread to always maintain the Chan offset. */ if(off == 0LL){ if(!ispread){ c->offset = 0; c->devoffset = 0; } mountrewind(c); unionrewind(c); } if(!mountrockread(c, p, n, &nn)){ if(c->umh) nn = unionread(c, p, n); else{ if(off != c->offset) error(Edirseek); nn = c->dev->read(c, p, n, c->devoffset); } } nnn = mountfix(c, p, nn, n); ispread = 0; } else nnn = nn = c->dev->read(c, p, n, off); if(!ispread){ lock(&c->r.l); c->devoffset += nn; c->offset += nnn; unlock(&c->r.l); } poperror(); cclose(c); return nnn;}
开发者ID:Shamar,项目名称:harvey,代码行数:77,
示例19: loopbackattachstatic Chan*loopbackattach(char *spec){ Loop *volatile lb; Queue *q; Chan *c; int chan; int dev; dev = 0; if(spec != nil){ dev = atoi(spec); if(dev >= Nloopbacks) error(Ebadspec); } c = devattach('X', spec); if(waserror()){ chanfree(c); nexterror(); } lb = &loopbacks[dev]; qlock(lb); if(waserror()){ lb->ref--; qunlock(lb); nexterror(); } lb->ref++; if(lb->ref == 1){ for(chan = 0; chan < 2; chan++){ lb->link[chan].ci.mode = Trelative; lb->link[chan].ci.a = &lb->link[chan]; lb->link[chan].ci.f = linkintr; lb->link[chan].limit = Loopqlim; q = qopen(lb->link[chan].limit, 0, 0, 0); lb->link[chan].iq = q; if(q == nil){ freelb(lb); exhausted("memory"); } q = qopen(lb->link[chan].limit, 0, 0, 0); lb->link[chan].oq = q; if(q == nil){ freelb(lb); exhausted("memory"); } lb->link[chan].indrop = 1; lb->link[chan].delaynns = Delayn; lb->link[chan].delay0ns = Delay0; } } poperror(); qunlock(lb); poperror(); mkqid(&c->qid, QID(0, Qtopdir), 0, QTDIR); c->aux = lb; c->dev = dev; return c;}
开发者ID:Nurb432,项目名称:plan9front,代码行数:65,
示例20: qcmdstatic char*qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block){ uchar *d, *c; int pad; TXQ *q; assert(qid < nelem(ctlr->tx)); assert(size <= Tcmdsize-4); ilock(ctlr); q = &ctlr->tx[qid]; while(q->n >= Ntx && !ctlr->broken){ iunlock(ctlr); qlock(q); if(!waserror()){ tsleep(q, txqready, q, 10); poperror(); } qunlock(q); ilock(ctlr); } if(ctlr->broken){ iunlock(ctlr); return "qcmd: broken"; } q->n++; q->lastcmd = code; q->b[q->i] = block; c = q->c + q->i * Tcmdsize; d = q->d + q->i * Tdscsize; /* build command */ c[0] = code; c[1] = 0; /* flags */ c[2] = q->i; c[3] = qid; if(size > 0) memmove(c+4, data, size); size += 4; memset(d, 0, Tdscsize); pad = size - 4; if(block != nil) pad += BLEN(block); pad = ((pad + 3) & ~3) - pad; put32(d, (pad << 28) | ((1 + (block != nil)) << 24)), d += 4; put32(d, PCIWADDR(c)), d += 4; put32(d, size), d += 4; if(block != nil){ size = BLEN(block); put32(d, PCIWADDR(block->rp)), d += 4; put32(d, size), d += 4; } USED(d); coherence(); q->i = (q->i+1) % Ntx; csr32w(ctlr, HbusTargWptr, (qid<<8) | q->i); iunlock(ctlr); return nil;}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:71,
示例21: powerwritestatic longpowerwrite(Chan* c, void *a, long n, vlong){ Cmdbuf *cmd; Puser *p; if(c->qid.type & QTDIR) error(Ebadusefd); cmd = parsecmd(a, n); if(waserror()){ free(cmd); nexterror(); } switch(c->qid.path & ~CHDIR){ case Qdata: p = c->aux; if(cmd->nf < 2) error(Ebadarg); if(strcmp(cmd->f[0], "ack") == 0){ if(strcmp(cmd->f[1], "power") == 0){ lock(p); if(p->state == Pwrack){ lock(&pwrusers.l); if(pwrusers.shutdown && pwrusers.nwaiting > 0) pwrusers.nwaiting--; unlock(&pwrusers.l); wakeup(&pwrusers.ackr); p->state = Pwridle; } unlock(p); }else error(Ebadarg); }else if(strcmp(cmd->f[0], "alarm") == 0){ /* set alarm */ }else error(Ebadarg); break; case Qctl: if(cmd->nf < 1) error(Ebadarg); if(strcmp(cmd->f[0], "suspend") == 0){ /* start the suspend action */ qlock(&pwrusers); //powersuspend(0); /* calls poweringdown, then archsuspend() */ qunlock(&pwrusers); }else if(strcmp(cmd->f[0], "shutdown") == 0){ /* go to it */ qlock(&pwrusers); if(waserror()){ lock(&pwrusers.l); pwrusers.shutdown = 0; /* hard luck for those already notified */ unlock(&pwrusers.l); qunlock(&pwrusers); nexterror(); } lock(&pwrusers.l); pwrusers.shutdown = 1; pwrusers.nwaiting = 0; unlock(&pwrusers.l); for(p = pwrusers.list; p != nil; p = p->next){ lock(p); if(p->state == Pwridle){ p->state = Pwroff; lock(&pwrusers.l); pwrusers.nwaiting++; unlock(&pwrusers.l); } unlock(p); wakeup(&p->r); /* putting the tsleep here does each in turn; move out of loop to multicast */ tsleep(&pwrusers.ackr, alldown, nil, 1000); } poperror(); qunlock(&pwrusers); //powersuspend(1); }else error(Ebadarg); free(cmd); break; default: error(Ebadusefd); } poperror(); return n;}
开发者ID:8l,项目名称:inferno,代码行数:85,
示例22: aoesweepproc/* * Check all frames on device and resend any frames that have been * outstanding for 200% of the device round trip time average. */static voidaoesweepproc(void*){ ulong i, tx, timeout, nbc; vlong starttick; enum { Nms = 100, Nbcms = 30*1000, }; /* magic */ uchar *ea; Aoeata *a; Aoedev *d; Devlink *l; Frame *f, *e; nbc = Nbcms/Nms;loop: if(nbc-- == 0){ if(rediscover && !waserror()){ discover(0xffff, 0xff); poperror(); } nbc = Nbcms/Nms; } starttick = MACHP(0)->ticks; rlock(&devs); for(d = devs.d; d; d = d->next){ if(!canqlock(d)) continue; if(!UP(d)){ qunlock(d); continue; } tx = 0; f = d->frames; e = f + d->nframes; for (; f < e; f++){ if(f->tag == Tfree) continue; l = f->dl; timeout = l->rttavg << 1; i = tsince(f->tag); if(i < timeout) continue; if(d->nout == d->maxout){ if(d->maxout > 1) d->maxout--; d->lastwadj = MACHP(0)->ticks; } a = (Aoeata*)f->hdr; if(a->scnt > Dbcnt / Aoesectsz && ++f->nl->lostjumbo > (d->nframes << 1)){ ea = f->dl->eatab[f->eaidx]; eventlog("% C++ watchdog_init函数代码示例 C++ warnx函数代码示例
|