Annotation of researchv10no/cmd/u9fs/mfmt.c, revision 1.1.1.1

1.1       root        1: #include "u.h"
                      2: #include <sys/types.h>
                      3: #include <sys/stat.h>
                      4: #include "libc.h"
                      5: #include "9p.h"
                      6: #include "stdio.h"
                      7: 
                      8: 
                      9: void   error(char*);
                     10: 
                     11: struct{
                     12:        int     type;
                     13:        char    *name;
                     14: }mname[] = {
                     15:        Tnop,           "Tnop",
                     16:        Rnop,           "Rnop",
                     17:        Tsession,       "Tsession",
                     18:        Rsession,       "Rsession",
                     19:        Terror,         "Terror",
                     20:        Rerror,         "Rerror",
                     21:        Tflush,         "Tflush",
                     22:        Rflush,         "Rflush",
                     23:        Tattach,        "Tattach",
                     24:        Rattach,        "Rattach",
                     25:        Tclone,         "Tclone",
                     26:        Rclone,         "Rclone",
                     27:        Twalk,          "Twalk",
                     28:        Rwalk,          "Rwalk",
                     29:        Topen,          "Topen",
                     30:        Ropen,          "Ropen",
                     31:        Tcreate,        "Tcreate",
                     32:        Rcreate,        "Rcreate",
                     33:        Tread,          "Tread",
                     34:        Rread,          "Rread",
                     35:        Twrite,         "Twrite",
                     36:        Rwrite,         "Rwrite",
                     37:        Tclunk,         "Tclunk",
                     38:        Rclunk,         "Rclunk",
                     39:        Tremove,        "Tremove",
                     40:        Rremove,        "Rremove",
                     41:        Tstat,          "Tstat",
                     42:        Rstat,          "Rstat",
                     43:        Twstat,         "Twstat",
                     44:        Rwstat,         "Rwstat",
                     45:        Tclwalk,        "Tclwalk",
                     46:        Rclwalk,        "Rclwalk",
                     47:        0,              0
                     48: };
                     49: 
                     50: char*
                     51: mfmt(Fcall *f)
                     52: {
                     53:        int i;
                     54:        char *n;
                     55:        static char buf[512];
                     56: 
                     57:        for(i=0; mname[i].name; i++)
                     58:                if(f->type == mname[i].type){
                     59:                        strcpy(buf, mname[i].name);
                     60:                        n = buf+strlen(buf);
                     61:                        switch(f->type){
                     62:                        case Tnop:
                     63:                        case Rnop:
                     64:                        case Tsession:
                     65:                        case Rsession:
                     66:                        case Terror:
                     67:                        case Rflush:
                     68:                                break;
                     69:                        case Rerror:
                     70:                                sprintf(n, " tag %d ename %s", f->tag, f->ename);
                     71:                                break;
                     72:                        case Tflush:
                     73:                                sprintf(n, " tag %d oldtag %d", f->tag, f->oldtag);
                     74:                                break;
                     75:                        case Tattach:
                     76:                                sprintf(n, " tag %d fid %d uname %s aname %s auth %s",
                     77:                                        f->tag, f->fid, f->uname, f->aname, f->auth);
                     78:                                break;
                     79:                        case Rattach:
                     80:                        case Rwalk:
                     81:                        case Rclwalk:
                     82:                        case Ropen:
                     83:                        case Rcreate:
                     84:                                sprintf(n, " tag %d fid %d qid 0x%x.0x%x",
                     85:                                        f->tag, f->fid, f->qid.path, f->qid.vers);
                     86:                                break;
                     87:                        case Tclone:
                     88:                                sprintf(n, " tag %d fid %d newfid %d",
                     89:                                        f->tag, f->fid, f->newfid);
                     90:                                break;
                     91:                        case Twalk:
                     92:                                sprintf(n, " tag %d fid %d name %s", f->tag, f->fid, f->name);
                     93:                                break;
                     94:                        case Topen:
                     95:                                sprintf(n, " tag %d fid %d mode 0x%x",
                     96:                                        f->tag, f->fid, f->mode);
                     97:                                break;
                     98:                        case Tcreate:
                     99:                                sprintf(n, " tag %d fid %d name %s perm 0x%x mode 0x%x",
                    100:                                        f->tag, f->fid, f->name, f->perm, f->mode);
                    101:                                break;
                    102:                        case Tread:
                    103:                                sprintf(n, " tag %d fid %d offset %ld count %ld",
                    104:                                        f->tag, f->fid, f->offset, f->count);
                    105:                                break;
                    106:                        case Rread:
                    107:                                sprintf(n, " tag %d fid %d count %ld +data...",
                    108:                                        f->tag, f->fid, f->count);
                    109:                                break;
                    110:                        case Twrite:
                    111:                                sprintf(n, " tag %d fid %d offset %ld count %ld +data...",
                    112:                                        f->tag, f->fid, f->offset, f->count);
                    113:                                break;
                    114:                        case Rwrite:
                    115:                                sprintf(n, " tag %d fid %d count %ld",
                    116:                                        f->tag, f->fid, f->count);
                    117:                                break;
                    118:                        case Tclunk:
                    119:                        case Rclunk:
                    120:                        case Rremove:
                    121:                        case Rwstat:
                    122:                        case Rclone:
                    123:                        case Tremove:
                    124:                        case Tstat:
                    125:                                sprintf(n, " tag %d fid %d", f->tag, f->fid);
                    126:                                break;
                    127:                        case Rstat:
                    128:                        case Twstat:
                    129:                                sprintf(n, " tag %d fid %d + dir", f->tag, f->fid);
                    130:                                break;
                    131:                        case Tclwalk:
                    132:                                sprintf(n, " tag %d fid %d newfid %d name %s",
                    133:                                        f->tag, f->fid, f->newfid, f->name);
                    134:                                break;
                    135:                        default:
                    136:                                error("mfmt");
                    137:                        }
                    138:                        return buf;
                    139:                }
                    140:        sprintf(buf, "mtype 0x%x", f->type);
                    141:        return buf;
                    142: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.