aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/fuse/fuse_dir.go
diff options
context:
space:
mode:
Diffstat (limited to 'swarm/fuse/fuse_dir.go')
-rw-r--r--swarm/fuse/fuse_dir.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/swarm/fuse/fuse_dir.go b/swarm/fuse/fuse_dir.go
index a7701985e..7f66451f1 100644
--- a/swarm/fuse/fuse_dir.go
+++ b/swarm/fuse/fuse_dir.go
@@ -25,6 +25,7 @@ import (
"bazil.org/fuse"
"bazil.org/fuse/fs"
+ "github.com/ethereum/go-ethereum/swarm/log"
"golang.org/x/net/context"
)
@@ -49,6 +50,7 @@ type SwarmDir struct {
}
func NewSwarmDir(fullpath string, minfo *MountInfo) *SwarmDir {
+ log.Debug("swarmfs", "NewSwarmDir", fullpath)
newdir := &SwarmDir{
inode: NewInode(),
name: filepath.Base(fullpath),
@@ -62,6 +64,8 @@ func NewSwarmDir(fullpath string, minfo *MountInfo) *SwarmDir {
}
func (sd *SwarmDir) Attr(ctx context.Context, a *fuse.Attr) error {
+ sd.lock.RLock()
+ defer sd.lock.RUnlock()
a.Inode = sd.inode
a.Mode = os.ModeDir | 0700
a.Uid = uint32(os.Getuid())
@@ -70,7 +74,7 @@ func (sd *SwarmDir) Attr(ctx context.Context, a *fuse.Attr) error {
}
func (sd *SwarmDir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fs.Node, error) {
-
+ log.Debug("swarmfs", "Lookup", req.Name)
for _, n := range sd.files {
if n.name == req.Name {
return n, nil
@@ -85,6 +89,7 @@ func (sd *SwarmDir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *f
}
func (sd *SwarmDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
+ log.Debug("swarmfs ReadDirAll")
var children []fuse.Dirent
for _, file := range sd.files {
children = append(children, fuse.Dirent{Inode: file.inode, Type: fuse.DT_File, Name: file.name})
@@ -96,6 +101,7 @@ func (sd *SwarmDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
}
func (sd *SwarmDir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error) {
+ log.Debug("swarmfs Create", "path", sd.path, "req.Name", req.Name)
newFile := NewSwarmFile(sd.path, req.Name, sd.mountInfo)
newFile.fileSize = 0 // 0 means, file is not in swarm yet and it is just created
@@ -108,6 +114,7 @@ func (sd *SwarmDir) Create(ctx context.Context, req *fuse.CreateRequest, resp *f
}
func (sd *SwarmDir) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
+ log.Debug("swarmfs Remove", "path", sd.path, "req.Name", req.Name)
if req.Dir && sd.directories != nil {
newDirs := []*SwarmDir{}
@@ -144,13 +151,11 @@ func (sd *SwarmDir) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
}
func (sd *SwarmDir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error) {
-
- newDir := NewSwarmDir(req.Name, sd.mountInfo)
-
+ log.Debug("swarmfs Mkdir", "path", sd.path, "req.Name", req.Name)
+ newDir := NewSwarmDir(filepath.Join(sd.path, req.Name), sd.mountInfo)
sd.lock.Lock()
defer sd.lock.Unlock()
sd.directories = append(sd.directories, newDir)
return newDir, nil
-
}