From 7f1240516e4a7a657e78f3f5c4977c57d1a8215f Mon Sep 17 00:00:00 2001 From: Filipe Azevedo Date: Sat, 3 Sep 2022 00:25:39 +0200 Subject: [PATCH] mount2: Fix missing . and .. entries --- cmd/mount2/node.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/mount2/node.go b/cmd/mount2/node.go index 7544040b8..74d05c7d9 100644 --- a/cmd/mount2/node.go +++ b/cmd/mount2/node.go @@ -227,7 +227,7 @@ type dirStream struct { // HasNext indicates if there are further entries. HasNext // might be called on already closed streams. func (ds *dirStream) HasNext() bool { - return ds.i < len(ds.nodes) + return ds.i < len(ds.nodes)+2 } // Next retrieves the next entry. It is only called if HasNext @@ -235,7 +235,22 @@ func (ds *dirStream) HasNext() bool { // indicate I/O errors func (ds *dirStream) Next() (de fuse.DirEntry, errno syscall.Errno) { // defer log.Trace(nil, "")("de=%+v, errno=%v", &de, &errno) - fi := ds.nodes[ds.i] + if ds.i == 0 { + ds.i++ + return fuse.DirEntry{ + Mode: fuse.S_IFDIR, + Name: ".", + Ino: 0, // FIXME + }, 0 + } else if ds.i == 1 { + ds.i++ + return fuse.DirEntry{ + Mode: fuse.S_IFDIR, + Name: "..", + Ino: 0, // FIXME + }, 0 + } + fi := ds.nodes[ds.i-2] de = fuse.DirEntry{ // Mode is the file's mode. Only the high bits (e.g. S_IFDIR) // are considered.