open: preserve error on failed open

write: handle offset correctly for fswrite
This commit is contained in:
rsc 2005-03-01 20:56:27 +00:00
parent 6c78172831
commit c31f81ac8b
2 changed files with 4 additions and 1 deletions

View file

@ -7,6 +7,7 @@
CFid* CFid*
fsopen(CFsys *fs, char *name, int mode) fsopen(CFsys *fs, char *name, int mode)
{ {
char e[ERRMAX];
CFid *fid; CFid *fid;
Fcall tx, rx; Fcall tx, rx;
@ -16,7 +17,9 @@ fsopen(CFsys *fs, char *name, int mode)
tx.fid = fid->fid; tx.fid = fid->fid;
tx.mode = mode; tx.mode = mode;
if(_fsrpc(fs, &tx, &rx, 0) < 0){ if(_fsrpc(fs, &tx, &rx, 0) < 0){
rerrstr(e, sizeof e);
fsclose(fid); fsclose(fid);
errstr(e, sizeof e);
return nil; return nil;
} }
fid->mode = mode; fid->mode = mode;

View file

@ -53,7 +53,7 @@ fspwrite(CFid *fid, void *buf, long n, vlong offset)
want = n - tot; want = n - tot;
if(want > msize) if(want > msize)
want = msize; want = msize;
got = _fspwrite(fid, buf, want, offset); got = _fspwrite(fid, buf+tot, want, offset);
first = 0; first = 0;
if(got < 0){ if(got < 0){
if(tot == 0) if(tot == 0)