-
Notifications
You must be signed in to change notification settings - Fork 18k
path/filepath: Walk walks recursive NTFS junction points #10424
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
Comments
@ClusterCat do you have a small program that I can run to see your problem? Thank you. Alex |
Sure @alexbrainman , a minimal example would be package main
import (
"log"
"os"
"path/filepath"
)
func main() {
err := filepath.Walk("C:\\Users\\USERNAME\\AppData\\Local", walkFunc)
if err != nil {
log.Fatalln(err)
}
}
func walkFunc(path string, info os.FileInfo, err error) error {
if err != nil {
log.Println(err)
}
return nil
} Just replace USERNAME and run on Win7 (don't know about the directory structure of later versions). Thanks, |
@ClusterCat thank you for the program. But you didn't not explain what is wrong with your program. What does your program output look like? What do you expect to see instead? Why? Thank you. Alex |
Ok, I'll try to explain more clearly... The starting path (C:\Users\username\AppData\Local) contains the ntfs junction "Application Data" which points to the starting path again (loop/recursion). When the program gets to the ntfs junction it walks into it and begins looping/recursion. It then creates about one path error for every file in the starting path, which is about 14000 path errors. Example output:
I expected Walk to skip the ntfs junction ("Application Data") and go on with the next real directory, avoiding many path errors because it does so for symbolic links. |
for about the argument |
@ClusterCat I cannot reproduce the output you see:
Am I missing something? I don't see problem with my output. Do you see problem with my output? Alex |
@alexbrainman your output looks fine. I don't see any problem with it either.
and then point the program to My output looks like
If your version stops at the first |
My output looks like:
Are you sure you're using go1.4.2? Windows symlink support has changed significantly between 1.3 and 1.4. What does your "go version" command output?
I don't believe in magic, there is always a reason. You should be able to work out what is going on. I would add new tmp test to path/filepath package that does something similar to your program above. Then add println or fmt.Printf statements in correspondent library code here and there (while running "go test ..." command) to see why your output is different from mine. You would obviously need Go source code for that. Alex |
Output of go version is: Ok, I will get the source code and will try to debug it like you said. This might take some time due to my time constraints atm. Just for the sake of completeness this are the ACLs for the
|
Too late for Go 1.5. |
@ClusterCat I think I can see what the problem is. Please see https://go-review.googlesource.com/36851 Alex |
CL https://golang.org/cl/36851 mentions this issue. |
For #10424. Change-Id: Ie4e87503b0ed04f65d2444652bd1db647d3529f4 Reviewed-on: https://go-review.googlesource.com/36851 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
CL https://golang.org/cl/41830 mentions this issue. |
go Version 1.4.2
Windows 7, AMD64
When using filepath.Walk on an NTFS Volume it follows NTFS junction points.
If there are junction points which point to a parent directory, this leads to recursion and following errors.
Example:
Windows 7 creates the junction points:
C:\Users\username\Local Settings -> C:\Users\username\AppData\local
C:\Users\username\Local Settings\Application Data -> C:\Users\username\AppData\local
which leads to errors like:
GetFileAttributesEx C:\Users\username\Local Settings\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Temp\go-build168935239: The system cannot find the file specified.
I expected Walk to not follow junction points, in accordance to the behavior of not following symlinks.
The text was updated successfully, but these errors were encountered: