aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-09-05 20:11:20 +0200
committerJakob Unterwurzacher2015-09-05 20:11:20 +0200
commit7e564f928fef80b0485210603a8aa58b14ca5109 (patch)
treee011e362d47ae35bf55cc7709a8b47017ec51cca /frontend
parent199d3fd79ff03222cf7498418b40e1263f8aa104 (diff)
Fix size reporting
Diffstat (limited to 'frontend')
-rw-r--r--frontend/checks.go31
-rw-r--r--frontend/dir.go8
-rw-r--r--frontend/file.go20
-rw-r--r--frontend/node.go17
4 files changed, 51 insertions, 25 deletions
diff --git a/frontend/checks.go b/frontend/checks.go
new file mode 100644
index 0000000..30720f6
--- /dev/null
+++ b/frontend/checks.go
@@ -0,0 +1,31 @@
+package frontend
+
+import (
+ "bazil.org/fuse/fs"
+)
+
+// Compile-time interface checks.
+var _ fs.FS = (*FS)(nil)
+var _ fs.FSStatfser = (*FS)(nil)
+
+var _ fs.Node = (*Dir)(nil)
+var _ fs.NodeCreater = (*Dir)(nil)
+var _ fs.NodeMkdirer = (*Dir)(nil)
+var _ fs.NodeRemover = (*Dir)(nil)
+var _ fs.NodeRenamer = (*Dir)(nil)
+var _ fs.HandleReadDirAller = (*Dir)(nil)
+
+var _ fs.HandleReader = (*File)(nil)
+var _ fs.HandleWriter = (*File)(nil)
+var _ fs.Node = (*File)(nil)
+var _ fs.NodeOpener = (*File)(nil)
+var _ fs.NodeSetattrer = (*File)(nil)
+
+func foo(h fs.HandleReadDirAller) {
+
+}
+
+func init() {
+ var d Dir
+ foo(&d)
+}
diff --git a/frontend/dir.go b/frontend/dir.go
index 46be0db..ee5c474 100644
--- a/frontend/dir.go
+++ b/frontend/dir.go
@@ -11,6 +11,7 @@ import (
type Dir struct {
*cluefs.Dir
+
crfs *cryptfs.CryptFS
}
@@ -39,18 +40,19 @@ func (d *Dir) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenRe
func (d *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fusefs.Node, error) {
fmt.Printf("Lookup %s\n", req.Name)
req.Name = d.crfs.EncryptPath(req.Name)
- n, err := d.Dir.Lookup(ctx, req, resp)
+ node, err := d.Dir.Lookup(ctx, req, resp)
if err != nil {
return nil, err
}
- clueDir, ok := n.(*cluefs.Dir)
+ clueDir, ok := node.(*cluefs.Dir)
if ok {
return &Dir {
Dir: clueDir,
crfs: d.crfs,
}, nil
} else {
- clueFile := n.(*cluefs.File)
+ resp.Attr.Size = d.crfs.PlainSize(resp.Attr.Size)
+ clueFile := node.(*cluefs.File)
return &File {
File: clueFile,
crfs: d.crfs,
diff --git a/frontend/file.go b/frontend/file.go
index 8014753..ef74491 100644
--- a/frontend/file.go
+++ b/frontend/file.go
@@ -56,12 +56,12 @@ func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenR
}
func (f *File) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error {
- iblocks := f.crfs.SplitRange(req.Offset, int64(req.Size))
+ iblocks := f.crfs.SplitRange(uint64(req.Offset), uint64(req.Size))
for _, ib := range iblocks {
var partReq fuse.ReadRequest
var partResp fuse.ReadResponse
o, l := ib.CiphertextRange()
- partReq.Offset = o
+ partReq.Offset = int64(o)
partReq.Size = int(l)
partResp.Data = make([]byte, int(l))
err := f.File.Read(ctx, &partReq, &partResp)
@@ -82,7 +82,7 @@ func (f *File) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadR
func (f *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error {
fmt.Printf("File.Write\n")
resp.Size = 0
- iblocks := f.crfs.SplitRange(req.Offset, int64(len(req.Data)))
+ iblocks := f.crfs.SplitRange(uint64(req.Offset), uint64(len(req.Data)))
var blockData []byte
for _, ib := range iblocks {
if ib.IsPartial() {
@@ -91,7 +91,7 @@ func (f *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.Wri
var readReq fuse.ReadRequest
var readResp fuse.ReadResponse
o, l := ib.PlaintextRange()
- readReq.Offset = o
+ readReq.Offset = int64(o)
readReq.Size = int(l)
err := f.Read(ctx, &readReq, &readResp)
if err != nil {
@@ -109,7 +109,7 @@ func (f *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.Wri
var partResp fuse.WriteResponse
o, _ := ib.CiphertextRange()
partReq.Data = ciphertext
- partReq.Offset = o
+ partReq.Offset = int64(o)
err := f.File.Write(ctx, &partReq, &partResp)
if err != nil {
fmt.Printf("Write failure: %s\n", err.Error())
@@ -121,3 +121,13 @@ func (f *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.Wri
}
return nil
}
+
+func (f *File) Attr(ctx context.Context, attr *fuse.Attr) error {
+ fmt.Printf("Attr\n")
+ err := f.File.Node.Attr(ctx, attr)
+ if err != nil {
+ return err
+ }
+ attr.Size = f.crfs.PlainSize(attr.Size)
+ return nil
+}
diff --git a/frontend/node.go b/frontend/node.go
deleted file mode 100644
index f9b630c..0000000
--- a/frontend/node.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package frontend
-
-import (
- "fmt"
- "github.com/rfjakob/cluefs/lib/cluefs"
-)
-
-type Node struct {
- *cluefs.Node
-}
-
-func NewNode(parent string, name string, fs *FS) *Node {
- fmt.Printf("NewNode\n")
- return &Node{
- Node: cluefs.NewNode(parent, name, fs.ClueFS),
- }
-}