On 04/17/22 12:42, Richard W.M. Jones wrote:
Thinking about this even more, maybe if create=true we want to
always
create the file, and never ignore create-mode or create-size?
(One issue with the current code is if the file exists already, we
truncate it to the correct size but leave the existing content. But
callers might reasonably expect that create=true creates an
all-zeroes sparse file).
I think we could do this using O_TRUNC. The permissions can be set
using sftp_setstat (which I think ignores umask).
Yes, O_CREAT|O_TRUNC also makes sense (as the sole way to "create") --
what you describe above is basically fopen("w+"), so there's definitely
"prior art" for the usefulness of this!
Laszlo