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

Closed
ncw opened this issue Jun 23, 2020 · 6 comments
Closed

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

ncw opened this issue Jun 23, 2020 · 6 comments
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Milestone

Comments

@ncw
Copy link
Contributor

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 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 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 the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 23, 2020
@cagedmantis cagedmantis added this to the Backlog milestone Jun 23, 2020
@cagedmantis
Copy link
Contributor

At first glance, it certainly seems related to #22230

@cagedmantis
Copy link
Contributor

@ianlancetaylor
Copy link
Contributor

CC @alexbrainman

@networkimprov
Copy link

Related: #39786

cc @bcmills

@ericwj
Copy link

ericwj commented Jul 7, 2020

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

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/517015 mentions this issue: os: make MkdirAll support volume names

@golang golang locked and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

No branches or pull requests

6 participants