-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/tools/godoc/vfs: missing root directory listing when mounting vfs.NameSpace via httpfs and serving by http.FileServer #14190
Comments
godoc never relies on that functionality so it's possible it's just a bug we never noticed. |
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. |
Thanks! Submitted CL https://go-review.googlesource.com/19445 |
CL https://golang.org/cl/19445 mentions this issue. |
Hi Brad, did you get a chance to review the CL? |
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 <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
I'm trying to mount a few folders into a virtual file system via
vfs.NameSpace
and serving them usinghttp.FileServer
through ahttpfs.New()
. I am unable to see a listing of the root folder ofNameSpace
and get a404 page not found
.Interestingly, when i do
NameSpace.ReadDir("/")
on the NameSpace and loop through the results, i see the expected folders. There are also no problems getting a directory listing via eitherhttp.Dir()
orhttpfs.New(vfs.OS("FolderName"))
.Also when I directly browse the mounted folders (as explained below), I see the folders mounted properly. Only the root directory is not listing.
The text was updated successfully, but these errors were encountered: