diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2018-05-05 14:12:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-05 14:12:51 -0700 |
| commit | 4d5e1e5947e3a515cb4a6010f7ac49e3a6ab52dc (patch) | |
| tree | f6c90bfa2bac3491cc853113e686a9c0da83d773 /weed/command/mount_std.go | |
| parent | 94a35f25f35e992eab10beae124e76fcec21c3a1 (diff) | |
| parent | 7f49514f6fad19b70d955f8ad94fa7eae4e45edf (diff) | |
| download | seaweedfs-4d5e1e5947e3a515cb4a6010f7ac49e3a6ab52dc.tar.xz seaweedfs-4d5e1e5947e3a515cb4a6010f7ac49e3a6ab52dc.zip | |
Merge pull request #645 from chrislusf/vasto_filer
merge back filer related refactoring
Diffstat (limited to 'weed/command/mount_std.go')
| -rw-r--r-- | weed/command/mount_std.go | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index 0c36e488f..ef962e15b 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -59,27 +59,27 @@ func (WFS) Root() (fs.Node, error) { var fileIdMap = make(map[uint64]filer.FileId) type Dir struct { - Id uint64 Path string DirentMap map[string]*fuse.Dirent } func (dir *Dir) Attr(context context.Context, attr *fuse.Attr) error { - attr.Inode = dir.Id attr.Mode = os.ModeDir | 0555 return nil } func (dir *Dir) Lookup(ctx context.Context, name string) (fs.Node, error) { - if dirent, ok := dir.DirentMap[name]; ok { - if dirent.Type == fuse.DT_File { - return &File{Id: dirent.Inode, FileId: fileIdMap[dirent.Inode], Name: dirent.Name}, nil + if entry, err := filer.LookupDirectoryEntry(*mountOptions.filer, dir.Path, name); err == nil { + if !entry.Found { + return nil, fuse.ENOENT + } + if entry.FileId != "" { + return &File{FileId: filer.FileId(entry.FileId), Name: name}, nil + } else { + return &Dir{Path: path.Join(dir.Path, name)}, nil } - return &Dir{ - Id: dirent.Inode, - Path: path.Join(dir.Path, dirent.Name), - }, nil } + return nil, fuse.ENOENT } @@ -90,17 +90,16 @@ func (dir *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { } if dirs, e := filer.ListDirectories(*mountOptions.filer, dir.Path); e == nil { for _, d := range dirs.Directories { - dirId := uint64(d.Id) - dirent := fuse.Dirent{Inode: dirId, Name: d.Name, Type: fuse.DT_Dir} + dirent := fuse.Dirent{Name: string(d), Type: fuse.DT_Dir} ret = append(ret, dirent) - dir.DirentMap[d.Name] = &dirent + dir.DirentMap[string(d)] = &dirent } } if files, e := filer.ListFiles(*mountOptions.filer, dir.Path, ""); e == nil { for _, f := range files.Files { if fileId, e := storage.ParseFileId(string(f.Id)); e == nil { fileInode := uint64(fileId.VolumeId)<<48 + fileId.Key - dirent := fuse.Dirent{Inode: fileInode, Name: f.Name, Type: fuse.DT_File} + dirent := fuse.Dirent{Name: f.Name, Type: fuse.DT_File} ret = append(ret, dirent) dir.DirentMap[f.Name] = &dirent fileIdMap[fileInode] = f.Id @@ -120,13 +119,11 @@ func (dir *Dir) Remove(ctx context.Context, req *fuse.RemoveRequest) error { } type File struct { - Id uint64 FileId filer.FileId Name string } func (file *File) Attr(context context.Context, attr *fuse.Attr) error { - attr.Inode = file.Id attr.Mode = 0444 ret, err := filer.GetFileSize(*mountOptions.filer, string(file.FileId)) if err == nil { |
