本文整理汇总了C++中ERRSTACK函数的典型用法代码示例。如果您正苦于以下问题:C++ ERRSTACK函数的具体用法?C++ ERRSTACK怎么用?C++ ERRSTACK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERRSTACK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: devtabread
long devtabread(struct chan *c, void *buf, long n, int64_t off)
{
ERRSTACK(1);
int i;
struct dev *dev;
char *alloc, *e, *p;
alloc = kzmalloc(READSTR, KMALLOC_WAIT);
if (alloc == NULL)
error(ENOMEM, NULL);
p = alloc;
e = p + READSTR;
for (i = 0; &devtab[i] < __devtabend; i++) {
dev = &devtab[i];
printd("p %p e %p e-p %d\n", p, e, e - p);
printd("do %d %s\n", i, dev->name);
p += snprintf(p, e - p, "#%s\n", dev->name);
}
if (waserror()) {
kfree(alloc);
nexterror();
}
n = readstr(off, buf, n, alloc);
kfree(alloc);
poperror();
return n;
}
示例2: ERRSTACK
/*
* parse a command written to a device
*/
struct cmdbuf *parsecmd(char *p, int n)
{
ERRSTACK(1);
struct cmdbuf *volatile cb;
int nf;
char *sp;
nf = ncmdfield(p, n);
/* allocate Cmdbuf plus string pointers plus copy of string including \0 */
sp = kzmalloc(sizeof(*cb) + nf * sizeof(char *) + n + 1, 0);
cb = (struct cmdbuf *)sp;
cb->f = (char **)(&cb[1]);
cb->buf = (char *)(&cb->f[nf]);
if (current != NULL && waserror()) {
kfree(cb);
nexterror();
}
memmove(cb->buf, p, n);
if (current != NULL)
poperror();
/* dump new line and null terminate */
if (n > 0 && cb->buf[n - 1] == '\n')
n--;
cb->buf[n] = '\0';
cb->nf = tokenize(cb->buf, cb->f, nf - 1);
cb->f[cb->nf] = NULL;
return cb;
}
示例3: pipewstat
static int pipewstat(struct chan *c, uint8_t *dp, int n)
{
ERRSTACK(2);
struct dir *d;
Pipe *p;
int d1;
if (c->qid.type & QTDIR)
error(EPERM, ERROR_FIXME);
p = c->aux;
if (strcmp(current->user, p->user) != 0)
error(EPERM, ERROR_FIXME);
d = kzmalloc(sizeof(*d) + n, 0);
if (waserror()) {
kfree(d);
nexterror();
}
n = convM2D(dp, n, d, (char *)&d[1]);
if (n == 0)
error(ENODATA, ERROR_FIXME);
d1 = NETTYPE(c->qid.path) == Qdata1;
if (!emptystr(d->name)) {
validwstatname(d->name);
if (strlen(d->name) >= KNAMELEN)
error(ENAMETOOLONG, ERROR_FIXME);
if (strncmp(p->pipedir[1 + !d1].name, d->name, KNAMELEN) == 0)
error(EEXIST, ERROR_FIXME);
strncpy(p->pipedir[1 + d1].name, d->name, KNAMELEN);
}
if (d->mode != ~0UL)
p->pipedir[d1 + 1].perm = d->mode & 0777;
poperror();
kfree(d);
return n;
}
示例4: syscreate
int syscreate(char *path, int mode, uint32_t perm)
{
ERRSTACK(2);
int fd;
struct chan *c;
if (waserror()) {
poperror();
return -1;
}
openmode(mode & ~O_EXCL); /* error check only; OEXCL okay here */
c = namec(path, Acreate, mode, perm);
if (waserror()) {
cclose(c);
nexterror();
}
fd = newfd(c, mode); /* 9ns mode is the O_FLAGS and perm is glibc mode */
if (fd < 0)
error(-fd, ERROR_FIXME);
poperror();
poperror();
return fd;
}
示例5: sysfversion
int sysfversion(int fd, unsigned int msize, char *vers, unsigned int arglen)
{
ERRSTACK(2);
int m;
struct chan *c;
if (waserror()) {
poperror();
return -1;
}
/* check there's a NUL in the version string */
if (arglen == 0 || memchr(vers, 0, arglen) == 0)
error(EINVAL, ERROR_FIXME);
c = fdtochan(¤t->open_files, fd, O_RDWR, 0, 1);
if (waserror()) {
cclose(c);
nexterror();
}
m = mntversion(c, vers, msize, arglen);
poperror();
cclose(c);
poperror();
return m;
}
示例6: sys_dup_to
/* Could pass in the fdt instead of the proc, but we used to need the to_proc
* for now so we can claim a VFS FD. Careful, we don't close the old chan. */
int sys_dup_to(struct proc *from_proc, unsigned int from_fd,
struct proc *to_proc, unsigned int to_fd)
{
ERRSTACK(1);
int ret;
struct chan *c;
if (waserror()) {
poperror();
return -1;
}
c = fdtochan(&from_proc->open_files, from_fd, -1, 0, 1);
if (c->qid.type & QTAUTH) {
cclose(c);
error(EPERM, ERROR_FIXME);
}
ret = insert_obj_fdt(&to_proc->open_files, c, to_fd, 0, TRUE, FALSE);
/* drop the ref from fdtochan. if insert succeeded, there is one other ref
* stored in the FDT */
cclose(c);
if (ret < 0)
error(EFAIL, "Can't insert FD %d into FDG", to_fd);
poperror();
return 0;
}
示例7: ipifckick
/*
* called when a process writes to an interface's 'data'
*/
static void ipifckick(void *x)
{
ERRSTACK(1);
struct conv *c = x;
struct block *bp;
struct Ipifc *ifc;
bp = qget(c->wq);
if (bp == NULL)
return;
ifc = (struct Ipifc *)c->ptcl;
if (!canrlock(&ifc->rwlock)) {
freeb(bp);
return;
}
if (waserror()) {
runlock(&ifc->rwlock);
nexterror();
}
if (ifc->m == NULL || ifc->m->pktin == NULL)
freeb(bp);
else
(*ifc->m->pktin) (c->p->f, ifc, bp);
runlock(&ifc->rwlock);
poperror();
}
示例8: ERRSTACK
/*
* associate an address with the interface. This wipes out any previous
* addresses. This is a macro that means, remove all the old interfaces
* and add a new one.
*/
static char *ipifcconnect(struct conv *c, char **argv, int argc)
{
ERRSTACK(1);
char *err;
struct Ipifc *ifc;
ifc = (struct Ipifc *)c->ptcl;
if (ifc->m == NULL)
return "ipifc not yet bound to device";
if (waserror()) {
wunlock(&ifc->rwlock);
nexterror();
}
wlock(&ifc->rwlock);
while (ifc->lifc) {
err = ipifcremlifc(ifc, ifc->lifc);
if (err)
error(err);
}
wunlock(&ifc->rwlock);
poperror();
err = ipifcadd(ifc, argv, argc, 0, NULL);
if (err)
return err;
Fsconnected(c, NULL);
return NULL;
}
示例9: kchanio
long kchanio(void *vc, void *buf, int n, int mode)
{
ERRSTACK(1);
int r;
struct chan *c;
c = vc;
if (waserror()) {
poperror();
return -1;
}
if (mode == O_READ)
r = devtab[c->type].read(c, buf, n, c->offset);
else if (mode == O_WRITE)
r = devtab[c->type].write(c, buf, n, c->offset);
else
error(ENOSYS, "kchanio: use only O_READ xor O_WRITE");
spin_lock(&c->lock);
c->offset += r;
spin_unlock(&c->lock);
poperror();
return r;
}
示例10: syscreate
int syscreate(char *path, int mode, uint32_t perm)
{
ERRSTACK(2);
int fd;
struct chan *c;
if (waserror()) {
poperror();
return -1;
}
openmode(mode & ~OEXCL); /* error check only; OEXCL okay here */
c = namec(path, Acreate, mode, perm);
if (waserror()) {
cclose(c);
nexterror();
}
fd = newfd(c);
if (fd < 0)
error(Enofd);
poperror();
poperror();
return fd;
}
示例11: pprint
int pprint(char *fmt, ...)
{
ERRSTACK(2);
int n;
struct chan *c;
va_list arg;
char buf[2 * PRINTSIZE];
if (up == NULL || current->fgrp == NULL)
return 0;
c = current->fgrp->fd[2];
if (c == 0 || (c->mode != O_WRITE && c->mode != O_RDWR))
return 0;
n = snprintf(buf, sizeof buf, "%s %lud: ", current->text, current->pid);
va_start(arg, fmt);
n = vsnprintf(buf + n, sizeof(buf), fmt, arg);
va_end(arg);
if (waserror())
return 0;
devtab[c->type]->write(c, buf, n, c->offset);
poperror();
spin_lock(&c->lock);
c->offset += n;
spin_unlock(&c->lock);
return n;
}
示例12: ERRSTACK
/*
* copy the contents of memory into a string of blocks.
* return NULL on error.
*/
struct block *mem2bl(uint8_t * p, int len)
{
ERRSTACK(1);
int n;
struct block *b, *first, **l;
first = NULL;
l = &first;
if (waserror()) {
freeblist(first);
nexterror();
}
do {
n = len;
if (n > Maxatomic)
n = Maxatomic;
*l = b = block_alloc(n, MEM_WAIT);
/* TODO consider extra_data */
memmove(b->wp, p, n);
b->wp += n;
p += n;
len -= n;
l = &b->next;
} while (len > 0);
poperror();
return first;
}
示例13: regresswrite
static long
regresswrite(struct chan *c, void *a, long n, int64_t unused)
{
ERRSTACK(1);
uintptr_t pc;
struct cmdbuf *cb;
cb = parsecmd(a, n);
if (waserror()) {
kfree(cb);
nexterror();
}
switch((int)(c->qid.path)){
case Monitorctlqid:
if(strncmp(a, "ktest", 5) == 0){
run_registered_ktest_suites();
} else {
error(EFAIL, "regresswrite: only commands are %s", ctlcommands);
}
break;
case Monitordataqid:
if (onecmd(cb->nf, cb->f, NULL) < 0)
n = -1;
break;
default:
error(EBADFD, ERROR_FIXME);
}
kfree(cb);
poperror();
return n;
}
示例14: perfmon_open_event
int perfmon_open_event(const struct core_set *cset, struct perfmon_session *ps,
const struct perfmon_event *pev)
{
ERRSTACK(1);
int i;
struct perfmon_alloc *pa = perfmon_create_alloc(pev);
if (waserror()) {
perfmon_destroy_alloc(pa);
nexterror();
}
smp_do_in_cores(cset, perfmon_do_cores_alloc, pa);
for (i = 0; i < num_cores; i++) {
if (core_set_getcpu(cset, i)) {
counter_t ccno = pa->cores_counters[i];
if (unlikely(ccno < 0)) {
perfmon_destroy_alloc(pa);
return (int) ccno;
}
}
}
/* The perfmon_alloc data structure will not be visible to userspace,
* until the perfmon_install_session_alloc() completes, and at that
* time the smp_do_in_cores(perfmon_do_cores_alloc) will have run on
* all cores.
* The perfmon_alloc data structure will never be changed once published.
*/
i = perfmon_install_session_alloc(ps, pa);
poperror();
return i;
}
示例15: netlogctl
void netlogctl(struct Fs *f, char *s, int n)
{
ERRSTACK(1);
int i, set = 0;
Netlogflag *fp;
struct cmdbuf *cb;
struct cmdtab *ct;
cb = parsecmd(s, n);
if (waserror()) {
kfree(cb);
nexterror();
}
if (cb->nf < 2)
error(EINVAL, ERROR_FIXME);
ct = lookupcmd(cb, routecmd, ARRAY_SIZE(routecmd));
switch (ct->index) {
case CMset:
set = 1;
break;
case CMclear:
set = 0;
break;
case CMonly:
parseip(f->alog->iponly, cb->f[1]);
if (ipcmp(f->alog->iponly, IPnoaddr) == 0)
f->alog->iponlyset = 0;
else
f->alog->iponlyset = 1;
kfree(cb);
poperror();
return;
default:
cmderror(cb, "unknown ip control message");
}
for (i = 1; i < cb->nf; i++) {
for (fp = flags; fp->name; fp++)
if (strcmp(fp->name, cb->f[i]) == 0)
break;
if (fp->name == NULL)
continue;
if (set)
f->alog->logmask |= fp->mask;
else
f->alog->logmask &= ~fp->mask;
}
kfree(cb);
poperror();
}