On Thu, Oct 10, 2024 at 11:01:48AM +0200, Stefan Metzmacher wrote:
MS-FSA 2.1.5.4 Server Requests a Write has this: If ByteOffset equals -2, then set ByteOffset to Open.CurrentByteOffset. So I think if a file is opened with O_APPEND (on the client), a write() syscall without explicit offset (so no pwrite), could be mapped to an SMB2 write with offset -2. But I fear the linux vfs layer already replaces offset before cifs_file_write_iter() and friends are called... But I guess the per operation IOCB_APPEND flag can be used in order to decide if offset -2 should be used. On the server we could map that to pwritev2(RWF_APPEND). So O_APPEND could be a client only thing...
Hmmm. We should test against a Windows server doing an open with FILE_APPEND_DATA|SYNCHRONIZE and an offset of other than -2, and see if it writes at the end of file or not. Looks like the protocol has one way of expressing APPEND, and the internal syscall has another. We need to figure out what is required on the wire to see what works.