1
0
mirror of https://github.com/golang/go synced 2024-09-30 20:28:32 -06:00
go/godoc/vfs
Hariharan Srinath 936084890a x/tools/godoc/vfs: adds NewNameSpace() and emptyVFS for better behavior
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>
2016-03-21 00:49:05 +00:00
..
gatefs tools: add import comments. 2014-12-09 22:42:16 +00:00
httpfs tools: add import comments. 2014-12-09 22:42:16 +00:00
mapfs tools: add import comments. 2014-12-09 22:42:16 +00:00
zipfs godoc/vfs/zipfs: use an os.IsNotExist-compatible error 2016-02-15 04:18:10 +00:00
emptyvfs_test.go x/tools/godoc/vfs: adds NewNameSpace() and emptyVFS for better behavior 2016-03-21 00:49:05 +00:00
emptyvfs.go x/tools/godoc/vfs: adds NewNameSpace() and emptyVFS for better behavior 2016-03-21 00:49:05 +00:00
namespace.go x/tools/godoc/vfs: adds NewNameSpace() and emptyVFS for better behavior 2016-03-21 00:49:05 +00:00
os.go godoc/vfs: close file on error 2015-06-01 03:28:17 +00:00
vfs.go tools: add import comments. 2014-12-09 22:42:16 +00:00