aboutsummaryrefslogtreecommitdiff
path: root/src/libfs/open.c
blob: 458c5dac3dc0fbb80a934984540cea2d8b402e0b (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
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <fs.h>
#include "fsimpl.h"

Fid*
fsopen(Fsys *fs, char *name, int mode)
{
	Fid *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){
		fsclose(fid);
		return nil;
	}
	fid->mode = mode;
	return fid;
}