From 5a0a709016f6530a3eca225499f5f814c1a38948 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 12 Feb 2022 05:27:16 -0800 Subject: it runs, but directory listing output is not showing up --- weed/mount/weedfs_dir_read.go | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'weed/mount/weedfs_dir_read.go') diff --git a/weed/mount/weedfs_dir_read.go b/weed/mount/weedfs_dir_read.go index 43eb17bf2..a696953a1 100644 --- a/weed/mount/weedfs_dir_read.go +++ b/weed/mount/weedfs_dir_read.go @@ -5,8 +5,10 @@ import ( "github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/filesys/meta_cache" "github.com/chrislusf/seaweedfs/weed/glog" + "github.com/chrislusf/seaweedfs/weed/util" "github.com/hanwen/go-fuse/v2/fuse" "math" + "os" ) // Directory handling @@ -31,26 +33,45 @@ func (wfs *WFS) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, out *fus func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPlusMode bool) fuse.Status { dirPath := wfs.inodeToPath.GetPath(input.NodeId) + println("input size", input.Size, "offset", input.Offset, "pid", input.Caller.Pid) + var dirEntry fuse.DirEntry + if input.Offset == 0 { + dirEntry.Ino = input.NodeId + dirEntry.Name = "." + dirEntry.Mode = toSystemMode(os.ModeDir) + out.AddDirEntry(dirEntry) + + parentDir, _ := dirPath.DirAndName() + parentInode := wfs.inodeToPath.GetInode(util.FullPath(parentDir)) + dirEntry.Ino = parentInode + dirEntry.Name = ".." + dirEntry.Mode = toSystemMode(os.ModeDir) + out.AddDirEntry(dirEntry) + + } + + var counter uint64 processEachEntryFn := func(entry *filer.Entry, isLast bool) bool { + counter++ + if counter <= input.Offset { + return true + } dirEntry.Name = entry.Name() inode := wfs.inodeToPath.GetInode(dirPath.Child(dirEntry.Name)) + println("entry", dirEntry.Name, "inode", inode) dirEntry.Ino = inode dirEntry.Mode = toSystemMode(entry.Mode) if !isPlusMode { if !out.AddDirEntry(dirEntry) { return false } - } else { entryOut := out.AddDirLookupEntry(dirEntry) if entryOut == nil { return false } - entryOut.Generation = 1 - entryOut.EntryValid = 1 - entryOut.AttrValid = 1 - wfs.setAttrByFilerEntry(&entryOut.Attr, inode, entry) + wfs.outputEntry(entryOut, inode, entry) } return true } @@ -67,5 +88,6 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl glog.Errorf("list meta cache: %v", listErr) return fuse.EIO } + return fuse.OK } -- cgit v1.2.3