-
Notifications
You must be signed in to change notification settings - Fork 490
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
fix bug on create file #124
Conversation
Sorry, I'm having trouble following your description. Could you elaborate? What problem is being solved, and how is it triggered? The commit seems to consist mostly of whitespace changes. |
So sorry my explanation was terrible. So I was trying to fix a bug here: gl-prototypes/cmd-localfs@d3e65e6 The behavior we were seeing is when the flag /local # ls
Dockerfile LICENSE Makefile README.md cmd cmd-client data sshfs
/local # touch non_existent_file
touch: non_existent_file: No such file or directory
/local # touch non_existent_file
/local # echo "hello" > another_non_existent_file
sh: can't create another_non_existent_file: nonexistent directory
/local # echo "hello" > another_non_existent_file
/local # cat another_non_existent_file
hello
/local # strace touch blah_another_file
execve("/bin/touch", ["touch", "blah_another_file"], 0x7fff641a7e28 /* 7 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7f21e8e9bb88) = 0
set_tid_address(0x7f21e8e9bbc0) = 16
mprotect(0x7f21e8e98000, 4096, PROT_READ) = 0
mprotect(0x55c2e834d000, 16384, PROT_READ) = 0
getuid() = 0
utimensat(AT_FDCWD, "blah_another_file", NULL, 0) = -1 ENOENT (No such file or directory)
open("blah_another_file", O_RDWR|O_CREAT, 0666) = -1 ENOENT (No such file or directory)
write(2, "touch: blah_another_file: No suc"..., 52touch: blah_another_file: No such file or directory
) = 52
exit_group(1) = ?
+++ exited with 1 +++ |
Then with this fix it works with no error: /local # ls
Dockerfile LICENSE Makefile README.md cmd cmd-client data sshfs
/local # touch non_existent_file
/local # echo "hello" > another_non_existent_file
/local # cat another_non_existent_file
hello |
if (fi->flags & O_CREAT){ | ||
fi->flags = fi->flags &~ O_CREAT; | ||
return sshfs_open_common(path, mode, fi); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly the logic here, sorry the whitespace is a vim plugin
Do two calls to `open_common` one for the create and once for the remaining flags. The behavior we were seeing is when the flag `O_CREAT` is passed on `open` (via running `touch $file` or `echo "hello" > file`) then the call will error, as shown below. But, it still create an empty file. ``console /local # ls Dockerfile LICENSE Makefile README.md cmd cmd-client data sshfs /local # touch non_existent_file touch: non_existent_file: No such file or directory /local # touch non_existent_file /local # echo "hello" > another_non_existent_file sh: can't create another_non_existent_file: nonexistent directory /local # echo "hello" > another_non_existent_file /local # cat another_non_existent_file hello /local # strace touch blah_another_file execve("/bin/touch", ["touch", "blah_another_file"], 0x7fff641a7e28 /* 7 vars */) = 0 arch_prctl(ARCH_SET_FS, 0x7f21e8e9bb88) = 0 set_tid_address(0x7f21e8e9bbc0) = 16 mprotect(0x7f21e8e98000, 4096, PROT_READ) = 0 mprotect(0x55c2e834d000, 16384, PROT_READ) = 0 getuid() = 0 utimensat(AT_FDCWD, "blah_another_file", NULL, 0) = -1 ENOENT (No such file or directory) open("blah_another_file", O_RDWR|O_CREAT, 0666) = -1 ENOENT (No such file or directory) write(2, "touch: blah_another_file: No suc"..., 52touch: blah_another_file: No such file or directory ) = 52 exit_group(1) = ? +++ exited with 1 +++ ``` Signed-off-by: Jess Frazelle <[email protected]>
And I definitely don't know if this fix is correct but that is the behavior :) |
I don't think this can be the right solution. You are simply stripping out the O_CREAT flag, which changes the semantics of the operation. Furthermore, your examples run just fine on my system, so I suspect the problem is actually with your SSH server:
Which kind of server are you connecting to? |
7.7_p1-r2 from this package https://pkgs.alpinelinux.org/package/edge/main/x86_64/openssh if its the ssh server then I will close this, thanks for the help, i suspected it was a weird fix and wrong |
Do two calls to
open_common
one for the create and once for the open.I don't think this is a correct fix but just opening here for some direction.
The problem is when running
touch file
on master returns:It seems like
create
andopen
can't be done in one call.