first two syscalls, now to start client

This commit is contained in:
Barak Michener 2018-03-29 14:39:13 -07:00
parent 869999fc3e
commit d7a1eb7e30

View file

@ -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
}