From d7a1eb7e30a4e38577bc1351b7e2e82a337316fb Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Thu, 29 Mar 2018 14:39:13 -0700 Subject: [PATCH] first two syscalls, now to start client --- filesystem.go | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/filesystem.go b/filesystem.go index 594da05..4ff787c 100644 --- a/filesystem.go +++ b/filesystem.go @@ -1,6 +1,10 @@ package kubelwagen -import "github.com/hanwen/go-fuse/fuse/pathfs" +import ( + "github.com/hanwen/go-fuse/fuse" + "github.com/hanwen/go-fuse/fuse/pathfs" + "github.com/sirupsen/logrus" +) type WsFs struct { pathfs.FileSystem @@ -33,3 +37,40 @@ func getChannel() chan Response { func (fs *WsFs) String() string { return "kubelwagen" } + +func (fs *WsFs) OpenDir(name string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { + r := Request{ + Method: MethodOpenDir, + Path: name, + } + c := getChannel() + fs.req <- RequestCallback{ + message: r, + response: c, + } + resp, ok := <-c + if !ok { + logrus.Errorln("Response to request channel closed") + return fs.FileSystem.OpenDir(name, context) + } + return resp.Dirents, resp.Code +} + +func (fs *WsFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { + r := Request{ + Method: MethodGetAttr, + Path: name, + } + c := getChannel() + fs.req <- RequestCallback{ + message: r, + response: c, + } + resp, ok := <-c + if !ok { + logrus.Errorln("Response to request channel closed") + return fs.FileSystem.GetAttr(name, context) + } + return resp.Stat, resp.Code + +}