plan9port/src/lib9pclient/open.c

28 lines
449 B
C
Raw Normal View History

2005-01-04 21:22:40 +00:00
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9pclient.h>
#include "fsimpl.h"
CFid*
fsopen(CFsys *fs, char *name, int mode)
{
char e[ERRMAX];
2005-01-04 21:22:40 +00:00
CFid *fid;
Fcall tx, rx;
if((fid = _fswalk(fs->root, name)) == nil)
return nil;
tx.type = Topen;
tx.fid = fid->fid;
tx.mode = mode;
if(_fsrpc(fs, &tx, &rx, 0) < 0){
rerrstr(e, sizeof e);
2005-01-04 21:22:40 +00:00
fsclose(fid);
errstr(e, sizeof e);
2005-01-04 21:22:40 +00:00
return nil;
}
fid->mode = mode;
return fid;
}