diff -ru wmii.org/fs.c wmii.u/fs.c --- wmii.org/fs.c 2006-10-30 10:00:06.000000000 +0100 +++ wmii.u/fs.c 2006-11-22 23:36:20.832871750 +0100 @@ -175,15 +175,15 @@ /* This should be moved to libixp */ static void write_buf(P9Req *r, void *buf, unsigned int len) { - if(r->ifcall.offset >= len) + if(r->ifcall.data.twrite.offset >= len) return; - len -= r->ifcall.offset; - if(len > r->ifcall.count) - len = r->ifcall.count; - r->ofcall.data = ixp_emalloc(len); - memcpy(r->ofcall.data, buf + r->ifcall.offset, len); - r->ofcall.count = len; + len -= r->ifcall.data.twrite.offset; + if(len > r->ifcall.data.twrite.count) + len = r->ifcall.data.twrite.count; + r->ofcall.data.rwrite.data = ixp_emalloc(len); + memcpy(r->ofcall.data.rwrite.data, buf + r->ifcall.data.twrite.offset, len); + r->ofcall.data.rwrite.count = len; } /* This should be moved to libixp */ @@ -191,13 +191,13 @@ write_to_buf(P9Req *r, void *buf, unsigned int *len, unsigned int max) { unsigned int offset, count; - offset = (r->fid->omode&P9OAPPEND) ? *len : r->ifcall.offset; - if(offset > *len || r->ifcall.count == 0) { - r->ofcall.count = 0; + offset = (r->fid->omode&P9OAPPEND) ? *len : r->ifcall.data.twrite.offset; + if(offset > *len || r->ifcall.data.twrite.count == 0) { + r->ofcall.data.rwrite.count = 0; return; } - count = r->ifcall.count; + count = r->ifcall.data.twrite.count; if(max && (count > max - offset)) count = max - offset; @@ -208,8 +208,8 @@ buf = *(void **)buf; } - memcpy(buf + offset, r->ifcall.data, count); - r->ofcall.count = count; + memcpy(buf + offset, r->ifcall.data.rwrite.data, count); + r->ofcall.data.rwrite.count = count; ((char *)buf)[offset+count] = '\0'; } @@ -217,11 +217,11 @@ void data_to_cstring(P9Req *r) { unsigned int i; - i = r->ifcall.count; - if(!i || r->ifcall.data[i - 1] != '\n') - r->ifcall.data = ixp_erealloc(r->ifcall.data, ++i); - assert(r->ifcall.data); - r->ifcall.data[i - 1] = '\0'; + i = r->ifcall.data.twrite.count; + if(!i || r->ifcall.data.twrite.data[i - 1] != '\n') + r->ifcall.data.twrite.data = ixp_erealloc(r->ifcall.data.twrite.data, ++i); + assert(r->ifcall.data.twrite.data); + r->ifcall.data.twrite.data[i - 1] = '\0'; } /* This should be moved to liblitz */ @@ -327,8 +327,8 @@ respond_event(P9Req *r) { FileId *f = r->fid->aux; if((char*)f->ref) { - r->ofcall.data = f->ref; - r->ofcall.count = strlen((char*)f->ref); + r->ofcall.data.rread.data = f->ref; + r->ofcall.data.rread.count = strlen((char*)f->ref); respond(r, NULL); f->ref = NULL; }else{ @@ -521,7 +521,7 @@ r->fid->aux = f; r->fid->qid.type = f->tab.qtype; r->fid->qid.path = QID(f->tab.type, 0); - r->ofcall.qid = r->fid->qid; + r->ofcall.data.rattach.qid = r->fid->qid; respond(r, NULL); } @@ -532,28 +532,28 @@ f = r->fid->aux; clone_files(f); - for(i=0; i < r->ifcall.nwname; i++) { - if(!strncmp(r->ifcall.wname[i], "..", 3)) { + for(i=0; i < r->ifcall.data.twalk.nwname; i++) { + if(!strncmp(r->ifcall.data.twalk.wname[i], "..", 3)) { if(f->next) { nf=f; f=f->next; free_file(nf); } }else{ - nf = lookup_file(f, r->ifcall.wname[i]); + nf = lookup_file(f, r->ifcall.data.twalk.wname[i]); if(!nf) break; assert(!nf->next); - if(strncmp(r->ifcall.wname[i], ".", 2)) { + if(strncmp(r->ifcall.data.twalk.wname[i], ".", 2)) { nf->next = f; f = nf; } } - r->ofcall.wqid[i].type = f->tab.qtype; - r->ofcall.wqid[i].path = QID(f->tab.type, f->id); + r->ofcall.data.rwalk.wqid[i].type = f->tab.qtype; + r->ofcall.data.rwalk.wqid[i].path = QID(f->tab.type, f->id); } /* There should be a way to do this on freefid() */ - if(i < r->ifcall.nwname) { + if(i < r->ifcall.data.twalk.nwname) { while((nf = f)) { f=f->next; free_file(nf); @@ -564,7 +564,7 @@ /* Remove refs for r->fid if no new fid */ /* If Fids were ref counted, this could be * done in their decref function */ - if(r->ifcall.fid == r->ifcall.newfid) { + if(r->ifcall.fid == r->ifcall.data.twalk.newfid) { nf=r->fid->aux; r->fid->aux = f; while((nf = f)) { @@ -573,7 +573,7 @@ } } r->newfid->aux = f; - r->ofcall.nwqid = i; + r->ofcall.data.rwalk.nwqid = i; respond(r, NULL); } @@ -601,9 +601,9 @@ unsigned char *buf; dostat(&s, fs_size(r->fid->aux), r->fid->aux); - r->ofcall.nstat = size = ixp_sizeof_stat(&s); + r->ofcall.data.rstat.nstat = size = ixp_sizeof_stat(&s); buf = ixp_emallocz(size); - r->ofcall.stat = buf; + r->ofcall.data.rstat.stat = buf; ixp_pack_stat(&buf, &size, &s); respond(r, NULL); } @@ -620,15 +620,15 @@ if(f->tab.perm & P9DMDIR && f->tab.perm & 0400) { Stat s; offset = 0; - size = r->ifcall.count; + size = r->ifcall.data.tread.count; buf = ixp_emallocz(size); - r->ofcall.data = buf; + r->ofcall.data.rread.data = buf; tf = f = lookup_file(f, NULL); /* Note: f->tab.name == "." so we skip it */ for(f=f->next; f; f=f->next) { dostat(&s, fs_size(f), f); n = ixp_sizeof_stat(&s); - if(offset >= r->ifcall.offset) { + if(offset >= r->ifcall.data.tread.offset) { if(size < n) break; ixp_pack_stat((unsigned char **)&buf, &size, &s); @@ -639,7 +639,7 @@ tf=tf->next; free_file(f); } - r->ofcall.count = r->ifcall.count - size; + r->ofcall.data.rread.count = r->ifcall.data.tread.count - size; respond(r, NULL); return; } @@ -676,14 +676,14 @@ respond(r, NULL); return; case FsFCctl: - if(r->ifcall.offset) { + if(r->ifcall.data.tread.offset) { respond(r, NULL); return; } - r->ofcall.data = ixp_emallocz(16); - n = snprintf(r->ofcall.data, 16, "%d", f->index); + r->ofcall.data.rread.data = ixp_emallocz(16); + n = snprintf(r->ofcall.data.rread.data, 16, "%d", f->index); assert(n >= 0); - r->ofcall.count = n; + r->ofcall.data.rread.count = n; respond(r, NULL); return; case FsFTindex: @@ -709,7 +709,7 @@ char *errstr = NULL; unsigned int i; - if(r->ifcall.count == 0) { + if(r->ifcall.data.twrite.count == 0) { respond(r, NULL); return; } @@ -728,39 +728,39 @@ data_to_cstring(r); i=strlen(((Client*)f->ref)->tags); write_to_buf(r, &((Client*)f->ref)->tags, &i, 255); - r->ofcall.count = i- r->ifcall.offset; + r->ofcall.data.rwrite.count = i- r->ifcall.data.twrite.offset; respond(r, NULL); return; case FsFBar: /* XXX: This should validate after each write */ i = strlen(((Bar*)f->ref)->buf); write_to_buf(r, &((Bar*)f->ref)->buf, &i, 279); - r->ofcall.count = i - r->ifcall.offset; + r->ofcall.data.rwrite.count = i - r->ifcall.data.twrite.offset; respond(r, NULL); return; case FsFCctl: data_to_cstring(r); - if((errstr = message_client((Client*)f->ref, r->ifcall.data))) { + if((errstr = message_client((Client*)f->ref, r->ifcall.data.twrite.data))) { respond(r, errstr); return; } - r->ofcall.count = r->ifcall.count; + r->ofcall.data.rwrite.count = r->ifcall.data.twrite.count; respond(r, NULL); return; case FsFTctl: data_to_cstring(r); - if((errstr = message_view((View*)f->ref, r->ifcall.data))) { + if((errstr = message_view((View*)f->ref, r->ifcall.data.twrite.data))) { respond(r, errstr); return; } - r->ofcall.count = r->ifcall.count; + r->ofcall.data.rwrite.count = r->ifcall.data.twrite.count; respond(r, NULL); return; case FsFRctl: data_to_cstring(r); { unsigned int n; char *toks[32]; - n = ixp_tokenize(toks, 32, r->ifcall.data, '\n'); + n = ixp_tokenize(toks, 32, r->ifcall.data.twrite.data, '\n'); for(i = 0; i < n; i++) { if(errstr) message_root(toks[i]); @@ -772,15 +772,15 @@ respond(r, errstr); return; } - r->ofcall.count = r->ifcall.count; + r->ofcall.data.rwrite.count = r->ifcall.data.twrite.count; respond(r, NULL); return; case FsFEvent: - if(r->ifcall.data[r->ifcall.count-1] == '\n') - write_event("%.*s", r->ifcall.count, r->ifcall.data); + if(r->ifcall.data.twrite.data[r->ifcall.data.twrite.count-1] == '\n') + write_event("%.*s", r->ifcall.data.twrite.count, r->ifcall.data.twrite.data); else - write_event("%.*s\n", r->ifcall.count, r->ifcall.data); - r->ofcall.count = r->ifcall.count; + write_event("%.*s\n", r->ifcall.data.twrite.count, r->ifcall.data.twrite.data); + r->ofcall.data.rwrite.count = r->ifcall.data.twrite.count; respond(r, NULL); return; } @@ -802,19 +802,19 @@ pending_event_fids = fl; break; } - if((r->ifcall.mode&3) == P9OEXEC) { + if((r->ifcall.data.topen.mode&3) == P9OEXEC) { respond(r, Enoperm); return; } - if((r->ifcall.mode&3) != P9OREAD && !(f->tab.perm & 0200)) { + if((r->ifcall.data.topen.mode&3) != P9OREAD && !(f->tab.perm & 0200)) { respond(r, Enoperm); return; } - if((r->ifcall.mode&3) != P9OWRITE && !(f->tab.perm & 0400)) { + if((r->ifcall.data.topen.mode&3) != P9OWRITE && !(f->tab.perm & 0400)) { respond(r, Enoperm); return; } - if((r->ifcall.mode&~(3|P9OAPPEND|P9OTRUNC))) { + if((r->ifcall.data.topen.mode&~(3|P9OAPPEND|P9OTRUNC))) { respond(r, Enoperm); return; } @@ -831,18 +831,18 @@ respond(r, Enoperm); return; case FsDBars: - if(!strlen(r->ifcall.name)) { + if(!strlen(r->ifcall.data.tcreate.name)) { respond(r, Ebadvalue); return; } - create_bar((Bar**)f->ref, r->ifcall.name); - f = lookup_file(f, r->ifcall.name); + create_bar((Bar**)f->ref, r->ifcall.data.tcreate.name); + f = lookup_file(f, r->ifcall.data.tcreate.name); if(!f) { respond(r, Enofile); return; } - r->ofcall.qid.type = f->tab.qtype; - r->ofcall.qid.path = QID(f->tab.type, f->id); + r->ofcall.data.rcreate.qid.type = f->tab.qtype; + r->ofcall.data.rcreate.qid.path = QID(f->tab.type, f->id); f->next = r->fid->aux; r->fid->aux = f; respond(r, NULL);