-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
x/sys/windows: wrong value of S_IFMT mask on Windows/plan9 #32270
Comments
As I noted in the issue over on
So, it would seem likely that they can be fixed with no issues. |
S_IFMT is meaningless on Windows (there is no such constant anywhere in Windows API). I suspect windows version of syscall.S_IFMT was added when windows port of Go was created. We, probably, could not compiled os package because it was referring to some Unix names - including S_IFMT. And we just copied these consts from another OS source file, like from syscall_linux.go. Just to make things build. Later on we added windows specific code in os package, but syscall.S_IFMT was left behind as is. I think no one should be using syscall.S_IFMT on windows, because it has no meaning. I doubt we could change syscall.S_IFMT value, because of https://golang.org/doc/go1compat Leaving for others to decide what to do here. Alex |
RE: changing the
The For plan9, it appears as well, for instance in NFS: https://github.com/cao-xx/plan-9/blob/b27a35643e4ee0ede5ed91ecb3a4ed98f8164454/sys/src/cmd/9nfs/nfs.h#L39 with the value of |
This only apply to changes by the OS. Otherwise syscall package is frozen.
That does not apply to Go. Alex |
Additionally, from the golang documentation:
The purpose of those resources it to point out that anytime these two OSes use |
Let me rephrase my argument. On both plan9 and windows: It would be so much simpler in this argument, if |
@puellanivis I don't make decisions here. You don't need to convince me. Go ahead and send a change https://golang.org/doc/contribute.html and see what happens. Alex |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputIt seems that value of syscall.S_IFMT mask is wrong on Windows/Plan9. It is defined as 0x1f000 while it is defined as 0xf000 on other platforms.
I had previously entered an issue on the sftp package page:
pkg/sftp#291
The code is testing the result of an SSH_FXP_STAT request on an AIX server. It tests the filemode bits with syscall.S_IFMT mask. The results should be S_IFDIR, but the mask tests an extra bit that is used as S_IFJOURNAL on AIX, hence failing to get the correst value.
The different values tested are:
As you can see, none of the values match the input, and the leftmost bit is not used by any value.
The input would match S_IFDIR if the S_IFMT mask didn't test the leftmost bit.
The text was updated successfully, but these errors were encountered: