-
Notifications
You must be signed in to change notification settings - Fork 96
Description
If you compile and run this program
package main
import (
"fmt"
"github.com/winfsp/cgofuse/fuse"
)
func main() {
fmt.Printf("fuse.O_APPEND = 0x%04x\n", fuse.O_APPEND)
fmt.Printf("fuse.O_CREAT = 0x%04x\n", fuse.O_CREAT)
fmt.Printf("fuse.O_EXCL = 0x%04x\n", fuse.O_EXCL)
fmt.Printf("fuse.O_TRUNC = 0x%04x\n", fuse.O_TRUNC)
}It prints this
Z:\go\src\github.com\rclone\rclone\cgofusetest>go run test.go
fuse.O_APPEND = 0x0008
fuse.O_CREAT = 0x0100
fuse.O_EXCL = 0x0400
fuse.O_TRUNC = 0x0200
However if you disable CGO and compile it you get a different answer with O_EXCL and O_TRUNC swapped over.
Z:\go\src\github.com\rclone\rclone\cgofusetest>set CGO_ENABLED=0
Z:\go\src\github.com\rclone\rclone\cgofusetest>go run test.go
fuse.O_APPEND = 0x0008
fuse.O_CREAT = 0x0100
fuse.O_EXCL = 0x0200
fuse.O_TRUNC = 0x0400
I believe the non CGO version is correct, at least that agrees with what I receive from WinFSP. It is defined here
cgofuse/fuse/fsop_nocgo_windows.go
Lines 107 to 108 in f0ad031
| O_EXCL = 0x0200 | |
| O_TRUNC = 0x0400 |
whereas the CGO version is defined here - this also looks correct
Lines 249 to 250 in f0ad031
| O_EXCL = int(C.O_EXCL) | |
| O_TRUNC = int(C.O_TRUNC) |
So something a little wacky is going on!
This is compiling on Windows 10 with go1.18.1 and gcc 8.1.0 provided by MinGW using latest released cgofuse v1.5.0 and latest stable WinFSP (2022 installed from 1.10.220006.msi).
This was originally reported in the rclone forum here: https://forum.rclone.org/t/cannot-copy-files-to-mounted-azure-storage-windows/30092 if you want some background.
I suspect that the problem might be with the WinFSP include files, but I couldn't figure out where the constants were defined.
You said before in #19 (comment) where we discussed a very similar issue
WinFsp-FUSE supports both the MSVC and Cygwin environments. In MSVC O_CREAT|O_RDWR translates to 0x0102. In Cygwin it translates to 0x0202. Cgofuse uses the MSVC environment, which is the reason you see 0x0102.
So I wonder if I'm including the Cygwin version of the fuse header files or something like that? This is the include I use
CPATH=C:\Program Files\WinFsp\inc\fuse;C:\Program Files (x86)\WinFsp\inc\fuse
Any help gratefully received!