From 3834de5ab12345dc0d47ccc2345bb3bcef6521eb 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 fae416d64..4cbe8ea5c 100644 --- a/cmd/mount2/node.go +++ b/cmd/mount2/node.go @@ -226,7 +226,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 @@ -234,7 +234,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.