Blob
1 #include <u.h>2 #include <libc.h>3 #include <fcall.h>4 #include <9pclient.h>5 #include "fsimpl.h"7 int8 fsfopen(CFid *fid, int mode)9 {10 Fcall tx, rx;12 tx.type = Topen;13 tx.fid = fid->fid;14 tx.mode = mode;15 if(_fsrpc(fid->fs, &tx, &rx, 0) < 0)16 return -1;17 fid->mode = mode;18 return 0;19 }21 CFid*22 fsopen(CFsys *fs, char *name, int mode)23 {24 char e[ERRMAX];25 CFid *fid;27 if((fid = fswalk(fs->root, name)) == nil)28 return nil;29 if(fsfopen(fid, mode) < 0){30 rerrstr(e, sizeof e);31 fsclose(fid);32 errstr(e, sizeof e);33 return nil;34 }35 fid->mode = mode;36 return fid;37 }