-
Notifications
You must be signed in to change notification settings - Fork 86
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
Unknown flags being delivered to Create method #19
Comments
I think the relevant code is in the WinFsp-FUSE layer [link]: if ('C' == f->env->environment) /* Cygwin */
fi.flags = 0x0200 | 2 /*O_CREAT|O_RDWR*/;
else
fi.flags = 0x0100 | 2 /*O_CREAT|O_RDWR*/; WinFsp-FUSE supports both the MSVC and Cygwin environments. In MSVC From the MSVC #define _O_RDONLY 0x0000 // open for reading only
#define _O_WRONLY 0x0001 // open for writing only
#define _O_RDWR 0x0002 // open for reading and writing
#define _O_CREAT 0x0100 // create and open file The go constant const (
// Invented values to support what package os expects.
O_RDONLY = 0x00000
O_WRONLY = 0x00001
O_RDWR = 0x00002
O_CREAT = 0x00040
O_EXCL = 0x00080
O_NOCTTY = 0x00100
O_TRUNC = 0x00200
O_NONBLOCK = 0x00800
O_APPEND = 0x00400
O_SYNC = 0x01000
O_ASYNC = 0x02000
O_CLOEXEC = 0x80000
) From the perspective of a cgofuse client, this is a bug in cgofuse. I will have it fixed (and also examine |
That is very interesting - thanks for working that out. So that mystery 0x100 should be O_CREAT... From the perspective of that code the O_TRUNC has gone missing too. I read that (linux) FUSE doesn't normally supply O_TRUNC to Open - it opens the file and then truncates it. From rclone's perspective I'd much rather know about the truncation when I open the file (so I don't needlessly fetch it just to truncate it), so I've been using If not I can jiggle the code around to make a pending truncate without too many problems to avoid the fetch then truncate dance. |
You are correct, WinFsp does not support atomic truncation. You will always get The reasons for this are complicated and it has to do both with WinFsp and Windows design. The primary reason is that after the user mode file system The native WinFsp API includes a hint during |
Thanks for clearing that up - I'll go back to plan A and remove the |
BTW, as I am looking into resolving this I note that cgofuse already defines its own https://github.com/billziss-gh/cgofuse/blob/master/fuse/fsop.go#L118-L128 It looks to me as if the intent was that constants such as |
Ah ha! So if I use the fuse.O_CREAT then would all be well? I'd need to write a translator for fuse constants -> go constants which would be quite straight forward. I note that your passthrough code makes the assumption that you can pass Open flags straight to syscall.Open. I don't think this code runs on Windows though does it? |
Yes. That would do it. In retrospect we should have probably used the
You are right. I now wish I had spent the time to get it to run on Windows, because it would have probably caught this problem. |
Given our discussion in #3 and the fact the cgofuse has its own |
Yes that is fine. It should probably say in the Open docs that the flags a combination of the fuse.O_* constants. Or maybe here. Or perhaps best of all a comment above the definition that these flags should be passed into Open() etc would look nice in the docs. |
Agreed. I will have this added some time later today. |
Commit 487e2ba improves the documentation. |
I'm trying to track down a problem with my new mount code and rclone. I've changed the way the open flags are handled to (optionally) enable on disk caching which will make the file system a whole lot more compatible.
What seems to be happening is that when cgofuse calls the Create method, it calls it with some flags that rclone doesn't understand - in particular the 0x100 flag doesn't seem to match anything.
The flags which were supplied by the go program writing to the mount were from ioutil.WriteFile so should have been
os.O_WRONLY|os.O_CREATE|os.O_TRUNC
. So it is as if O_TRUNC is being delivered as 0x100.Can you confirm? Am I making a mistake assuming that the open flags are the same as the go flags?
I haven't managed to find definitions for these flags anywhere in your code so I'm not sure where the constants come from!
If you want to play with the code it is on the vfs-rw branch and I've been running in
cmd/cmount
the commandgo test -v -tags cmount
.Any help much appreciated - thanks!
The text was updated successfully, but these errors were encountered: