Closed palainp closed 2 years ago
There is in fact a sligh difference, my do a LSTAT
before openning the file, not sure if this will be done with any shells. This trace correspond to echo -n KO > test.txt
:
2021-11-02 16:30:23 +01:00: DBG [sshfs_protocol] [SSH_FXP_LSTAT 12] for '/test.txt'
2021-11-02 16:30:23 +01:00: DBG [sshfs_protocol] [SSH_FXP_OPEN 13] for '/test.txt' attrs=4
2021-11-02 16:30:23 +01:00: DBG [sshfs_protocol] [SSH_FXP_LSTAT 14] for '/test.txt'
2021-11-02 16:30:23 +01:00: DBG [sshfs_protocol] [SSH_FXP_WRITE 15] '/test.txt' @0 (2)
2021-11-02 16:30:23 +01:00: DBG [sshfs_protocol] [SSH_FXP_CLOSE 16] for /test.txt
2021-11-02 16:30:23 +01:00: DBG [sshfs_protocol] [SSH_FXP_LSTAT 17] for '/'
This one to cat test.txt
:
2021-11-02 16:30:57 +01:00: DBG [sshfs_protocol] [SSH_FXP_LSTAT 18] for '/test.txt'
2021-11-02 16:30:57 +01:00: DBG [sshfs_protocol] [SSH_FXP_OPEN 19] for '/test.txt' attrs=4
2021-11-02 16:30:57 +01:00: DBG [sshfs_protocol] [SSH_FXP_LSTAT 20] for '/test.txt'
2021-11-02 16:30:57 +01:00: DBG [sshfs_protocol] [SSH_FXP_READ 21] for '/test.txt' @0 (4096)
2021-11-02 16:30:57 +01:00: DBG [sshfs_protocol] [SSH_FXP_CLOSE 22] for /test.txt
2021-11-02 16:30:57 +01:00: DBG [sshfs_protocol] [SSH_FXP_LSTAT 23] for '/'
And finaly ./testw
(which is the result of the compilation of the C program):
2021-11-02 16:31:08 +01:00: DBG [sshfs_protocol] [SSH_FXP_OPEN 29] for '/test.txt' attrs=4
2021-11-02 16:31:08 +01:00: DBG [sshfs_protocol] [SSH_FXP_LSTAT 30] for '/test.txt'
2021-11-02 16:31:08 +01:00: DBG [sshfs_protocol] [SSH_FXP_WRITE 31] '/test.txt' @0 (2)
2021-11-02 16:31:08 +01:00: DBG [sshfs_protocol] [SSH_FXP_CLOSE 32] for /test.txt
Update: I was wrongly using attrs
instead of pflags
. The issue is solved :shame:
With a mounted disk.img I encountered a problem when I needed to write to the middle of files. For example, the second
echo
command is supposed to erase the entire file and does not:The two
echo
commands sendSSH_FXP_OPEN
thenSSH_FXP_LSTAT
thenSSH_FXP_WRITE
thenSSH_FXP_CLOSE
. As far as I think I can't tell the difference (from the server side) if the user's intention is to delete the file with a shell redirect or if the user just wants to update some bytes like with this program: