Fixed some bugs.

This commit is contained in:
Kris Maglione 2007-03-26 17:21:05 -04:00
parent f758fba726
commit 983f1baa16
2 changed files with 7 additions and 7 deletions

View File

@ -515,7 +515,7 @@ fs_attach(Ixp9Req *r) {
FileId *f = get_file();
f->tab = dirtab[FsRoot][0];
f->tab.name = estrdup("/");
f->content.ref = nil; /* shut up valgrind */
f->content.ref = nil;
r->fid->aux = f;
r->fid->qid.type = f->tab.qtype;
r->fid->qid.path = QID(f->tab.type, 0);

View File

@ -22,18 +22,18 @@ usage() {
/* Utility Functions */
static void
write_data(IxpCFid *fid) {
write_data(IxpCFid *fid, char *name) {
void *buf;
uint len;
buf = ixp_emalloc(fid->iounit);;
while((len = read(0, buf, fid->iounit)) > 0)
if(ixp_write(fid, buf, len) != len)
fatal("cannot write file: %s\n", errstr);
fatal("cannot write file '%s': %s\n", name, errstr);
/* do an explicit empty write when no writing has been done yet */
if(fid->offset == 0)
if(ixp_write(fid, buf, 0) != 0)
fatal("cannot write file: %s\n", errstr);
fatal("cannot write file '%s': %s\n", name, errstr);
free(buf);
}
@ -109,7 +109,7 @@ xwrite(int argc, char *argv[]) {
if(fid == nil)
fatal("Can't open file '%s': %s\n", file, errstr);
write_data(fid);
write_data(fid, file);
return 0;
}
@ -161,12 +161,12 @@ xcreate(int argc, char *argv[]) {
}ARGEND;
file = EARGF(usage());
fid = ixp_create(client, file, 0777, P9_OREAD);
fid = ixp_create(client, file, 0777, P9_OWRITE);
if(fid == nil)
fatal("Can't create file '%s': %s\n", file, errstr);
if((fid->qid.type&P9_DMDIR) == 0)
write_data(fid);
write_data(fid, file);
return 0;
}