diff options
author | ethersphere <thesw@rm.eth> | 2018-06-20 20:06:27 +0800 |
---|---|---|
committer | ethersphere <thesw@rm.eth> | 2018-06-22 03:10:31 +0800 |
commit | e187711c6545487d4cac3701f0f506bb536234e2 (patch) | |
tree | d2f6150f70b84b36e49a449082aeda267b4b9046 /swarm/fuse/fuse_dir.go | |
parent | 574378edb50c907b532946a1d4654dbd6701b20a (diff) | |
download | go-tangerine-e187711c6545487d4cac3701f0f506bb536234e2.tar go-tangerine-e187711c6545487d4cac3701f0f506bb536234e2.tar.gz go-tangerine-e187711c6545487d4cac3701f0f506bb536234e2.tar.bz2 go-tangerine-e187711c6545487d4cac3701f0f506bb536234e2.tar.lz go-tangerine-e187711c6545487d4cac3701f0f506bb536234e2.tar.xz go-tangerine-e187711c6545487d4cac3701f0f506bb536234e2.tar.zst go-tangerine-e187711c6545487d4cac3701f0f506bb536234e2.zip |
swarm: network rewrite merge
Diffstat (limited to 'swarm/fuse/fuse_dir.go')
-rw-r--r-- | swarm/fuse/fuse_dir.go | 15 |
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 - } |