aboutsummaryrefslogtreecommitdiff
path: root/src/lib9pclient/create.c
blob: cbb4a3acc340864b134984c361d31090ad6d7667 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9pclient.h>
#include "fsimpl.h"

CFid*
fscreate(CFsys *fs, char *name, int mode, ulong perm)
{
	CFid *fid;
	Fcall tx, rx;

	if((fid = _fswalk(fs->root, name)) == nil)
		return nil;
	tx.type = Tcreate;
	tx.fid = fid->fid;
	tx.mode = mode;
	tx.perm = perm;
	if(_fsrpc(fs, &tx, &rx, 0) < 0){
		fsclose(fid);
		return nil;
	}
	fid->mode = mode;
	return fid;
}