v1:
https://listman.redhat.com/archives/libguestfs/2022-April/028680.html
v2:
https://listman.redhat.com/archives/libguestfs/2022-April/028682.html
This version implements what I described here:
https://listman.redhat.com/archives/libguestfs/2022-April/028691.html
In brief, if you use create=true then the remote file is always
created, existing content is removed if the file was already present.
I think this is more predictable, and we can add further flags to
refine the behaviour if we think that's necessary in future.
Also this version uses setstat + SSH_FILEXFER_ATTR_PERMISSIONS to set
the mode. I have checked and this is not affected by umask, so you
get the exact mode that you request (at least, you do with OpenSSH).
Also we try to clean up the remote file if creation fails, although
it's best-effort only.
Also use a lock to prevent parallel requests from trying to create the
file twice.
Rich.