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: MkdirAll fails on Windows with extended volume name syntax #39785

ncw opened this issue Jun 23, 2020 · 5 comments

os: MkdirAll fails on Windows with extended volume name syntax #39785

ncw opened this issue Jun 23, 2020 · 5 comments


Copy link

@ncw ncw commented Jun 23, 2020

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 GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Dev\go
set GOPROXY=,direct
set GOROOT=c:\go
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set GOMOD=
set CGO_CFLAGS=-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 (

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 {

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")

This may be related to #22230

@cagedmantis cagedmantis changed the title os.MkdirAll fails on Windows with extended volume name syntax os: MkdirAll fails on Windows with extended volume name syntax Jun 23, 2020
@cagedmantis cagedmantis added this to the Backlog milestone Jun 23, 2020
Copy link

@cagedmantis cagedmantis commented Jun 23, 2020

At first glance, it certainly seems related to #22230

Copy link

@ianlancetaylor ianlancetaylor commented Jun 23, 2020

Copy link

@networkimprov networkimprov commented Jun 24, 2020

Related: #39786

cc @bcmills

Copy link

@ericwj ericwj commented Jul 7, 2020

Consider weighing in on #40104 to see issues like this finally be resolved once and forever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants