5 static uint dumpsome(char*, char*, char*, long);
6 static void fdirconv(char*, char*, Dir*);
7 static char *qidtype(char*, uchar);
9 #define QIDFMT "(%.16llux %lud %s)"
15 int fid, type, tag, i;
16 char buf[512], tmp[200];
22 f = va_arg(fmt->args, Fcall*);
27 case Tversion: /* 100 */
28 seprint(buf, e, "Tversion tag %ud msize %ud version '%s'", tag, f->msize, f->version);
31 seprint(buf, e, "Rversion tag %ud msize %ud version '%s'", tag, f->msize, f->version);
34 seprint(buf, e, "Tauth tag %ud afid %d uname %s aname %s", tag,
35 f->afid, f->uname, f->aname);
38 seprint(buf, e, "Rauth tag %ud qid " QIDFMT, tag,
39 f->aqid.path, f->aqid.vers, qidtype(tmp, f->aqid.type));
41 case Tattach: /* 104 */
42 seprint(buf, e, "Tattach tag %ud fid %d afid %d uname %s aname %s", tag,
43 fid, f->afid, f->uname, f->aname);
46 seprint(buf, e, "Rattach tag %ud qid " QIDFMT, tag,
47 f->qid.path, f->qid.vers, qidtype(tmp, f->qid.type));
49 case Rerror: /* 107; 106 (Terror) illegal */
50 seprint(buf, e, "Rerror tag %ud ename %s", tag, f->ename);
52 case Tflush: /* 108 */
53 seprint(buf, e, "Tflush tag %ud oldtag %ud", tag, f->oldtag);
56 seprint(buf, e, "Rflush tag %ud", tag);
59 p = seprint(buf, e, "Twalk tag %ud fid %d newfid %d nwname %d ", tag, fid, f->newfid, f->nwname);
60 if(f->nwname <= MAXWELEM)
61 for(i=0; i<f->nwname; i++)
62 p = seprint(p, e, "%d:%s ", i, f->wname[i]);
65 p = seprint(buf, e, "Rwalk tag %ud nwqid %ud ", tag, f->nwqid);
66 if(f->nwqid <= MAXWELEM)
67 for(i=0; i<f->nwqid; i++){
69 p = seprint(p, e, "%d:" QIDFMT " ", i,
70 q->path, q->vers, qidtype(tmp, q->type));
74 seprint(buf, e, "Topen tag %ud fid %ud mode %d", tag, fid, f->mode);
77 seprint(buf, e, "Ropen tag %ud qid " QIDFMT " iounit %ud", tag,
78 f->qid.path, f->qid.vers, qidtype(tmp, f->qid.type), f->iounit);
80 case Topenfd: /* 98 */
81 seprint(buf, e, "Topenfd tag %ud fid %ud mode %d", tag, fid, f->mode);
84 seprint(buf, e, "Ropenfd tag %ud qid " QIDFMT " iounit %ud unixfd %d", tag,
85 f->qid.path, f->qid.vers, qidtype(tmp, f->qid.type), f->iounit, f->unixfd);
87 case Tcreate: /* 114 */
88 seprint(buf, e, "Tcreate tag %ud fid %ud name %s perm %M mode %d", tag, fid, f->name, (ulong)f->perm, f->mode);
91 seprint(buf, e, "Rcreate tag %ud qid " QIDFMT " iounit %ud ", tag,
92 f->qid.path, f->qid.vers, qidtype(tmp, f->qid.type), f->iounit);
95 seprint(buf, e, "Tread tag %ud fid %d offset %lld count %ud",
96 tag, fid, f->offset, f->count);
99 p = seprint(buf, e, "Rread tag %ud count %ud ", tag, f->count);
100 dumpsome(p, e, f->data, f->count);
102 case Twrite: /* 118 */
103 p = seprint(buf, e, "Twrite tag %ud fid %d offset %lld count %ud ",
104 tag, fid, f->offset, f->count);
105 dumpsome(p, e, f->data, f->count);
108 seprint(buf, e, "Rwrite tag %ud count %ud", tag, f->count);
110 case Tclunk: /* 120 */
111 seprint(buf, e, "Tclunk tag %ud fid %ud", tag, fid);
114 seprint(buf, e, "Rclunk tag %ud", tag);
116 case Tremove: /* 122 */
117 seprint(buf, e, "Tremove tag %ud fid %ud", tag, fid);
120 seprint(buf, e, "Rremove tag %ud", tag);
122 case Tstat: /* 124 */
123 seprint(buf, e, "Tstat tag %ud fid %ud", tag, fid);
126 p = seprint(buf, e, "Rstat tag %ud ", tag);
127 if(f->nstat > sizeof tmp)
128 seprint(p, e, " stat(%d bytes)", f->nstat);
131 convM2D(f->stat, f->nstat, d, (char*)(d+1));
132 seprint(p, e, " stat ");
136 case Twstat: /* 126 */
137 p = seprint(buf, e, "Twstat tag %ud fid %ud", tag, fid);
138 if(f->nstat > sizeof tmp)
139 seprint(p, e, " stat(%d bytes)", f->nstat);
142 convM2D(f->stat, f->nstat, d, (char*)(d+1));
143 seprint(p, e, " stat ");
148 seprint(buf, e, "Rwstat tag %ud", tag);
151 seprint(buf, e, "unknown type %d", type);
153 return fmtstrcpy(fmt, buf);
157 qidtype(char *s, uchar t)
179 fdirconv(buf, buf+sizeof buf, va_arg(fmt->args, Dir*));
180 return fmtstrcpy(fmt, buf);
184 fdirconv(char *buf, char *e, Dir *d)
188 seprint(buf, e, "'%s' '%s' '%s' '%s' "
189 "q " QIDFMT " m %#luo "
190 "at %ld mt %ld l %lld "
192 d->name, d->uid, d->gid, d->muid,
193 d->qid.path, d->qid.vers, qidtype(tmp, d->qid.type), d->mode,
194 d->atime, d->mtime, d->length,
199 * dump out count (or DUMPL, if count is bigger) bytes from
200 * buf to ans, as a string if they are all printable,
201 * else as a series of hex bytes
206 dumpsome(char *ans, char *e, char *buf, long count)
212 seprint(ans, e, "<no data>");
218 for(i=0; i<count && printable; i++)
219 if((buf[i]<32 && buf[i] !='\n' && buf[i] !='\t') || (uchar)buf[i]>127)
226 memmove(p, buf, count);
231 for(i=0; i<count; i++){
234 sprint(p, "%2.2ux", buf[i]);