Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/godoc/vfs: missing root directory listing when mounting vfs.NameSpace via httpfs and serving by http.FileServer #14190
I'm trying to mount a few folders into a virtual file system via
Interestingly, when i do
Also when I directly browse the mounted folders (as explained below), I see the folders mounted properly. Only the root directory is not listing.
I have figured out the reason this bug is happening. The issue is that behavior of
The issue is that
The use case above mounts several folders under root but nothing at root breaking this implicit assumption. Unless we explicitly bind a
Most algorithms that traverse a directory structure either
I was able to get the right behavior by If i mount an empty directory at root like below.
I think the least disruptive resolution to this issue will be to add a
Happy to work on a CL if the approach sounds ok.
I have a working implementation of a fix for this issue at https://github.com/srinathh/emptyvfs for review/discussion of the proposed solution approach.
If the approach looks ok, I can move the implementation into
Feel free to send a code review. In addition to being easier to review in Gerrit, it will also guarantee that you've signed a CLA (since our Gerrit doesn't allow uploads before a CLA is signed). Reviewers shouldn't be reviewing code elsewhere (e.g. your personal github repo) without knowing a CLA is on file anyway.
The existing implementation of NameSpace implicitly assumes that a FileSystem with a directory at the top will be mounted at the root mount point "/" of the NameSpace. If this is not the case, then Stat("/") will fail even if ReadDir("/") succeedes. This is unexpected behavior which breaks directory traversal routines (eg. http.FileServer). This CL adds an unexported implementation of FileSystem called emptyVFS that emulates an empty directory and adds a NewNameSpace() function that binds emptyVFS to "/" so that unexpected behavior does not arise even if the use does not mount anything explicitly at "/". Latest patch set causes the FileInfo of the empty top level emulated directory to return "/" for Name() and Zero Time for ModTime() and removes the related struct state fields being used in the previous implementation. Fixes golang/go#14190 Change-Id: Idce2fc3c9b81206847a33840d76b660059d53d18 Reviewed-on: https://go-review.googlesource.com/19445 Reviewed-by: Brad Fitzpatrick <email@example.com> Run-TryBot: Brad Fitzpatrick <firstname.lastname@example.org>