Example #1
0
Tnode*
initxsuper(void)
{
    Block *b;
    Tnode *t;

    b = readBlock(PartSuper, 0);
    if(b == nil)
        return stringnode("reading super: %r");
    if(!superUnpack(&super, b->data)) {
        blockPut(b);
        return stringnode("unpacking super: %r");
    }
    blockPut(b);
    t = stringnode("super "
                   "version=%#ux "
                   "epoch=[%#ux,%#ux) "
                   "qid=%#llux "
                   "active=%#x "
                   "next=%#x "
                   "current=%#x "
                   "last=%V "
                   "name=%s",
                   super.version, super.epochLow, super.epochHigh,
                   super.qid, super.active, super.next, super.current,
                   super.last, super.name);
    t->expand = xsuperexpand;
    return t;
}
Example #2
0
Tnode*
initxdirentry(MetaEntry *me)
{
    DirEntry dir;
    Tnode *t;

    if(!deUnpack(&dir, me))
        return stringnode("deUnpack: %r");

    t = stringnode("dirEntry elem=%s size=%llud data=%#lux/%#lux meta=%#lux/%#lux", dir.elem, dir.size, dir.entry, dir.gen, dir.mentry, dir.mgen);
    t->nkid = 1;
    t->kid = mallocz(sizeof(t->kid[0])*1, 1);
    t->kid[0] = stringnode(
                    "qid=%#llux\n"
                    "uid=%s gid=%s mid=%s\n"
                    "mtime=%lud mcount=%lud ctime=%lud atime=%lud\n"
                    "mode=%luo\n"
                    "plan9 %d p9path %#llux p9version %lud\n"
                    "qidSpace %d offset %#llux max %#llux",
                    dir.qid,
                    dir.uid, dir.gid, dir.mid,
                    dir.mtime, dir.mcount, dir.ctime, dir.atime,
                    dir.mode,
                    dir.plan9, dir.p9path, dir.p9version,
                    dir.qidSpace, dir.qidOffset, dir.qidMax);
    return t;
}
Example #3
0
/*
 * Read a string for the lexical analyzer.
 * `endc' terminates the string.
 */
static int
lexstring(wint_t endc)
{
	size_t length = lexescape(endc, 0, 0);

	yylval.node = stringnode(linebuf, FALLOC, length);
	return (CONSTANT);
}
Example #4
0
Tnode*
initxroot(char *name, uchar score[VtScoreSize])
{
    Block *b;

    b = dataBlock(score, BtDir, RootTag);
    if(b == nil)
        return stringnode("read data block %V: %r", score);
    return initxblock(b, smprint("'%s' fs root", name), xvacrootgen, nil);
}
Example #5
0
Tnode*
initxvacroot(uchar score[VtScoreSize])
{
    Tnode *t;
    uchar buf[VtRootSize];
    int n;

    if((n = vtread(z, score, VtRootType, buf, VtRootSize)) < 0)
        return stringnode("reading root %V: %r", score);

    if(vtrootunpack(&vac, buf) < 0)
        return stringnode("unpack %d-byte root: %r", n);

    h.blockSize = vac.blocksize;
    t = stringnode("vac version=%#ux name=%s type=%s blocksize=%lud score=%V prev=%V",
                   VtRootVersion, vac.name, vac.type, vac.blocksize, vac.score, vac.prev);
    t->expand = xvacrootexpand;
    return t;
}
Example #6
0
Tnode*
initxlocalroot(char *name, u32int addr)
{
    uchar score[VtScoreSize];
    Block *b;

    localToGlobal(addr, score);
    b = dataBlock(score, BtDir, RootTag);
    if(b == nil)
        return stringnode("read data block %#ux: %r", addr);
    return initxblock(b, smprint("'%s' fs root", name), xlocalrootgen, nil);
}
Example #7
0
Tnode*
initxcache(char *name)
{
    Tnode *t;

    if((fd = open(name, OREAD)) < 0)
        sysfatal("cannot open %s: %r", name);

    t = stringnode("%s", name);
    t->expand = xcacheexpand;
    return t;
}
Example #8
0
Tnode*
initxsource(Entry e, int dowrap)
{
    Block *b;
    Tnode *t, *tt;

    b = dataBlock(e.score, etype(e.flags, e.depth), e.tag);
    if(b == nil)
        return stringnode("dataBlock: %r");

    if((e.flags & VtEntryActive) == 0)
        return stringnode("inactive Entry");

    if(e.depth == 0) {
        if(e.flags & _VtEntryDir)
            tt = initxentryblock(b, copyEntry(e));
        else
            tt = initxdatablock(b, e.dsize);
    } else {
        tt = initxblock(b, smprint("%s+%d pointer", (e.flags & _VtEntryDir) ? "BtDir" : "BtData", e.depth),
                        ptrgen, copyEntry(e));
    }

    /*
     * wrap the contents of the Source in a Source node,
     * just so it's closer to what you see in the code.
     */
    if(dowrap) {
        t = stringnode("Source");
        t->nkid = 1;
        t->kid = mallocz(sizeof(Tnode*)*1, 1);
        t->kid[0] = tt;
        tt = t;
    }
    return tt;
}
Example #9
0
Tnode*
initxheader(void)
{
    u8int buf[HeaderSize];
    Tnode *t;

    if(pread(fd, buf, HeaderSize, HeaderOffset) < HeaderSize)
        return stringnode("error reading header: %r");
    if(!headerUnpack(&h, buf))
        return stringnode("error unpacking header: %r");

    t = stringnode("header "
                   "version=%#ux (%d) "
                   "blockSize=%#ux (%d) "
                   "super=%#lux (%ld) "
                   "label=%#lux (%ld) "
                   "data=%#lux (%ld) "
                   "end=%#lux (%ld)",
                   h.version, h.version, h.blockSize, h.blockSize,
                   h.super, h.super,
                   h.label, h.label, h.data, h.data, h.end, h.end);
    t->expand = xheaderexpand;
    return t;
}
Example #10
0
int
metaentrygen(void *v, Block *b, int o, Tnode **tp)
{
    Tnode *t;
    MetaBlock *mb;
    MetaEntry me;

    mb = v;
    if(o >= mb->nindex)
        return -1;
    meUnpack(&me, mb, o);

    t = stringnode("MetaEntry %d bytes", mb->size);
    t->kid = mallocz(sizeof(t->kid[0])*1, 1);
    t->kid[0] = initxdirentry(&me);
    t->nkid = 1;
    *tp = t;
    return 1;
}
Example #11
0
Tnode*
initxlabel(Label l)
{
    return stringnode("label type=%s state=%s epoch=%#ux tag=%#ux",
                      btStr(l.type), bsStr(l.state), l.epoch, l.tag);
}