os: MkdirAll fails on Windows with extended volume name syntax
ncw opened this issue · 6 comments
ncw commented
What version of Go are you using (go version)?
go version devel +18bcc7c285 Tue Jun 23 14:32:35 2020 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes, the above is latest tip
What operating system and processor architecture are you using (go env)?
Tested with Windows 10 with a binary cross compiled from Linux.
Here is go env from the Windows box (which isn't running go-tip as I don't know how to compile it on Windows!)
go env Output
set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\Dev\AppData\Local\go-build set GOENV=C:\Users\Dev\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\Dev\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=c:\go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=c:\go\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\Dev\AppData\Local\Temp\go-build801995766=/tmp/go-build -gno-record-gcc-switches
What did you do?
I ran this program
package main
import (
"fmt"
"os"
)
func main() {
for _, arg := range os.Args[1:] {
fmt.Printf("About to MkdirAll(%q)\n", arg)
err := os.MkdirAll(arg, 0777)
if err != nil {
fmt.Printf("...Returned error: %v\n", err)
} else {
fmt.Printf("...OK\n")
}
}
}With the extended volume name from mountvol.exe (run mountvol to see the extended name for your disk)
I ran
mkdirall.exe \\?\Volume{97bb9c9b-0000-0000-0000-402400000000}\go-test
What did you expect to see?
I expected this to create the go-test directory on C:
What did you see instead?
Z:\>mkdirall.exe \\?\Volume{97bb9c9b-0000-0000-0000-402400000000}\go-test
About to MkdirAll("\\\\?\\Volume{97bb9c9b-0000-0000-0000-402400000000}\\go-test")
...Returned error: mkdir \\?: The filename, directory name, or volume label syntax is incorrect.
Note that this succeeds if the directory already exists
Z:\>mkdir \\?\Volume{97bb9c9b-0000-0000-0000-402400000000}\mkdir-test
Z:\>dir \\?\Volume{97bb9c9b-0000-0000-0000-402400000000}\mkdir-test
Volume in drive \\?\Volume{97bb9c9b-0000-0000-0000-402400000000} has no label.
Volume Serial Number is 464C-ABA7
Directory of \\?\Volume{97bb9c9b-0000-0000-0000-402400000000}\mkdir-test
23/06/2020 17:41 <DIR> .
23/06/2020 17:41 <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 9,107,767,296 bytes free
Z:\>mkdirall.exe \\?\Volume{97bb9c9b-0000-0000-0000-402400000000}\mkdir-test
About to MkdirAll("\\\\?\\Volume{97bb9c9b-0000-0000-0000-402400000000}\\mkdir-test")
...OK
This may be related to #22230
cagedmantis commented
At first glance, it certainly seems related to #22230
cagedmantis commented
ianlancetaylor commented
networkimprov commented
ericwj commented
Consider weighing in on #40104 to see issues like this finally be resolved once and forever.
gopherbot commented
Change https://go.dev/cl/517015 mentions this issue: os: make MkdirAll support volume names