Skip to content
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

os: Stat.Name returns wrong value for directory junction #16145

Closed
alexbrainman opened this issue Jun 22, 2016 · 2 comments
Closed

os: Stat.Name returns wrong value for directory junction #16145

alexbrainman opened this issue Jun 22, 2016 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Milestone

Comments

@alexbrainman
Copy link
Member

It appears that directory junction created with junction.exe (available from Microsoft at: https://technet.microsoft.com/en-us/sysinternals/bb896768) cannot be os.Stat(ed):

c:\a>dir
 Volume in drive C has no label.
 Volume Serial Number is 1234-5678

 Directory of c:\a

22/06/2016  03:48 PM    <DIR>          .
22/06/2016  03:48 PM    <DIR>          ..
22/06/2016  03:42 PM               162 main.go
               1 File(s)            162 bytes
               2 Dir(s)   3,354,419,200 bytes free

c:\a>mkdir dir

c:\a>echo "abc" > dir\file.txt

c:\a>mklink /J mklink dir
Junction created for mklink <<===>> dir

c:\a>junction junction dir

Junction v1.06 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

Created: c:\a\junction
Targetted at: c:\a\dir

c:\a>dir
 Volume in drive C has no label.
 Volume Serial Number is 1234-5678

 Directory of c:\a

22/06/2016  03:48 PM    <DIR>          .
22/06/2016  03:48 PM    <DIR>          ..
22/06/2016  03:48 PM    <DIR>          dir
22/06/2016  03:48 PM    <JUNCTION>     junction [\??\c:\a\dir]
22/06/2016  03:42 PM               162 main.go
22/06/2016  03:48 PM    <JUNCTION>     mklink [c:\a\dir]
               1 File(s)            162 bytes
               5 Dir(s)   3,354,419,200 bytes free

c:\a>type mklink\file.txt
"abc"

c:\a>type junction\file.txt
"abc"

c:\a>junction mklink

Junction v1.06 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

c:\a\mklink: JUNCTION
   Print Name     : c:\a\dir
   Substitute Name: c:\a\dir


c:\a>junction junction

Junction v1.06 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

c:\a\junction: JUNCTION
   Substitute Name: c:\a\dir


c:\a>type main.go
package main

import (
        "fmt"
        "log"
        "os"
)

func main() {
        fi, err := os.Stat(os.Args[1])
        if err != nil {
                log.Fatal(err)
        }
        fmt.Printf("%s\n", fi.Name())
}

c:\a>go version
go version devel +1f44643 Wed Jun 22 00:12:55 2016 +0000 windows/amd64

c:\a>go run main.go mklink
dir

c:\a>go run main.go junction
2016/06/22 15:50:00 Lstat : The system cannot find the path specified.
exit status 1

c:\a>

Alex

@gopherbot
Copy link

CL https://golang.org/cl/25320 mentions this issue.

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 2016
gopherbot pushed a commit that referenced this issue Oct 12, 2016
Updates #15978
Updates #16145

Change-Id: I161f5bc97d41c08bf5e1405ccafa86232d70886d
Reviewed-on: https://go-review.googlesource.com/25320
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
@gopherbot
Copy link

CL https://golang.org/cl/31118 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Projects
None yet
Development

No branches or pull requests

4 participants